#!/usr/bin/perl
use vars;
$file = "/home/gds/vcs_scripts/vcsstatus.cfg";
if (!open (FILE, $file)) {
print "ERROR: Status file not found : $file\r\n";
exit(0);
}
#$new_file = "./vcsstatus.php";
#if (-e $new_file) {
# unlink($new_file);
#}
$val_name = '';
$val_status = '';
$val_zone_num = '';
$ex_status = '';
$ne_id = $ARGV[0];
while(<FILE>) {
my($line) = $_;
chomp($line); # Get rid of the trailling \n
$line =~ s/^\s*//; # Remove spaces at the start of the line
$line =~ s/\s*$//; # Remove spaces at the end of the line
if($line =~ m/^($ne_id)/){
($val_zone_num, $val_name, $val_status) = split (/:/, $line); # Split each line into name value pairs
if( $val_zone_num = $ne_id ){
if( $val_status eq "Active"){
print "OK\n";
$ex_status = 0;
last;
}
elsif( $val_status eq "Warning"){
print "Warning!\n";
$ex_status = 1;
last;
}
elsif( $val_status eq "Failed"){
print "Critical!\n";
$ex_status = 2;
last;
}
}
}
}
close FILE;
exit $ex_status; |