Changeset c9675cb5dfd3dc82a465d4cdc92b6f861474561e

Show
Ignore:
Timestamp:
05/21/08 19:01:09 (6 years ago)
Author:
Mark Harrison <mark@omniti.com>
git-committer:
Mark Harrison <mark@omniti.com> 1211396469 +0000
git-parent:

[2a21c78424f1bd6f1013fab1dbff362de5921387]

git-author:
Mark Harrison <mark@omniti.com> 1211396469 +0000
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lib/Resmon/Module/RESMON.pm

    r2a21c78 rc9675cb  
    1111# modules, reporting that it is running with old modules/an old config. 
    1212 
    13 (my $resmon_dir = $0) =~ s/\/?[^\/]+$//; 
     13my $resmon_dir = $0; 
     14$resmon_dir =~ s/\/?[^\/]+$//; 
    1415 
    1516sub handler { 
    1617    my $arg = shift; 
    1718    my $os = $arg->fresh_status(); 
     19 
     20    # Get the global config object 
     21    my $config = $main::config; 
     22    my $configstatus = $config->{'configstatus'} || ""; 
     23    my $modstatus = $config->{'modstatus'} || ""; 
    1824 
    1925    ## Current revision 
     
    2632        } 
    2733    } 
    28     my $output = cache_command("$svn info $resmon_path 2>&1", 600); 
    29     $revision = 0; 
     34    my $output = cache_command("$svn info $resmon_dir 2>&1", 600); 
     35    my $revision = 0; 
    3036    for (split(/\n/, $output)) { 
    3137        if (/^Revision:\s*(\d*)$/) { $revision = "r$1"; } 
     
    3945    my $hostname = eval { hostname } || "Unknown"; 
    4046 
     47    my $status = "OK"; 
     48    my $statusmsg = "running"; 
     49    if ($configstatus) { 
     50        $statusmsg = "BAD config file, running on old configuration"; 
     51        $status = "BAD"; 
     52    } 
     53    if ($modstatus) { 
     54        $statusmsg .= " with failed modules: $modstatus"; 
     55        $status = "BAD"; 
     56    } 
     57 
    4158    # Set 'config' variables so it shows up in the xml output 
    4259    $arg->{'revision'} = $revision; 
    4360    $arg->{'hostname'} = $hostname; 
     61    $arg->{'configstatus'} = $configstatus || "OK"; 
     62    $arg->{'modstatus'} = $modstatus || "OK"; 
    4463 
    45     return $arg->set_status("OK", "$hostname running ($revision)"); 
     64    return $arg->set_status($status, "$hostname $statusmsg ($revision)"); 
    4665} 
    4766