releasesystem
view release on metacpan or search on metacpan
utils/sysmonitor/sysmonitord view on Meta::CPAN
#!/usr/local/bin/perl
# System Process Monitor Daemon
# by Kevin Greene
# copyright 1996-2000 by hewlett-packard company
# may be distributed under the terms of the artistic license
use subs qw(fork_this);
use Time::Local; # get timelocal function
use FileHandle; # get select methods
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;
use Mail::Send;
use Sys::Hostname;
use Time::Period; # get inPeriod function
$ALARM_VAR = 0; #an alarm will set this to 1 - this will initiate a reset
# (reinitialize the variables
fork_this() if (defined $ARGV[0] and $ARGV[0] eq '-f');
$SIG{'HUP'} = sub {&log ("Caught HUP Alarm Signal", "INFO"); $ALARM_VAR=1;}; #trigger reset
$SIG{'ALRM'} = sub {&log ("Caught Alarm Signal", "INFO"); $ALARM_VAR=1;}; #trigger reset
###############################################################
# Global Setup
$DEBUG = 0; # Normally set to 0. Use 1 for debugging
$DEBUG_EMAIL = (getlogin || (getpwuid ($<))[0]) . "\@nafohq.hp.com";
if ($DEBUG) # debug values
{
$STARTUP_SLEEP = 1; # 1 seconds
$SLEEP_TIME = 10; # 10 seconds
$CONFIG_FILE = "$ENV{HOME}/public_html/wmTools/scripts/syscheck/syscheck.rc";
$SYSCHECK_LOG = "$ENV{HOME}/public_html/wmTools/scripts/syscheck/log";
$PID_FILE = "$ENV{HOME}/public_html/wmTools/scripts/syscheck/pid";
}
else #standard values
{
$STARTUP_SLEEP = 60 * 10; # 10 minutes
$SLEEP_TIME = 60 * 3; # 3 minutes
$CONFIG_FILE = "/opt/ims/local/sysmonitor/syscheck.rc";
$SYSCHECK_LOG = "/opt/ims/local/sysmonitor/log";
$PID_FILE = "/opt/ims/local/sysmonitor/pid";
}
# Uncomment this only if running *inside* the firewall
# $HTTP_PROXY = 'http://web_proxy:8088';
$PS = '/bin/ps -ef ';
$HOSTNAME = hostname;
# $NO_PROXY = 'hp.com';
#Parameters for config file (1st on line is id, these below follow)
$SEMAPHORE_PARAMETER = 0;
$REGEX_PARAMETER = 1;
$URL_PARAMETER = 2;
$COMMAND_PARAMETER = 3;
$EMAIL_PARAMETER = 4;
$SUBJECT_PARAMETER = 5;
$THRESHOLD_PARAMETER = 6;
$ERROR_REGEX_PARAMETER = 7;
$OPERATING_HOURS_PARAMETER = 8;
$DEAD_PARAMETER = 9; # NOTE! - this must ALWAYS be the last one
# because it does not actually exist in the
# config file
###############################################################
&main;
exit;
###############################################################
sub main
{
my (%idlist);
&initialize (\%idlist);
&event_loop (\%idlist);
}
###############################################################
sub initialize
{
my ($listref) = @_;
my ($pid) = $$;
my ($killit) = 1 if $ARGV[0] eq '-kill'; #cheap command line
( run in 0.952 second using v1.01-cache-2.11-cpan-97f6503c9c8 )