Changeset 1533dda22b2e7854c9d23a7dc3df5b57e838e66f
- Timestamp:
- 05/14/08 18:53:52
(5 years ago)
- Author:
- Mark Harrison <mark@omniti.com>
- git-committer:
- Mark Harrison <mark@omniti.com> 1210791232 +0000
- git-parent:
[36631e9cdfacbfd046a989336974b1af1982f9e3]
- git-author:
- Mark Harrison <mark@omniti.com> 1210791232 +0000
- Message:
Resmon no longer dies on config file errors on reload. Also show a better
error message when starting with a faulty module.
git-svn-id: https://labs.omniti.com/resmon/trunk@88 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r37857c4 |
r1533dda |
|
| 26 | 26 | my $object = bless \%kvs, "Resmon::Module::$current"; |
|---|
| 27 | 27 | push(@{$self->{Module}->{$current}}, $object); |
|---|
| | 28 | |
|---|
| | 29 | # Test to make sure the module actually works |
|---|
| | 30 | my $coderef; |
|---|
| | 31 | eval { $coderef = Resmon::Module::fetch_monitor($current); }; |
|---|
| | 32 | 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 $@; |
|---|
| | 37 | } else { |
|---|
| | 38 | print STDERR "moo"; |
|---|
| | 39 | } |
|---|
| | 40 | |
|---|
| 28 | 41 | } elsif (/^\s*\}\s*$/) { |
|---|
| 29 | 42 | $current = undef; |
|---|
| r0eea370 |
r1533dda |
|
| 37 | 37 | } |
|---|
| 38 | 38 | |
|---|
| 39 | | $SIG{'HUP'} = \&configure; |
|---|
| | 39 | sub reconfigure { |
|---|
| | 40 | print STDERR "Reloading...\n"; |
|---|
| | 41 | eval { configure(); }; |
|---|
| | 42 | if ($@) { |
|---|
| | 43 | print STDERR " Failed to reload: "; |
|---|
| | 44 | print STDERR $@; |
|---|
| | 45 | print STDERR " Continuing with old configuration\n"; |
|---|
| | 46 | } |
|---|
| | 47 | } |
|---|
| | 48 | |
|---|
| | 49 | $SIG{'HUP'} = \&reconfigure; |
|---|
| 40 | 50 | configure(); |
|---|
| 41 | 51 | |
|---|
| … | … | |
| 82 | 92 | eval { ($check_rv, $check_mess) = $monobj->handler(); }; |
|---|
| 83 | 93 | } |
|---|
| | 94 | my $checkstat = $@; |
|---|
| 84 | 95 | my $results = { |
|---|
| 85 | 96 | configuration => eval { $monobj->config_as_hash(); }, |
|---|
| 86 | 97 | last_runtime_seconds => sprintf("%.6f", tv_interval($starttime)), |
|---|
| 87 | 98 | }; |
|---|
| 88 | | if($@) { |
|---|
| | 99 | if($checkstat) { |
|---|
| 89 | 100 | $results->{state} = 'BAD'; |
|---|
| 90 | | $results->{message} = $@; |
|---|
| | 101 | $results->{message} = $checkstat; |
|---|
| 91 | 102 | } else { |
|---|
| 92 | 103 | $results->{state} = $check_rv; |
|---|