#!/usr/bin/perl -w # See copyright, etc in below POD section. ###################################################################### require 5.006_001; use lib '../blib/lib'; # testing use Getopt::Long; use Pod::Usage; use strict; use vars qw ($Debug $VERSION); use lib "/usr/lib/nagios/plugins" ; use utils qw(%ERRORS &print_revision &support &usage); use IPC::Locker; $VERSION = '1.491'; #====================================================================== # main our $PROGNAME = "check_lockerd"; my %opt_req_params = ( host => "localhost", ); autoflush STDOUT 1; autoflush STDERR 1; Getopt::Long::Configure('bundling'); if (! GetOptions ( "h|help" => \&print_usage, "v|debug" => \&debug, "V|version" => \&version, "p|port=i" => sub {$opt_req_params{port} = $_[1];}, "H|host|hostname=s" => sub {$opt_req_params{host} = $_[1];}, )) { usage("Bad options passed, use --help for more information.\n"); } check_lockerd(%opt_req_params); #---------------------------------------------------------------------- sub print_usage { print_revision($PROGNAME, $VERSION); pod2usage(-verbose=>2, -exitval=>2, -output=>\*STDOUT, -noperldoc=>1); support(); exit $ERRORS{'OK'}; } sub version { print_revision($PROGNAME, $VERSION); exit $ERRORS{'OK'}; } sub debug { $Debug = 1; $IPC::Locker::Debug = 1; } ####################################################################### sub check_lockerd { my %params = (@_); # Config requestor my $locker = new IPC::Locker (%params); # Send a request to the server, get reply & trap errors my $res = $locker->ping_status(); if ($res && $res->{ok}) { print "LOCKERD OK - $res->{status}\n"; exit $ERRORS{OK}; } else { print "LOCKERD CRITICAL - $res->{status}\n"; exit $ERRORS{CRITICAL}; } } ####################################################################### __END__ =pod =head1 NAME check_lockerd - Under Nagios, check the lockerd daemon on the specified host. =head1 SYNOPSIS check_lockerd --host hostname -p port =head1 DESCRIPTION Check_lockerd is a nagios plugin for the IPC::Locker daemon. Add to Nagios's checkcommands.cfg: define command{ command_name check_lockerd command_line $USER1$/check_lockerd -H $HOSTADDRESS$ } A quicker, but less accurate check is possible using the default Nagios check_tcp plugin as follows: define command{ command_name check_lockerd command_line $USER1$/check_tcp -H $HOSTADDRESS$ -p 1751 } =head1 ARGUMENTS =over 4 =item --help Displays this message and program version and exits. =item --host Specifies host name to check for a process. =item --port Specifies the port number to contact the "lockerd" on. (default 1752) =back =head1 DISTRIBUTION The latest version is available from CPAN and from L. Copyright 2006-2012 by Wilson Snyder. This package is free software; you can redistribute it and/or modify it under the terms of either the GNU Lesser General Public License Version 3 or the Perl Artistic License Version 2.0. =head1 AUTHORS Wilson Snyder =head1 SEE ALSO L, L, L, L =cut ###################################################################### ### Local Variables: ### compile-command: "./check_lockerd " ### End: