Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
title3check_neighbor_status-PLUGIN.rtf
collapsetrue
#!/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;

...

Code Block
titlehost_definition_example.rtf
collapsetrue
define host{
host_name                       ZoneName
alias                           ZoneAlias
hostgroups                      zone_group
address                         x.x.x.x
check_command                   check_neighbor_status!X
check_interval                  5
retry_interval                  1
max_check_attempts              5
check_period                    24x7
process_perf_data               0
retain_nonstatus_information    0
contact_groups                  contact_group
notification_interval           30
notification_period             24x7
notification_options            d,u,r
}

...