mirror of
https://github.com/opinkerfi/nagios-plugins.git
synced 2024-12-22 09:03:54 +01:00
Merge branch 'master' of https://opensource.ok.is/git/misc
This commit is contained in:
commit
441f82c5e7
38
check_nagios/check_nagios_configuration
Executable file
38
check_nagios/check_nagios_configuration
Executable file
@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
PERFDATA=""
|
||||
MESSAGE="Nagios configuration is valid"
|
||||
EXIT_CODE=3
|
||||
|
||||
TMPFILE=`mktemp`
|
||||
nagios -v /etc/nagios/nagios.cfg > $TMPFILE
|
||||
RESULT=$?
|
||||
|
||||
# grep -E '^\s+Checked'
|
||||
warnings=`grep -c -E "^Warning:" "$TMPFILE"`
|
||||
errors=`grep -c -E "^Error:" "$TMPFILE"`
|
||||
PERFDATA="warnings=$warnings errors=$errors"
|
||||
|
||||
|
||||
# If there are any warnings
|
||||
if [ $warnings -gt 0 ]; then
|
||||
MESSAGE="nagios.cfg has $warnings warnings"
|
||||
EXIT_CODE=1
|
||||
fi
|
||||
|
||||
|
||||
# If nagios -v fails. Config is invalid
|
||||
if [ $RESULT -gt 0 ]; then
|
||||
MESSAGE="Could not validate Nagios configuration."
|
||||
EXIT_CODE=2
|
||||
fi
|
||||
|
||||
if [ $EXIT_CODE -eq "3" ]; then
|
||||
EXIT_CODE=0
|
||||
fi
|
||||
|
||||
echo "$MESSAGE | $PERFDATA"
|
||||
grep -E "^Error|^Warning" "$TMPFILE"
|
||||
rm -f TMPFILE
|
||||
exit $EXIT_CODE
|
6
misc/check_nagios_ghostservices → check_nagios/check_nagios_ghostservices
Normal file → Executable file
6
misc/check_nagios_ghostservices → check_nagios/check_nagios_ghostservices
Normal file → Executable file
@ -13,16 +13,16 @@ sort | uniq > $TMP
|
||||
|
||||
|
||||
LINES=`cat $TMP | wc -l`
|
||||
PERFDATA="'ghost_clients'=$LINES"
|
||||
PERFDATA="'ghost_services'=$LINES"
|
||||
if [ $LINES -gt 0 ]; then
|
||||
echo "$LINES ghost clients found in Nagios log files | $PERFDATA"
|
||||
echo "$LINES ghost services found in Nagios log files | $PERFDATA"
|
||||
echo ""
|
||||
cat $TMP
|
||||
rm -f $TMP
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "No ghost clients found in Nagios log files | $PERFDATA"
|
||||
echo "No ghost services found in Nagios log files | $PERFDATA"
|
||||
rm -f $TMP
|
||||
exit 0
|
||||
|
20
check_nagios/check_nagios_needs_reload
Executable file
20
check_nagios/check_nagios_needs_reload
Executable file
@ -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)
|
10
check_nagios/check_nagios_plugin_existance
Executable file
10
check_nagios/check_nagios_plugin_existance
Executable file
@ -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
|
||||
|
4
check_nagios/nrpe.d/check_nagios.cfg
Normal file
4
check_nagios/nrpe.d/check_nagios.cfg
Normal file
@ -0,0 +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
|
6
check_proc/check_procs.sh
Executable file
6
check_proc/check_procs.sh
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
LINE=`/usr/lib64/nagios/plugins/check_procs $*`
|
||||
RC=$?
|
||||
COUNT=`echo $LINE | awk '{print $3}'`
|
||||
echo $LINE \| procs=$COUNT
|
||||
exit $RC
|
@ -6,7 +6,11 @@
|
||||
|
||||
__author__ = "Hari Sekhon"
|
||||
__title__ = "Nagios Plugin for Yum updates on RedHat/CentOS systems"
|
||||
__version__ = "0.7.1"
|
||||
__version__ = "0.7.2"
|
||||
|
||||
# Changes:
|
||||
# 0.7.2 added support for rhel6-style yum output
|
||||
|
||||
|
||||
# Standard Nagios return codes
|
||||
OK = 0
|
||||
@ -29,19 +33,19 @@ from optparse import OptionParser
|
||||
DEFAULT_TIMEOUT = 30
|
||||
|
||||
|
||||
def end(status, message):
|
||||
def end(status, message, perfdata=''):
|
||||
"""Exits the plugin with first arg as the return code and the second
|
||||
arg as the message to output"""
|
||||
|
||||
check = "YUM "
|
||||
if status == OK:
|
||||
print "%sOK: %s" % (check, message)
|
||||
print "%sOK: %s | %s" % (check, message, perfdata)
|
||||
sys.exit(OK)
|
||||
elif status == WARNING:
|
||||
print "%sWARNING: %s" % (check, message)
|
||||
print "%sWARNING: %s | %s" % (check, message, perfdata)
|
||||
sys.exit(WARNING)
|
||||
elif status == CRITICAL:
|
||||
print "%sCRITICAL: %s" % (check, message)
|
||||
print "%sCRITICAL: %s | %s" % (check, message, perfdata)
|
||||
sys.exit(CRITICAL)
|
||||
else:
|
||||
print "UNKNOWN: %s" % message
|
||||
@ -316,23 +320,33 @@ class YumTester:
|
||||
cmd = "%s --security check-update" % YUM
|
||||
|
||||
output = self.run(cmd)
|
||||
|
||||
re_security_summary = \
|
||||
re.compile("Needed \d+ of \d+ packages, for security")
|
||||
re_no_security_updates_available = \
|
||||
re.compile("No packages needed, for security, \d+ available")
|
||||
|
||||
re_security_summary_rhel5 = re.compile("Needed \d+ of \d+ packages, for security")
|
||||
re_security_summary_rhel6 = re.compile("\d+ package\(s\) needed for security, out of \d+ available")
|
||||
re_no_security_updates_available_rhel5 = re.compile("No packages needed, for security, \d+ available")
|
||||
re_no_security_updates_available_rhel6 = re.compile("No packages needed for security; \d+ packages available")
|
||||
summary_line_found = False
|
||||
for line in output:
|
||||
if re_no_security_updates_available.match(line):
|
||||
if re_no_security_updates_available_rhel5.match(line):
|
||||
summary_line_found = True
|
||||
number_security_updates = 0
|
||||
number_total_updates = line.split()[5]
|
||||
break
|
||||
elif re_security_summary.match(line):
|
||||
if re_no_security_updates_available_rhel6.match(line):
|
||||
summary_line_found = True
|
||||
number_security_updates = 0
|
||||
number_total_updates = line.split()[5]
|
||||
break
|
||||
if re_security_summary_rhel5.match(line):
|
||||
summary_line_found = True
|
||||
number_security_updates = line.split()[1]
|
||||
number_total_updates = line.split()[3]
|
||||
break
|
||||
if re_security_summary_rhel6.match(line):
|
||||
summary_line_found = True
|
||||
number_security_updates = line.split()[0]
|
||||
number_total_updates = line.split()[7]
|
||||
break
|
||||
|
||||
if not summary_line_found:
|
||||
end(WARNING, "Cannot find summary line in yum output. Please " \
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
Summary: Nagios plugin to test for Yum updates on RedHat/CentOS Linux.
|
||||
Name: nagios-okplugin-check_yum
|
||||
Version: 0.7.1
|
||||
Release: 1%{?dist}
|
||||
Version: 0.7.2
|
||||
Release: 2%{?dist}
|
||||
License: GPLv2+
|
||||
Group: Applications/System
|
||||
URL: http://opensource.is/trac/wiki/check_yum
|
||||
|
Loading…
Reference in New Issue
Block a user