Skip to content

Commit

Permalink
Merge pull request #29 from rpsedlak/development-1.0.3
Browse files Browse the repository at this point in the history
Development 1.0.3
  • Loading branch information
rpsedlak committed Dec 23, 2015
2 parents 9ee11a4 + 0cf946e commit 25b1151
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
5 changes: 5 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 11 additions & 2 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-22T01:04:01Z</date>
<date>2015-12-22T22:18:09Z</date>
<groups>
<group>
<name>Templates</name>
Expand Down Expand Up @@ -5543,6 +5543,15 @@ 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.Running].last(0)}=0</expression>
<name>Docker Container {#ZD_NAME} ({#ZD_ID}) is not running</name>
<url/>
<status>0</status>
<priority>3</priority>
<description/>
<type>0</type>
</trigger_prototype>
<trigger_prototype>
<expression>{Template App Docker:docker.container.stats[{#ZD_ID},pmem].avg(300)}&gt;70</expression>
<name>Docker Container {#ZD_NAME} ({#ZD_ID}) memory exceeding 70% for over 5 minutes</name>
Expand Down Expand Up @@ -5571,7 +5580,7 @@ last(&quot;docker.containers.running&quot;)</params>
<type>0</type>
</trigger_prototype>
<trigger_prototype>
<expression>{Template App Docker:docker.container.inspect.boolean[{#ZD_ID},State.OOMKilled].last(0)}=1</expression>
<expression>{Template App Docker:docker.container.inspect.boolean[{#ZD_ID},State.OOMKilled].last(0)}=1 &amp; {Template App Docker:docker.container.inspect.boolean[{#ZD_ID},State.Running].last(0)}=0</expression>
<name>Docker Container {#ZD_NAME} ({#ZD_ID}) Out of memory (killed)</name>
<url/>
<status>0</status>
Expand Down
5 changes: 2 additions & 3 deletions userparameter_zabbixdocker.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
56 changes: 56 additions & 0 deletions zabbix-docker-info.py
Original file line number Diff line number Diff line change
@@ -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<maxNdx):
if term in strings[ndx]:
found=ndx
else:
ndx+=1
retval=errorString
if found>=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)

0 comments on commit 25b1151

Please sign in to comment.