Skip to content
Snippets Groups Projects
Commit c9675cb5 authored by Mark Harrison's avatar Mark Harrison
Browse files

Fixed a bug in the resmon module and added checking for bad config/failed

module loading.


git-svn-id: https://labs.omniti.com/resmon/trunk@105 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55
parent 2a21c784
No related branches found
No related tags found
No related merge requests found
......@@ -10,12 +10,18 @@ use Sys::Hostname;
# returning OK. In future it will check for a broken config and broken
# modules, reporting that it is running with old modules/an old config.
(my $resmon_dir = $0) =~ s/\/?[^\/]+$//;
my $resmon_dir = $0;
$resmon_dir =~ s/\/?[^\/]+$//;
sub handler {
my $arg = shift;
my $os = $arg->fresh_status();
# Get the global config object
my $config = $main::config;
my $configstatus = $config->{'configstatus'} || "";
my $modstatus = $config->{'modstatus'} || "";
## Current revision
# Find location of subversion binary
my $svn = 'svn';
......@@ -25,8 +31,8 @@ sub handler {
last;
}
}
my $output = cache_command("$svn info $resmon_path 2>&1", 600);
$revision = 0;
my $output = cache_command("$svn info $resmon_dir 2>&1", 600);
my $revision = 0;
for (split(/\n/, $output)) {
if (/^Revision:\s*(\d*)$/) { $revision = "r$1"; }
if (/^svn: (.*) is not a working copy$/) {
......@@ -38,11 +44,24 @@ sub handler {
# The hostname command croaks (dies) if it fails, hence the eval
my $hostname = eval { hostname } || "Unknown";
my $status = "OK";
my $statusmsg = "running";
if ($configstatus) {
$statusmsg = "BAD config file, running on old configuration";
$status = "BAD";
}
if ($modstatus) {
$statusmsg .= " with failed modules: $modstatus";
$status = "BAD";
}
# Set 'config' variables so it shows up in the xml output
$arg->{'revision'} = $revision;
$arg->{'hostname'} = $hostname;
$arg->{'configstatus'} = $configstatus || "OK";
$arg->{'modstatus'} = $modstatus || "OK";
return $arg->set_status("OK", "$hostname running ($revision)");
return $arg->set_status($status, "$hostname $statusmsg ($revision)");
}
1;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment