#! /usr/bin/perl -w # check_vserver # Copyright 2008 Hans-Peter Oeri # # Checks if a named vserver (www.linux-vserver.org) is up # # 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 3 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, see . use strict; use English; use Getopt::Long; use vars qw($PROGNAME); use lib "/usr/lib/nagios/plugins"; use utils qw (%ERRORS &print_revision &support); sub print_help (); sub print_usage (); my ($param_h, $param_v); my ($result, $message, $vserver); $PROGNAME="check_vserver"; Getopt::Long::Configure('bundling'); GetOptions( "V" => \$param_v, "version" => \$param_v, "h" => \$param_h, "help" => \$param_h, ); if ($param_v) { print_revision($PROGNAME, '1.0'); exit $ERRORS{'OK'}; } if ($param_h) { print_help(); exit $ERRORS{'OK'}; } $vserver = shift; $result = 'OK'; system( "vserver $vserver running 2> /dev/null" ) and $result='CRITICAL'; print "VSERVER $result: vserver \'$vserver\' is " . ($result eq 'OK' ? '' : 'not ') . "up\n"; exit $ERRORS{$result}; sub print_usage () { print "Usage:\n"; print " $PROGNAME [-h | --help]\n"; print " $PROGNAME [-V | --version]\n"; } sub print_help () { print_revision($PROGNAME, '1.0'); print "Copyright 2008 Hans-Peter Oeri \n\n"; print_usage(); print "\n"; support(); }