Preface: in the previous period in the deployment of ZABBIX, there is a need to monitor the status of the container is the occupation of CPU memory IO, so I wrote a script, and the template, share a hey hey:

waste I will not say much, directly start the

first choice, zabbix_agentd configuration VIM /us. R/local/zabbix/etc/zabbix_agentd.conf

 UserParameter=docker.discovery, /usr/local/zabbix/script/docker.py UserParameter=docker.[*], /usr/local/zabbix/script/docker.py $1 $2

are docker.py scripts, using the automatic discovery rules to send the current container, and then specify the container to get the state. /usr/bin/python import sys import OS import JSON def discover (): D = {} = {} = {} {} = {} = {} = {} Def status (name, action): if action = = "Ping": CMD ='docker inspect --format=. Esult = os.popen (CMD).Read ().Replace ("n", "") if "%" in result: print float (result.replace ("%")) Find the pit of the rules. I was pits for a long time to find out... One must return to JSON format content, two is info['{#CONTAINERNAME}'] and this key must write {#CONTAINERNAME}...

returns the result as follows:.

 {"data"]: [{"{#CONTAINERNAME}": node-3 "}, {" {#CONTAINERNAME}] ":" node-2 "}, {" {#CONTAINERNAME} ":" node-1 "}," {#CONTAINERNAME} "" Web "}," {#CONTAINERNAME} "," cadvisor "), {'{#CONTAINERNAME}': updatol '}, {' {#CONTAINERNAME} ':' research '}, {'} ', {'}, {'}, {'}, {'} Is "}, {" {#CONTAINERNAME} ":" MySQL "}, {" {#CONTAINERNAME} ":" SSDB ""}]}

"the other function is very simple, that is to call the docker command to get the data.

automatic discovery of the rules is so that the

only monitors these States, and another trigger is the Ping to check whether the current status of the container is running, if it is not to call the alarm. The

templates are as follows:

 < XML version= "UTF-8" encoding= "UTF-8"? > < zabbix_export> dialectical; dialectical; dialectical; dialectical; dialectical; dialectical; dialectical; dialectical; Es> < template> < template> docker-status< /template> < name> docker-status< /name> < constructs; souls; souls; societies; societies; societies; societies; societies; societies; societies; societies; societies; societies; societies; societies; societies; > < name> docker_test< /name> < /application> < /applications> < items/> < constructs; constructs; souls; societies; societies; societies; societies; societies; societies; societies; souls; < key> docker.discovery< /key> < delay> 60< /delay> < status> 0< Tocol> 0< /snmpv3_authprotocol> < snmpv3_authpassphrase/> < snmpv3_privprotocol> 0< /snmpv3_privprotocol> < snmpv3_privpassphrase/>. Ame/> < password/> < publickey/> < privatekey/> < port/> < filter> < plurality; dialectical; Alue> @ CONTAINER NAME< /value> < operator> 8< /operator> < formulaid> A<. < item_prototype> < name> Container {#CONTAINERNAME} Diskio usage:< /name> < type> 0< plurality; dialectical. < delay> 60< /delay> < history> 90< /history> < trends> 0< /trends> constructs; souls; souls; societies; societies; societies; societies; societies; societies; societies; societies; societies; societies; societies; societies; societies; Snmpv3_contextname/> < snmpv3_securityname/> < snmpv3_securitylevel> 0< /snmpv3_securitylevel> < snmpv3_authprotocol> 0< /snmpv3_authprotocol> < snmpv3_privpassphrase/> < formula> 1< /formula> < delay_flex/> < params/> < ipmi_sensor/> societies; societies; societies; societies; societies; societies; societies; societies; societies; societies; Blickey/> < privatekey/> < port/> < description/> < inventory_link> 0< /inventory_link>. Gt; < valuemap/> < logtimefmt/> < application_prototypes/> < /item_prototype> < item_prototype>. Multiplier> 0< /multiplier> < snmp_oid/> < key> docker.[{#CONTAINERNAME}, CPUPerc]< /key> < delay> constructs; souls; souls; societies; societies; societies; societies; societies; societies; societies; societies; societies; Pe> 0< /value_type> < allowed_hosts/> < units>%< /units> < delta>. 0< /snmpv3_authprotocol> < snmpv3_authpassphrase/> < snmpv3_privprotocol> 0< /snmpv3_privprotocol> < snmpv3_privpassphrase/> < Data_type> 0< /data_type> < authtype> 0< /authtype> < username/> < password/> Ations> < application> < name> docker_test< /name> < /application> < /applications>. < name> Container {#CONTAINERNAME} MEM usage:< /name> < type> 0< /type>. ; < history> 90< /history> < trends> 365< /trends> < status> 0<. > < snmpv3_securityname/> < snmpv3_securitylevel> 0< /snmpv3_securitylevel> < snmpv3_authprotocol> 0< /snmpv3_authprotocol> < Phrase/> < formula> 1< /formula> < delay_flex/> < params/> < ipmi_sensor/> < societies; societies; societies; societies; societies; societies; peoples; < privatekey/> < port/> < description/> < inventory_link> 0< /inventory_link> <. Map/> < logtimefmt/> < application_prototypes/> < /item_prototype> < item_prototype> < name> Container; T; /multiplier> < snmp_oid/> < key> docker.[{#CONTAINERNAME}, NetIO]< /key> < delay> 60< societies; societies; societies; societies; societies; societies; societies; societies; societies; societies; societies; E> < allowed_hosts/> < units/> < delta> 0< /delta> < snmpv3_contextname/>. < snmpv3_au


This concludes the body part