$SIG{USR1} = \&ToggleVerbose;
-sub HandleSystemNotCheckingIn (%) {
+sub HandleSystemNotCheckingIn(%) {
my (%system) = @_;
my $startTime = time;
system => $system{name},
);
- my ($err, $msg, $lastid) = $clearadm->AddRunlog (%runlog);
+ my ($err, $msg, $lastid) = $clearadm->AddRunlog(%runlog);
$clearadm->Error ("Unable to add to runlog (Status: $err)\n$msg") if $err;
$systemLink .= "/systemdetails.cgi?system=$system{name}";
my $runlogLink = $Clearadm::CLEAROPTS{CLEARADM_WEBBASE};
$runlogLink .= "/runlog.cgi?id=$lastid";
- my $subject = "System is not responding (Is clearagent running?)";
- $message = <<"END";
+ my $subject = "System is not responding (Is clearagent running?)";
+ $message = <<"END";
<center>
<h1><font color="red">Alert</font> System not responding!</h1>
</center>
clearagent is not setup and running on the system.</p>
END
- $clearadm->Notify (
+ $clearadm->Notify(
$notification{name},
$subject,
$message,
return;
} # HandleSystemNotCheckingIn
-sub SystemsCheckin () {
+sub SystemsCheckin() {
for ($clearadm->FindSystem) {
my %system = %$_;
my $startTime = time;
- my $status = $clearexec->connectToServer (
- $system{name},
- $system{port}
- );
+ my $status = $clearexec->connectToServer($system{name}, $system{port});
unless ($status) {
HandleSystemNotCheckingIn %system;
. "$system{name}:$system{port}";
display __FILE__ . " DEBUG: System undefined 1" unless $system{name};
- $clearadm->UpdateSystem (
- $system{name},
- (lastheardfrom => Today2SQLDatetime)
- );
+ $clearadm->UpdateSystem($system{name}, (lastheardfrom => Today2SQLDatetime));
$clearadm->ClearNotifications ($system{name})
if $system{notification} and $system{notification} eq 'Heartbeat';
return;
} # SystemsCheckin
-sub UpdateRunlog ($$$$) {
+sub UpdateRunlog($$$$) {
my ($status, $startTime, $task, $output) = @_;
my %runlog = (
} # if
} # if
- my ($err, $msg, $lastid) = $clearadm->AddRunlog (%runlog);
+ my ($err, $msg, $lastid) = $clearadm->AddRunlog(%runlog);
- $clearadm->Error ($msg, $err) if $err;
+ $clearadm->Error($msg, $err) if $err;
return $lastid;
} # UpdateRunlog
-sub MakeSystemLink ($) {
+sub MakeSystemLink($) {
my ($system) = @_;
return "$Clearadm::CLEAROPTS{CLEARADM_WEBBASE}/systemdetails.cgi?system="
. $system;
} # MakeSystemLink
-sub MakeLoadavgLink ($) {
+sub MakeLoadavgLink($) {
my ($system) = @_;
return "$Clearadm::CLEAROPTS{CLEARADM_WEBBASE}/plot.cgi?type=loadavg&system="
. "$system&scaling=Hour&points=24";
} # MakeLoadavgLink
-sub ProcessLoadavgErrors ($$$$@) {
+sub ProcessLoadavgErrors($$$$@) {
# TODO: Also need to handle the case where the error was something other
# than "Load average over threshold". Perhaps by having different return
# status. Also, runlog entry #22169 never reported!
END
$message .= join "\n", @output;
$message .= "</pre>";
- $clearadm->Error ($message, -1);
+ $clearadm->Error($message, -1);
last;
} # if
- $clearadm->Notify (
+ $clearadm->Notify(
$notification,
$subject,
$message,
return;
} # ProcessLoadAvgErrors
-sub ProcessFilesystemErrors ($$$$@) {
+sub ProcessFilesystemErrors($$$$@) {
# TODO: Also need to handle the case where the error was something other
# than "Filesystem over threshold". Perhaps by having different return
# status.
push @fsinfo, @{$system{$systemName}};
} # if
- my $systemLink = MakeSystemLink ($systemName);
+ my $systemLink = MakeSystemLink($systemName);
my $subject = 'Filesystem has exceeded threshold';
my $message = <<"END";
<center>
$message .= "</ul>";
- $clearadm->Notify (
+ $clearadm->Notify(
$notification,
$subject,
$message,
return;
} # ProcessFilesystemErrors
-sub NonZeroReturn ($$$$$$) {
+sub NonZeroReturn($$$$$$) {
my ($system, $notification, $status, $lastid, $output, $task) = @_;
my @output = @{$output};
$message .= "</pre></blockquote>";
- $clearadm->Notify (
+ $clearadm->Notify(
$notification,
$subject,
$message,
return;
} # NonZeroReturn
-sub ExecuteTask ($%) {
+sub ExecuteTask($%) {
my ($sleep, %task) = @_;
my ($status, @output, %system, $subject, $message);
. "execute $task{command}";
$status = -1;
} else {
- ($status, @output) = $clearexec->execute ($task{command});
+ ($status, @output) = $clearexec->execute($task{command});
$output[0] = "Unable to exec $task{command} on $system{name}"
if $status == -1;
if ($status != 0) {
if ($notification{cond}
and $notification{cond} =~ /non zero return/i) {
- NonZeroReturn (
+ NonZeroReturn(
$system{name},
$notification{name},
$status,
\%task
);
} elsif ($notification{cond} =~ /loadavg over threshold/i) {
- ProcessLoadavgErrors ($notification{name}, $task{name}, $system{name}, $lastid, @output);
+ ProcessLoadavgErrors($notification{name}, $task{name}, $system{name}, $lastid, @output);
} elsif ($notification{cond} =~ /filesystem over threshold/i) {
- ProcessFilesystemErrors ($notification{name}, $task{name}, $system{name}, $lastid, @output);
+ ProcessFilesystemErrors($notification{name}, $task{name}, $system{name}, $lastid, @output);
} # if
} else {
- $clearadm->ClearNotifications ($task{system});
+ $clearadm->ClearNotifications($task{system});
} # if
- my ($err, $msg) = $clearadm->UpdateSchedule (
+ my ($err, $msg) = $clearadm->UpdateSchedule(
$task{schedulename},
( 'lastrunid' => $lastid ),
);
- $clearadm->Error ($msg, $err) if $err;
+ $clearadm->Error($msg, $err) if $err;
$sleep -= time - $startTime;
} # ExecuteTask
# Main
-GetOptions (
+GetOptions(
'usage' => sub { Usage },
'verbose' => sub { set_verbose },
'debug' => sub { set_debug },
'pidfile=s' => \$pidfile,
) or Usage "Invalid parameter";
-Usage 'Extraneous options: ' . join ' ', @ARGV
- if @ARGV;
+Usage 'Extraneous options: ' . join ' ', @ARGV if @ARGV;
-EnterDaemonMode $logfile, $logfile, $pidfile
- if $daemon;
+EnterDaemonMode $logfile, $logfile, $pidfile if $daemon;
display "$FindBin::Script V$VERSION started at " . localtime;