From c3b021f1dc74c2b2868149b55d6f8a92054ce295 Mon Sep 17 00:00:00 2001 From: Pall Sigurdsson Date: Fri, 2 Dec 2011 09:46:11 +0000 Subject: [PATCH] new check_nagios scripts added --- check_nagios/check_nagios_needs_reload | 20 ++++++++++++++++++++ check_nagios/check_nagios_plugin_existance | 10 ++++++++++ check_nagios/nrpe.d/check_nagios.cfg | 2 ++ 3 files changed, 32 insertions(+) create mode 100755 check_nagios/check_nagios_needs_reload create mode 100755 check_nagios/check_nagios_plugin_existance diff --git a/check_nagios/check_nagios_needs_reload b/check_nagios/check_nagios_needs_reload new file mode 100755 index 0000000..b239e59 --- /dev/null +++ b/check_nagios/check_nagios_needs_reload @@ -0,0 +1,20 @@ +#!/usr/bin/python +# Checks if nagios service needs a reload + +import sys +try: + from pynag.Parsers import config + + c = config(cfg_file='/etc/nagios/nagios.cfg') + c.parse() + result = c.needs_reparse() + + if result == True: + print "Warning - Nagios configuration has changed since last restart" + sys.exit(1) + else: + print "OK - Nagios service has been restarted since last config change" + sys.exit(0) +except Exception, e: + print "Unknown - Error running script: %s" % e + sys.exit(3) diff --git a/check_nagios/check_nagios_plugin_existance b/check_nagios/check_nagios_plugin_existance new file mode 100755 index 0000000..5281aa2 --- /dev/null +++ b/check_nagios/check_nagios_plugin_existance @@ -0,0 +1,10 @@ +#!/usr/bin/python + +import sys,os +sys.path.append('/opt/pynag') +from pynag import Model + +all_commands = Model.Command.objects.all +for c in all_commands: + print c.command_line + diff --git a/check_nagios/nrpe.d/check_nagios.cfg b/check_nagios/nrpe.d/check_nagios.cfg index 39ce1d1..cd1860f 100644 --- a/check_nagios/nrpe.d/check_nagios.cfg +++ b/check_nagios/nrpe.d/check_nagios.cfg @@ -1,2 +1,4 @@ command[check_nagios_configuration]=/usr/lib64/nagios/plugins/check_nagios_configuration command[check_nagios_ghostservices]=/usr/lib64/nagios/plugins/check_nagios_ghostservices +command[check_nagios_needs_reload]=/usr/lib64/nagios/plugins/check_nagios_needs_reload +command[check_nagios_plugin_existance]=/usr/lib64/nagios/plugins/check_nagios_plugin_existance