From 372da1b053b3fc0919369514a4297b646488194e Mon Sep 17 00:00:00 2001 From: Chris Sharp <csharp@georgialibraries.org> Date: Tue, 31 Oct 2017 15:58:47 -0400 Subject: [PATCH] Add OpenSRF monitoring to nodes. --- GenaSYS.sh | 1 + templates/monitor/check_osrf | 49 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100755 templates/monitor/check_osrf diff --git a/GenaSYS.sh b/GenaSYS.sh index 2e726f9..7d8fede 100755 --- a/GenaSYS.sh +++ b/GenaSYS.sh @@ -2875,6 +2875,7 @@ echo 'cp "${WD}/monitoring/check_memcached.pl" "/usr/lib/nagios/plugins"' >>$TMP echo 'cp "${WD}/monitoring/check_postgres.pl" "/usr/lib/nagios/plugins"' >>$TMPSETUPMONITOR echo 'cp "${WD}/monitoring/check_cpu.sh" "/usr/lib/nagios/plugins"' >>$TMPSETUPMONITOR echo 'cp "${WD}/monitoring/check_freemem" "/usr/lib/nagios/plugins"' >>$TMPSETUPMONITOR +echo 'cp "${WD}/monitoring/check_osrf" "/usr/lib/nagios/plugins"' >>$TMPSETUPMONITOR echo 'cp "${WD}/monitoring/nrpe_local.cfg" "/etc/nagios"' >>$TMPSETUPMONITOR chmod 755 $TMPSETUPMONITOR diff --git a/templates/monitor/check_osrf b/templates/monitor/check_osrf new file mode 100755 index 0000000..24f7b8b --- /dev/null +++ b/templates/monitor/check_osrf @@ -0,0 +1,49 @@ +#!/usr/bin/perl + +# Copyright (C) 2017 Georgia Public Library Service +# Chris Sharp <csharp@georgialibraries.org> +# +# Nagios/Icinga check for OpenSRF Diagnostic +# +# Returns OK as long as all configured services are running. +# +# Installation: +# +# Copy to your Nagios plugins directory (typically /usr/lib/nagios/plugins) on +# the remote server. Create the command in npre_local.cfg with sudo. Example: +# +# command[check_osrf]=sudo /usr/lib/nagios/plugins/check_osrf +# +# Then allow the nagios user to run the command on opensrf's behalf by adding +# the following line using visudo: +# +# nagios ALL=(root) NOPASSWD: /usr/lib/nagios/plugins/check_osrf +# +# adjusting for the actual location of your Nagios plugins. + +use warnings; +use strict; +use Getopt::Long; + +my $osrf_bindir = "/openils/bin"; +my $osrf_user = "opensrf"; +my $localhost = ''; +my $command; +my @errors; +GetOptions( 'localhost' => \$localhost ); + +if ($localhost) { + $command = "\"$osrf_bindir/osrf_control --localhost --diagnostic | grep ERR\""; +} else { + $command = "\"$osrf_bindir/osrf_control --diagnostic | grep ERR\""; +} + +@errors = `su - $osrf_user -c $command`; + +if (@errors) { + print "CRITICAL: At least one configured OpenSRF service not running!:\n@errors\n"; + exit 2; +} else { + print "OK: All configured OpenSRF services running.\n"; +} + -- 2.11.0