#! /usr/bin/perl -w # # gulm_lockspace v1.0 plugin for Nagios # # returns values from /proc/gulm/lockspace for trending purposes # # Copyright (C) 2006 Garrett Honeycutt # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # History: # # v1.0 Garrett Honeycutt - gh@3gupload.com # + initial release # use strict; use FindBin; use lib $FindBin::Bin; use utils qw($TIMEOUT %ERRORS &print_revision &support); use vars qw($PROGNAME $PROGVER); use Getopt::Long; use vars qw($opt_V $opt_h $opt_p); $PROGNAME = "gulm_lockspace"; $PROGVER = "1.0"; sub print_help (); sub print_usage (); Getopt::Long::Configure('bundling'); GetOptions ("V" => \$opt_V, "version" => \$opt_V, "h" => \$opt_h, "help" => \$opt_h); if ($opt_V) { print_revision($PROGNAME,'$Revision: '.$PROGVER.' $'); exit $ERRORS{'UNKNOWN'}; } if ($opt_h) { print_help(); exit $ERRORS{'UNKNOWN'}; } my $file = '/proc/gulm/lockspace'; open(STUFF, $file) || die "Cannot open /proc/gulm/lockspace"; my @lines = ; close(STUFF); my @total = split(": ",$lines[2]); my @unl = split(": ",$lines[3]); my @exl = split(": ",$lines[4]); my @shd = split(": ",$lines[5]); my @dfr = split(": ",$lines[6]); my @pending = split(": ",$lines[7]); my @lvbs = split(": ",$lines[8]); my @lops = split(": ",$lines[9]); chomp $total[1]; chomp $unl[1]; chomp $exl[1]; chomp $shd[1]; chomp $dfr[1]; chomp $pending[1]; chomp $lvbs[1]; chomp $lops[1]; printf("OK: gulm_lockspace | 'total'=%s 'pending'=%s 'unl'=%s 'exl'=%s 'shd'=%s 'dfr'=%s 'lvbs'=%s 'lops'=%s\n",$total[1], $pending[1], $unl[1], $exl[1], $shd[1], $dfr[1], $lvbs[1], $lops[1]); exit $ERRORS{'OK'}; sub print_usage () { print "Usage: $PROGNAME [-h]\n"; exit $ERRORS{'UNKNOWN'} unless ($opt_h); } sub print_help () { print_revision($PROGNAME,'$Revision: '.$PROGVER.' $'); print "Copyright (c) 2006 Garrett Honeycutt\n"; print "\n"; print_usage(); print "\n"; print "-h = This screen.\n\n"; my_support(); } sub my_support () { print "Send email to nagios-plugins\@3gupload.com if you have questions regarding\nuse of this software, to submit patches, or suggest improvements.\n"; }