Get the App
SLTechnology News&Howtos  ›  Servers  › 

Zabbix automatic monitoring

Shulou Source: shulou.com Published: 2022-06-02 17:12:07 09月22日 Update

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"

]

}

}

Tags: Servers services data success methods machines networks web pages testing authentication monitoring Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi macOS Apple Shulou Tech Info MariaDB