Changeset d1c88304cad0718a35367b4e5068e687459d1665
- Timestamp:
- 03/22/07 03:58:32
(6 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1174535912 +0000
- git-parent:
[c203f3d61063c12a4ce36e097772325e4ca8f26f]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1174535912 +0000
- Message:
auto adapt external referenced modules into the Resmon::Module name space for execution
git-svn-id: https://labs.omniti.com/resmon/trunk@25 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r3596d9c |
rd1c8830 |
|
| 3 | 3 | use strict; |
|---|
| 4 | 4 | use Data::Dumper; |
|---|
| 5 | | |
|---|
| | 5 | use UNIVERSAL qw/isa/; |
|---|
| 6 | 6 | my %coderefs; |
|---|
| 7 | 7 | |
|---|
| … | … | |
| 12 | 12 | my $coderef = $coderefs{$type}; |
|---|
| 13 | 13 | return $coderef if ($coderef); |
|---|
| | 14 | |
|---|
| | 15 | # First if the monitor name is raw and looks right: |
|---|
| | 16 | # is a subclass of Resmon::Module and can 'handler' |
|---|
| | 17 | # then we will promote it into the Resmon::Module namespace |
|---|
| | 18 | # and use this one. |
|---|
| 14 | 19 | eval "use $type;"; |
|---|
| | 20 | if($type->isa(__PACKAGE__) && $type->can('handler')) { |
|---|
| | 21 | eval " |
|---|
| | 22 | package Resmon::Module::$type; |
|---|
| | 23 | use vars qw/\@ISA/; |
|---|
| | 24 | \@ISA = qw($type); |
|---|
| | 25 | 1; |
|---|
| | 26 | "; |
|---|
| | 27 | if($@) { |
|---|
| | 28 | die "Could not repackage $type as Resmon::Module::$type\n"; |
|---|
| | 29 | } |
|---|
| | 30 | return undef; |
|---|
| | 31 | } |
|---|
| 15 | 32 | eval "use Resmon::Module::$type;"; |
|---|
| 16 | 33 | return undef; |
|---|
| … | … | |
| 38 | 55 | $arg->{lastmessage} = shift; |
|---|
| 39 | 56 | $arg->{lastupdate} = time; |
|---|
| 40 | | if($arg->{laststatus} =~ /^([A-Z]+)\(([^\)]+)\)$/s) { |
|---|
| | 57 | if($arg->{laststatus} =~ /^([A-Z]+)\((.*)\)$/s) { |
|---|
| 41 | 58 | # This handles old-style modules that return just set status as |
|---|
| 42 | 59 | # STATE(message) |
|---|