|
This script is a Big Brother monitoring script for monitoring whether a process is running. Big Brother includes process monitoring functionality however this was a special case. We needed to monitor a particular reporting database between the hours of 4am-Midnight. From Midnight till 4am the database disks were being resynced with production. The following script was written to satisfy the requirement. |
#!/usr/local/bin/perl
#
#
# File arbr.pl
# Date 3/30/2004
# Author - Vic Engle
#
#
# This is a Big Brother external script for monitoring
# processes for the ARBR instance on erlang.
#
#
# Revision History:
# Date:
# Desc:
#
#
use Sys::Hostname;
$LocalHost=hostname();
#
#
# Configure this section for processes to be monitored on this server
#
@PROCS = qw(
ora_dbw0_ARBR
ora_reco_ARBR
ora_pmon_ARBR
ora_smon_ARBR
ora_ckpt_ARBR
ora_lgwr_ARBR
);
# Set BigBro vars
$BBHOME = '/opt/bb/bb';
$BB = "$BBHOME/bin/bb";
$BBDISP = 'jumpstart.mydomain.local';
$host = GetBBHostName();
#
#
$HOUR = (localtime)[2];
$TIME = localtime(time);
if ($HOUR < 4) {
$color = "blue";
$Message = "ARBR monitoring currently disabled. Monitoring hours are 4am till midnight.\n\n";
foreach $proc (@PROCS) {
$html = "&blue $proc";
$Message .= "$html\n";
}
system("$BB $BBDISP \"status $host.procs2 $color $TIME ARBR instance on erlang \n\n$Message\"");
exit;
}
@PS = `/usr/bin/ps -ef`;
$color = 'green';
$Message = "Monitoring the ARBR instance on $LocalHost (4am till midnight)\n\n";
foreach $proc (@PROCS) {
@procok = grep(/$proc/,@PS);
if (@procok) {
$html = "&green $proc";
$Message .= "$html\n";
} else {
$color = "red";
$html = "&red $proc";
$Message .= "$html\n";
}
}
system("$BB $BBDISP \"status $host.procs2 $color $TIME ARBR instance on erlang\n\n$Message\"");
#
#
#
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 910