Skip to content

Commit

Permalink
Merge pull request #22 from rpsedlak/integration
Browse files Browse the repository at this point in the history
Version 1.0.1 complete
  • Loading branch information
rpsedlak committed Dec 21, 2015
2 parents 1efc499 + a89f588 commit 619e12f
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 14 deletions.
17 changes: 17 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Release notes

## Release 1.0.1 - 12/21/2015
* #20 - Changed collection delay for docker version
* #18 - Implemented WARNING trigger for paused containers
* #17 - Implemented AVERAGE trigger for OMMKilled containers
* #16 - Corrected install.sh problem for overridden directories
* #15 - Implemented value file caching on zabbix-agent host to keep docker from becoming over loaded.
* #12 - Changed "Docker Storage Driver Deferred Removal Enabled" from text to unsigned int (Boolean value).

## Release 1.0.0 - 12/19/2015
* Feature complete
* Supports docker 'inspect'
* Supports docker 'stats' commands
* Supports docker 'info'
* Supports Zabbix LLD

26 changes: 22 additions & 4 deletions ZabbixDockerTemplate.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>2.0</version>
<date>2015-12-18T04:08:42Z</date>
<date>2015-12-21T20:59:49Z</date>
<groups>
<group>
<name>Templates</name>
Expand Down Expand Up @@ -733,12 +733,12 @@
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>docker.info[Deferred Removal Enabled]</key>
<key>docker.info.boolean[Deferred Removal Enabled]</key>
<delay>3600</delay>
<history>90</history>
<trends>365</trends>
<status>0</status>
<value_type>4</value_type>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
Expand Down Expand Up @@ -1338,7 +1338,7 @@ last(&quot;docker.containers.running&quot;)</params>
<privatekey/>
<port/>
<filter>:</filter>
<lifetime>2</lifetime>
<lifetime>7</lifetime>
<description/>
<item_prototypes>
<item_prototype>
Expand Down Expand Up @@ -5531,6 +5531,24 @@ last(&quot;docker.containers.running&quot;)</params>
<description/>
<type>0</type>
</trigger_prototype>
<trigger_prototype>
<expression>{Template App Docker:docker.container.inspect.boolean[{#ZD_ID},State.OOMKilled].last(0)}=1</expression>
<name>Docker Container {#ZD_NAME} ({#ZD_ID}) Out of memory (killed)</name>
<url/>
<status>0</status>
<priority>3</priority>
<description/>
<type>0</type>
</trigger_prototype>
<trigger_prototype>
<expression>{Template App Docker:docker.container.inspect.boolean[{#ZD_ID},State.Paused].last(0)}=1</expression>
<name>Docker Container {#ZD_NAME} ({#ZD_ID}) Paused</name>
<url/>
<status>0</status>
<priority>2</priority>
<description/>
<type>0</type>
</trigger_prototype>
</trigger_prototypes>
<graph_prototypes>
<graph_prototype>
Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

CONFIG_PATH=/etc/zabbix/zabbix_agentd.d/

if [ "$#" -eq 1];
if [ "$#" -eq 1 ];
then CONFIG_PATH=$1
fi

Expand Down
2 changes: 2 additions & 0 deletions userparameter_zabbixdocker.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ UserParameter=docker.discovery, /usr/local/bin/zabbix-docker-discover.py

UserParameter=docker.info[*], docker info | grep "$1" | cut -f2 -d: | cut -c2-

UserParameter=docker.info.boolean[*], docker info | grep "$1" | cut -f2 -d: | cut -c2- | grep -i true | wc -l

UserParameter=docker.info.convert[*], docker info | grep "$1" | cut -f2 -d: | cut -c2- | /usr/local/bin/zabbix-docker-convert.py

UserParameter=docker.container.inspect[*], /usr/local/bin/zabbix-docker-inspect.py $1 $2
Expand Down
27 changes: 19 additions & 8 deletions zabbix-docker-inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,35 @@
#################################################################

import sys
import subprocess
import os
import time
import json

#################################################################
# sys.argv[1] - the instanceID of the docker container
# sys.argv[2] - the JSON value of the key to collect
#################################################################

import sys
import subprocess
import json

# sys.argv[1] - container ID
# sys.argv[2] - key value
def local_run_command(cmd,file):
cmd = cmd + " | tee > " + file
if os.path.isfile(file) == False:
os.system(cmd)
else:
(mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime) = os.stat(file)
ticks=int(time.time())
delta=ticks-mtime
if (delta > 60):
os.system(cmd)

strings = open(file,"r").read()
return strings

cmd="docker inspect " + sys.argv[1]
string = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout.read()
strings = local_run_command(cmd,"/tmp/zabbix-docker-inspect-"+sys.argv[1]+".out")

parsed_json = json.loads(string)
parsed_json = json.loads(strings)

key_path = sys.argv[2].split('.')

Expand All @@ -40,4 +52,3 @@
ptr=ptr[key_path[i]]

print ptr

19 changes: 18 additions & 1 deletion zabbix-docker-stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

import sys
import subprocess
import os
import time

def B(b):
return int(float(b))
Expand Down Expand Up @@ -84,11 +86,26 @@ def onet(data):
'onet':onet
}

def local_run_command(cmd,file):
cmd = cmd + " | tee > " + file
if os.path.isfile(file) == False:
os.system(cmd)
else:
(mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime) = os.stat(file)
ticks=int(time.time())
delta=ticks-mtime
if (delta > 60):
os.system(cmd)

strings = open(file,"r").readlines()
return strings


container=sys.argv[1]
key=sys.argv[2]

cmd="docker stats --no-stream=true " + container
strings = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE).stdout.readlines()
strings = local_run_command(cmd,"/tmp/zabbix-docker-stats-"+container+".out")

print options[key](strings[1])

0 comments on commit 619e12f

Please sign in to comment.