Changeset 7b9e8bc8986e3f6e1e20051d23be0f664abb46dd
- Timestamp:
- 05/22/08 18:34:28
(5 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
| r9e52c9e |
r7b9e8bc |
|
| 8 | 8 | my $self = bless { |
|---|
| 9 | 9 | configfile => $filename, |
|---|
| | 10 | modstatus => '' |
|---|
| 10 | 11 | }, $class; |
|---|
| 11 | 12 | open(CONF, "<$filename") || return undef; |
|---|
| … | … | |
| 31 | 32 | eval { $coderef = Resmon::Module::fetch_monitor($current); }; |
|---|
| 32 | 33 | 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 | } |
|---|
| 37 | 44 | } |
|---|
| 38 | 45 | |
|---|
| ra55933e |
r7b9e8bc |
|
| 43 | 43 | while ( my ($key, $value) = each(%$modules) ) { |
|---|
| 44 | 44 | 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); |
|---|
| 46 | 49 | if ($errs) { |
|---|
| 47 | 50 | my $modname = ref($mod) || $mod; |
|---|
| … | … | |
| 113 | 116 | } |
|---|
| 114 | 117 | my $checkstat = $@; |
|---|
| | 118 | my $confighash = {}; |
|---|
| | 119 | eval { $confighash = $monobj->config_as_hash(); }; |
|---|
| 115 | 120 | my $results = { |
|---|
| 116 | | configuration => eval { $monobj->config_as_hash(); }, |
|---|
| | 121 | configuration => $confighash, |
|---|
| 117 | 122 | last_runtime_seconds => sprintf("%.6f", tv_interval($starttime)), |
|---|
| 118 | 123 | }; |
|---|