|
This script is an external plugin script for the Big Brother monitoring system. It works in conjunction with a root cron entry that runs "vxdisk list > $BBTMP/vxdisk.dat". The script parses that file checking for failed, failing or offline disks and reports the results to Big Brother. Page rules for red and yellow status reports are configured on the Big Brother server side. |
#!/usr/bin/perl
#
#
# File vxcheck .pl
# Date 3/30/2004
# Author - Vic Engle
#
#
# This is a Big Brother external script for monitoring
# vxvm for failed, failing or offline disks
#
#
# Revision History:
# Date:
# Desc:
#
#
use Sys::Hostname;
$LocalHost=hostname();
#
#
# Set BigBro vars
$BBHOME = '/opt/bb/bb';
$BB = "$BBHOME/bin/bb";
$BBDISP = 'jumpstart.mydomain.local';
$test = 'vxdisk';
$host = GetBBHostName();
$VXDISK = "$BBHOME/tmp/vxdisk.dat";
$TIME = localtime(time);
if (! -e "$BBHOME/tmp/vxdisk.dat") {
$Message = "No data file. Check the root crontab on $LocalHost.\n\n";
system("$BB $BBDISP \"status $host.$test blue $TIME vxvm disk stats on $LocalHost.\n\n$Message\"");
exit;
}
$color = 'green';
$Message = "Veritas VM Disk Stats\n\n";
open(VX,"<$VXDISK") or Fail("$!");
@VX = ;
close(VX);
foreach $line (@VX) {
if ($line =~/fail/i) {
$color = "red";
$Message .= "&red $line";
next;
}
if ($line =~/offline/i) {
$color = "yellow" if ($color eq 'green');
$Message .= "&yellow $line";
}
}
$Message .= "No problems found with vx disks.\n\n" if ($color eq 'green');
system("$BB $BBDISP \"status $host.$test $color $TIME Veritas VM Disk Stats on $LocalHost.\n\n$Message\"");
#
#
sub Fail {
$Message = "Failed opening $VXDISK - ($_[0]).\n\n";
system("$BB $BBDISP \"status $host.$test yellow $TIME Veritas VM Disk Stats on $LocalHost.\n\n$Message\"");
exit;
}
#
sub GetBBHostName {
open(BBHOSTS,"<$BBHOME/etc/bb-hosts") or die "Failed opening $BBHOME/etc/bb-hosts. ($!)";
@Hosts = ;
@Host = grep(/$LocalHost/,@Hosts);
@Host = split(/\s+/,$Host[0]);
$Host[1] =~ s/\./,/g;
return "$Host[1]";
}
You are visitor number 2003