Changeset 627a96772d62dfc3c4d65c35f81a7f266d5a4719
- Timestamp:
- 03/22/07 21:28:16
(6 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1174598896 +0000
- git-parent:
[736d17033260fb886cb4627c6f05277ee834c5bc]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1174598896 +0000
- Message:
make this more extensible and make Resmon auto 'use lib' based off \-tcsh
git-svn-id: https://labs.omniti.com/resmon/trunk@29 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r736d170 |
r627a967 |
|
| 223 | 223 | } |
|---|
| 224 | 224 | sub store { |
|---|
| 225 | | my ($self, $type, $name, $state, $mess) = @_; |
|---|
| 226 | | $self->{store}->{$type}->{$name} = { |
|---|
| 227 | | last_update => time, |
|---|
| 228 | | state => $state, |
|---|
| 229 | | message => $mess |
|---|
| 230 | | }; |
|---|
| | 225 | my ($self, $type, $name, $info) = @_; |
|---|
| | 226 | %{$self->{store}->{$type}->{$name}} = %$info; |
|---|
| | 227 | $self->{store}->{$type}->{$name}->{last_update} = time; |
|---|
| 231 | 228 | $self->store_shared_state(); |
|---|
| 232 | 229 | if($self->{handle}) { |
|---|
| 233 | | $self->{handle}->print("$name($type) :: $state($mess)\n"); |
|---|
| | 230 | $self->{handle}->print("$name($type) :: $info->{state}($info->{message})\n"); |
|---|
| 234 | 231 | } else { |
|---|
| 235 | | print "$name($type) :: $state($mess)\n"; |
|---|
| | 232 | print "$name($type) :: $info->{state}($info->{message})\n"; |
|---|
| 236 | 233 | } |
|---|
| 237 | 234 | } |
|---|
| re5d09e8 |
r627a967 |
|
| 1 | 1 | #!/usr/bin/perl |
|---|
| 2 | 2 | |
|---|
| 3 | | use lib '/opt/resmon/lib'; |
|---|
| | 3 | BEGIN { |
|---|
| | 4 | (my $dir = $0) =~ s/\/?[^\/]+$//; |
|---|
| | 5 | print "use lib '$dir/lib';\n"; |
|---|
| | 6 | eval "use lib '$dir/lib';"; |
|---|
| | 7 | die $@ if($@); |
|---|
| | 8 | }; |
|---|
| 4 | 9 | |
|---|
| 5 | 10 | use strict; |
|---|
| … | … | |
| 23 | 28 | ); |
|---|
| 24 | 29 | |
|---|
| 25 | | $config_file ||= 'resmon.conf'; |
|---|
| | 30 | $config_file ||= "$0.conf"; |
|---|
| 26 | 31 | die "Cannot open configuration file: $config_file" unless (-r $config_file); |
|---|
| 27 | 32 | |
|---|
| … | … | |
| 68 | 73 | my $check_rv = 'BAD', |
|---|
| 69 | 74 | my $check_mess = 'no data'; |
|---|
| | 75 | my $starttime = [gettimeofday]; |
|---|
| 70 | 76 | if($coderef) { |
|---|
| 71 | 77 | eval { ($check_rv, $check_mess) = $coderef->($monobj); }; |
|---|
| … | … | |
| 73 | 79 | eval { ($check_rv, $check_mess) = $monobj->handler(); }; |
|---|
| 74 | 80 | } |
|---|
| | 81 | my $results = { last_runtime_seconds => tv_interval($starttime) }; |
|---|
| 75 | 82 | if($@) { |
|---|
| 76 | | $status->store($module_name,$monobj->{'object'},'BAD',$@); |
|---|
| | 83 | $results->{state} = 'BAD'; |
|---|
| | 84 | $results->{message} = $@; |
|---|
| 77 | 85 | } else { |
|---|
| 78 | | $status->store($module_name,$monobj->{'object'},$check_rv,$check_mess); |
|---|
| | 86 | $results->{state} = $check_rv; |
|---|
| | 87 | $results->{message} = $check_mess; |
|---|
| 79 | 88 | } |
|---|
| | 89 | $status->store($module_name,$monobj->{'object'}, $results); |
|---|
| 80 | 90 | } |
|---|
| 81 | 91 | } |
|---|