Custom key
The configuration file on the Zabbix agent defines user-defined parameters by the user through the Userparameter directive
Userparameter=<key>,<command>userparameter=<key[*]>,<command> $1...$9
Example 1 (without parameters)
[[email protected] ~]# Vim/etc/zabbix/zabbix_agentd.confuserparameter=system.memory.free,awk '/^memfree/{print /proc/meminfo[[email protected] ~]# systemctl restart zabbix-agent in server-side testing [[email protected] ~]# zabbix_get-s 10.1.249.168-k ' System.memory.free ' 89844
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/8B/4B/wKiom1hI_1HydwLHAAAsguePnds119.png-wh_500x0-wm_3 -wmp_4-s_3420878369.png "title=" 1.png "alt=" Wkiom1hi_1hydwlhaaasguepnds119.png-wh_50 "/>
Example 2 (with parameters)
[[email protected] ~]# Vim/etc/zabbix/zabbix_agentd.confuserparameter=system.memory.usage[*],awk '/^$1/{print $$2} ' /proc/meminfo[[email protected] ~]# systemctl restart zabbix-agent in server-side testing [[email protected] ~]# zabbix_get-s 10.1.249.168-k ' system.memory.usage[memtotal] ' 493224[[email protected] ~]# zabbix_get-s 10.1.249.168-k ' System.memory.usage[memfree] ' 89188[[email protected] ~]# zabbix_get-s 10.1.249.168-k ' system.memory.usage[ Memavailable] ' 342664
Practical cases
(Monitor the Nginx status page for each indicator)
[[email protected] ~]# vim /etc/zabbix/zabbix_agentd.confuserparameter=nginx.status[*],/ tmp/status.sh $1[[email protected] ~]# vim /tmp/status.sh #!/bin/bash#host= 10.1.249.168port= ' statusurl= '/status ' active () { curl -s http://${host }:${port}${statusurl} | awk '/^active/{print $3} '}accepts () { curl -s http://${host}:${port}${statusurl} | awk ' nr==3{print $1} '}handled () { curl -s http://${host}:${port}${statusurl} | awk ' nr== 3{print $2} '}requests () { curl -s http://${host}:${port}${statusurl } | awk ' nr==3{print $3} '}reading () { curl -s http:/ /${host}:${port}${statusurl} | awk ' nr==4{print $2} '}writing () { curl -s http://${host}:${port}${statusurl} | awk ' nr==4{print $4} '}waiting () { curl -s http://${host}:${port}${statusurl} | awk ' nr==4{print $6} '}$ 1[[email protected] ~]# chmod +x /tmp/status.sh in server-side testing [[email protected] ~] # zabbix_get -s 10.1.249.168 -k ' nginx.status[accepts] '//parameters can be changed
This article is from the "Homecoming" blog, make sure to keep this source http://sixijie123.blog.51cto.com/11880770/1880732
Zabbix's Custom key (10)