Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Zabbix automatic monitoring

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

192.168.29.130 is the main server for installing Zabix

192.168.29.129 is from the server

1) automatic discovery

Zabbix API

Vim / etc/zabbix/zabbix_agentd.conf in slave server 192.168.29.129 ip

ServerActive=192.168.29.129

Hostname=linux-node2.example.com

HostMetadataItem=system.uname

Zabbix_get-s 192.168.29.130-k system.uname is tested on the master server

/ etc/init.d/zabbix-agent restart

2) Network Discovery

Turn off automatic registration

Vim / etc/zabbix/zabbix_agentd.conf is in the slave server

Server=192.168.29.130

StartAgents=3

ServerActive=127.0.0.1

Grep'^ [a Murz]'/ etc/zabbix/zabbix_agentd.conf

/ etc/init.d/zabbix-agent restart

Http://192.168.29.130/zabbix/hosts.php?ddreset=1&sid=9d7240bdae42f8f3

Perform relevant actions in the web page

3) disable auto-registration and delete auto-discovered machines in API mode

1. Verification

Https://www.zabbix.com/documentation/2.4/manual/api/reference/user/login

Curl-s-X POST-H 'Content-Type:application/json'-d'

{

"jsonrpc": "2.0"

"method": "user.login"

"params": {

"user": "Admin"

"password": "zabbix"

}

"id": 1

} 'http://192.168.29.130/zabbix/api_jsonrpc.php | python-mjson.tool

Return data

{

"id": 1

"jsonrpc": "2.0"

"result": "72e104119c242914115b5221e5bf1672"

}

Https://www.zabbix.com/documentation/2.4/manual/api/reference/host/get

two。 Request api with sessionid attached

Curl-s-X POST-H 'Content-Type:application/json'-d'

{

"jsonrpc": "2.0"

"method": "host.get"

"params": {

"output": ["hostid"]

"selectGroups": "extend"

"filter": {

"host": [

"Zabbix server"

]

}

}

"auth": "72e104119c242914115b5221e5bf1672"

"id": 2

} 'http://192.168.29.130/zabbix/api_jsonrpc.php | python-mjson.tool

Https://www.zabbix.com/documentation/2.4/manual/api/reference/host/create

Curl-s-X POST-H 'Content-Type:application/json'-d'

{

"jsonrpc": "2.0"

"method": "host.create"

"params": {

"host": "Linux server"

"interfaces": [

{

"type": 1

"main": 1

"useip": 1

"ip": "192.168.29.129"

"dns":

"port": "10050"

}

]

"groups": [

{

"groupid": "2"

}

]

"templates": [

{

"templateid": "10001"

}

]

"inventory_mode": 0

"inventory": {

"macaddress_a": "01234"

"macaddress_b": "56768"

}

}

"auth": "72e104119c242914115b5221e5bf1672"

"id": 5

} 'http://192.168.29.130/zabbix/api_jsonrpc.php | python-mjson.tool

Data returned successfully

{

"id": 5

"jsonrpc": "2.0"

"result": {

"hostids": [

"10114"

]

}

}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report