]> git.evergreen-ils.org Git - contrib/pines.git/blob - nagios/check_osrf
add local git tar script
[contrib/pines.git] / nagios / check_osrf
1 #!/usr/bin/perl
2
3 # Copyright (C) 2017 Georgia Public Library Service
4 # Chris Sharp <csharp@georgialibraries.org>
5 #
6 # Nagios/Icinga check for OpenSRF Diagnostic
7 #
8 # Returns OK as long as all configured services are running.
9 #
10 # Installation: 
11
12 # Copy to your Nagios plugins directory (typically /usr/lib/nagios/plugins) on
13 # the remote server.  Create the command in npre_local.cfg with sudo.  Example:
14 #       
15 #       command[check_osrf]=sudo /usr/lib/nagios/plugins/check_osrf
16 #
17 # Then allow the nagios user to run the command on opensrf's behalf by adding 
18 # the following line using visudo:
19 #
20 # nagios ALL=(root)  NOPASSWD: /usr/lib/nagios/plugins/check_osrf
21 #
22 # adjusting for the actual location of your Nagios plugins.
23
24 use warnings;
25 use strict;
26 use Getopt::Long;
27
28 my $osrf_bindir = "/openils/bin";
29 my $osrf_user = "opensrf";
30 my $localhost = '';
31 my $command;
32 my @errors;
33 GetOptions( 'localhost' => \$localhost );
34
35 if ($localhost) {
36         $command = "\"$osrf_bindir/osrf_control --localhost --diagnostic | grep ERR\"";
37 } else {
38         $command = "\"$osrf_bindir/osrf_control --diagnostic | grep ERR\"";
39 }
40
41 @errors = `su - $osrf_user -c $command`;
42
43 if (@errors) {
44         print "CRITICAL: At least one configured OpenSRF service not running!:\n@errors\n";
45         exit 2; 
46 } else {
47         print "OK: All configured OpenSRF services running.\n";
48 }
49