Skip to content

Commit

Permalink
Release 0.1.1
Browse files Browse the repository at this point in the history
- added -w / --warning for excluding fragile services like npcd from
throwing critical states
- added hint when running plugin as root
  • Loading branch information
stdevel committed Jun 27, 2016
1 parent 0c4b9c0 commit c33e408
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
26 changes: 21 additions & 5 deletions check_omd.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,38 @@ def getSiteStatus():
print "UNKNOWN: unable to check site: '{0}'".format(err.rstrip())
exit(3)
if res:
#try to find out whether omd was executed as root
if res.count("OVERALL") > 1:
print "UNKOWN: unable to check site, it seems this plugin is executed as root (use OMD site context!)"
exit(3)

#check all services
fail_srvs=[]
warn_srvs=[]
if options.debug: print "DEBUG: Got result '{0}'".format(res)
for line in io.StringIO(res.decode('utf-8')):
service = line.rstrip().split(" ")[0]
status = line.rstrip().split(" ")[1]
if service not in options.exclude:
#check service
if status != "0":
fail_srvs.append(service)
if options.debug: print "{0} service has failed state ({1})".format(service, status)
if service in options.warning:
if options.debug: print "{0} service marked for warning has failed state ({1})".format(service, status)
warn_srvs.append(service)
else:
fail_srvs.append(service)
if options.debug: print "{0} service has failed state ({1})".format(service, status)
else:
if options.debug: print "Ignoring '{0}' as it's blacklisted...".format(service)
if len(fail_srvs) == 0:
if len(fail_srvs) == 0 and len(warn_srvs) == 0:
print "OK: OMD site '{0}' services are running.".format(site)
exit(0)
else:
elif len(fail_srvs) > 0:
print "CRITICAL: OMD site '{0}' has failed service(s): '{1}'".format(site, ' '.join(fail_srvs))
exit(2)
else:
print "WARNING: OMD site '{0}' has service(s) in warning state: '{1}'".format(site, ' '.join(warn_srvs))
exit(1)



Expand All @@ -60,14 +73,17 @@ def getSiteStatus():
desc='''%prog is used to check a particular OMD site status. By default, the script only checks a site's overall status. It is also possible to exclude particular services and only check the remaining services (e.g. rrdcached, npcd, icinga, apache, crontab).
Checkout the GitHub page for updates: https://github.com/stdevel/check_omd'''
parser = OptionParser(description=desc,version="%prog version 1.0.0")
parser = OptionParser(description=desc,version="%prog version 1.1.0")

#-d / --debug
parser.add_option("-d", "--debug", dest="debug", default=False, action="store_true", help="enable debugging outputs")

#-e / --exclude
parser.add_option("-x", "--exclude", dest="exclude", default=["OVERALL"], action="append", metavar="SERVICE", help="defines one or more services that should be excluded")

#-w / --warning
parser.add_option("-w", "--warning", dest="warning", default=[""], action="append", metavar="SERVICE", help="defines one or more services that only should throw a warning if not running (useful for fragile stuff like npcd)")

#parse arguments
(options, args) = parser.parse_args()

Expand Down
6 changes: 3 additions & 3 deletions icingaexchange.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ type: Plugin
license: gplv2
releases:
-
name: 1.0
description: "1.0 Release"
name: 1.1.0
description: "1.1.0 Release"
files:
-
name: check_netio.py
url: "file:///check_omd.py"
description: "Initial release"
checksum: 5ef30b3ea32bd114d925575a3b79131b
checksum: df76dfdeedb07b8c7df52ae621b57c19

0 comments on commit c33e408

Please sign in to comment.