From: Chris Sharp Date: Fri, 4 Aug 2017 17:52:53 +0000 (-0400) Subject: Adding Nagios check for OpenSRF diagnostics X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d6327bb2dd924929d795f6a3049dfaf40e059a6b;p=contrib%2Fpines.git Adding Nagios check for OpenSRF diagnostics --- diff --git a/nagios/check_osrf b/nagios/check_osrf new file mode 100755 index 0000000..395d107 --- /dev/null +++ b/nagios/check_osrf @@ -0,0 +1,48 @@ +#!/usr/bin/perl + +# Copyright (C) 2017 Georgia Public Library Service +# Chris Sharp +# +# 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"; +} else { + print "OK: All configured OpenSRF services running.\n"; +} +