Objective: To obtain the IP addresses of all monitored machine hosts in zabbix
Method 1 use zabbix API to interface Python Program
Method 2 directly use the database for query and export
Here we will use method 2 to introduce
Mysql-uusername-ppassword log on to MySQL
Mysql> Use zabbix select zabbix Library
Mysql> select * from interface limit; table for viewing interface information. One field in the table is IP address (the hosts table contains the host and name fields, but there is no interface IP field)
+ ------------- + -------- + ------ + ------- + ---------------- + ----- + ------- +
| Interfaceid | hostid | main | type | useip | IP | DNS | Port |
+ ------------- + -------- + ------ + ------- + ---------------- + ----- + ------- +
| 255 | 10361 | 1 | 1 | 1 | 192.168.213.21 | 10050 |
| 256 | 10362 | 1 | 1 | 1 | 192.168.213.22 | 10050 |
| 257 | 10363 | 1 | 1 | 1 | 192.168.213.23 | 10050 |
| 258 | 10364 | 1 | 1 | 1 | 192.168.213.24 | 10050 |
| 259 | 10365 | 1 | 1 | 1 | 192.168.213.25 | 10050 |
| 261 | 10367 | 1 | 1 | 1 | 192.168.213.27 | 10050 |
| 262 | 10368 | 1 | 1 | 1 | 192.168.213.28 | 10050 |
| 263 | 10369 | 1 | 1 | 1 | 192.168.213.29 | 10050 |
| 264 | 10370 | 1 | 1 | 1 | 192.168.213.30 | 10050 |
| 265 | 10371 | 1 | 1 | 1 | 192.168.213.31 | 10050 |
+ ------------- + -------- + ------ + ------- + ---------------- + ----- + ------- +
Mysql> select * from interface into OUTFILE '/tmp/zabbix. ip'; the table has been exported in text format (note that the exported path is required for database login. You have the write permission for this path, and the/tmp permission is 777)
How to Get zabbix to monitor the IP addresses of all machines