Changeset 7b9e8bc8986e3f6e1e20051d23be0f664abb46dd

Show
Ignore:
Timestamp:
05/22/08 18:34:28 (6 years ago)
Author:
Mark Harrison <mark@omniti.com>
git-committer:
Mark Harrison <mark@omniti.com> 1211481268 +0000
git-parent:

[40149ad2c37d1c645665233f767d278f159b9dd5]

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

Several fixes:

  • Broken modules on startup will not cause resmon to quit, but will be
    added to the failed modules list and have a status shown as BAD.
  • Broken modules on startup will no longer break the XML (because there is
    no config_as_hash to generate the configuration from)
  • Reloading modules that were initially broken (either from startup or
    from adding them to the config file and reloading) now works correctly.

git-svn-id: https://labs.omniti.com/resmon/trunk@108 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55

Files:

Legend:

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

    r9e52c9e r7b9e8bc  
    88  my $self = bless { 
    99    configfile => $filename, 
     10    modstatus => '' 
    1011  }, $class; 
    1112  open(CONF, "<$filename") || return undef; 
     
    3132        eval { $coderef = Resmon::Module::fetch_monitor($current); }; 
    3233        if (!$coderef) { 
    33                 # Try to execute the config_as_hash method. If it fails, then 
    34                 # the module didn't load properly (e.g. syntax error). 
    35                 eval { $object->config_as_hash; }; 
    36                 die "Problem loading module $current" if $@; 
     34            # Try to execute the config_as_hash method. If it fails, then 
     35            # the module didn't load properly (e.g. syntax error). 
     36            eval { $object->config_as_hash; }; 
     37            if ($@) { 
     38                # Module failed to load, print error and add to failed 
     39                # modules list. 
     40                print STDERR "Problem loading module $current\n"; 
     41                print STDERR "This module will not be available\n"; 
     42                $self->{'modstatus'} .= "$current "; 
     43            } 
    3744        } 
    3845 
  • resmon

    ra55933e r7b9e8bc  
    4343    while ( my ($key, $value) = each(%$modules) ) { 
    4444        my $mod = $value->[0]; # Only need the first of each module 
    45         my $errs = $mod->reload_module(); 
     45        # Called this way rather than $mod->reload_module() in order to deal 
     46        # with modules that failed to load on startup and won't have a 
     47        # reload_module method. 
     48        my $errs = Resmon::Module::reload_module($mod); 
    4649        if ($errs) { 
    4750            my $modname = ref($mod) || $mod; 
     
    113116      } 
    114117      my $checkstat = $@; 
     118      my $confighash = {}; 
     119      eval { $confighash = $monobj->config_as_hash(); }; 
    115120      my $results = { 
    116         configuration => eval { $monobj->config_as_hash(); }
     121        configuration => $confighash
    117122        last_runtime_seconds => sprintf("%.6f", tv_interval($starttime)), 
    118123      };