From a7f67ef7a4ba6566d7f8006afa3db36c2c94a246 Mon Sep 17 00:00:00 2001 From: Richard Sedlak Date: Tue, 22 Dec 2015 16:19:22 -0600 Subject: [PATCH 1/2] Wrote new zabbix-docker-info.py command to parse data properly. --- ZabbixDockerTemplate.xml | 13 ++++++-- userparameter_zabbixdocker.conf | 5 ++- zabbix-docker-info.py | 56 +++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 5 deletions(-) create mode 100755 zabbix-docker-info.py diff --git a/ZabbixDockerTemplate.xml b/ZabbixDockerTemplate.xml index 6ca45de..4dfe068 100644 --- a/ZabbixDockerTemplate.xml +++ b/ZabbixDockerTemplate.xml @@ -1,7 +1,7 @@ 2.0 - 2015-12-22T01:04:01Z + 2015-12-22T22:18:09Z Templates @@ -5543,6 +5543,15 @@ last("docker.containers.running") 0 + + {Template App Docker:docker.container.inspect.boolean[{#ZD_ID},State.Running].last(0)}=0 + Docker Container {#ZD_NAME} ({#ZD_ID}) is not running + + 0 + 3 + + 0 + {Template App Docker:docker.container.stats[{#ZD_ID},pmem].avg(300)}>70 Docker Container {#ZD_NAME} ({#ZD_ID}) memory exceeding 70% for over 5 minutes @@ -5571,7 +5580,7 @@ last("docker.containers.running") 0 - {Template App Docker:docker.container.inspect.boolean[{#ZD_ID},State.OOMKilled].last(0)}=1 + {Template App Docker:docker.container.inspect.boolean[{#ZD_ID},State.OOMKilled].last(0)}=1 & {Template App Docker:docker.container.inspect.boolean[{#ZD_ID},State.Running].last(0)}=0 Docker Container {#ZD_NAME} ({#ZD_ID}) Out of memory (killed) 0 diff --git a/userparameter_zabbixdocker.conf b/userparameter_zabbixdocker.conf index 00a4020..a44e401 100644 --- a/userparameter_zabbixdocker.conf +++ b/userparameter_zabbixdocker.conf @@ -10,16 +10,15 @@ UserParameter=docker.version, docker -v UserParameter=docker.running.centos, ps -ef | grep 'docker -d' | grep -v grep | wc -l - UserParameter=docker.running.ubuntu, ps -ef | grep 'docker daemon' | grep -v grep | wc -l UserParameter=docker.containers.running, docker ps -q | wc -l 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[*], /usr/local/bin/zabbix-docker-info.py "$1" -UserParameter=docker.info.boolean[*], docker info | grep "$1" | cut -f2 -d: | cut -c2- | grep -i true | wc -l +UserParameter=docker.info.boolean[*], /usr/local/bin/zabbix-docker-info.py "$1" | 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 diff --git a/zabbix-docker-info.py b/zabbix-docker-info.py new file mode 100755 index 0000000..79e9467 --- /dev/null +++ b/zabbix-docker-info.py @@ -0,0 +1,56 @@ +#!/usr/bin/python + +import sys +import subprocess +import os +import time + +errorString="***NOT FOUND***" + +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 + +def findString(strings,term): + found=-1 + ndx=0 + maxNdx=len(strings) + while (found==-1) and (ndx=0: + retval=strings[found] + return retval + +def getValue(string): + pos=string.index(":") + return string[pos+2:-1] + + +search_for=sys.argv[1] + +cmd="docker info" +filename="/tmp/zabbix-docker-info.out" + +strings = local_run_command(cmd,filename) + +line=findString(strings,search_for) + +if errorString in line: + print search_for, " ", errorString +else: + print getValue(line) + From 0cf946e629747987190ca6825f1164143a779432 Mon Sep 17 00:00:00 2001 From: Richard Sedlak Date: Tue, 22 Dec 2015 16:21:58 -0600 Subject: [PATCH 2/2] Updated documentation --- README.md | 2 +- ReleaseNotes.md | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 613ce5c..c0a6ab0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# zabbix-docker 1.0.2 +# zabbix-docker 1.0.3 This repository contains monitoring code for Zabbix to discover and monitor Docker instances on Linux platforms. This module once installed provides monitoring capabilities through Zabbix 2.x for Docker version 1.7 and later. diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 37fb4ab..e7fea22 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,5 +1,10 @@ # Release notes +## Release 1.0.3 - 12/22/2015 +* #28 - Fixed 'Running instances showing OOMKilled set to true' +* #27 - Fixed 'ID from 'docker info' only returning a partial value' +* #15 - Fixed 'Requests for data appears to be overloading 'docker' command' + ## Release 1.0.2 - 12/21/2015 * #24 - Fixed container memory % report for Ubuntu * #23 - Fixed false "down" report for Ubuntu