root/lib/Resmon/Module.pm

Revision 5be248d1d84b3bbf014c1d95f45670d642777584, 0.8 kB (checked in by Mark Harrison <mark@omniti.com>, 4 years ago)

Give a hint when someone mistakenly calls a wildcard module wrong (refs #12)

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

  • Property mode set to 100644
Line 
1 package Resmon::Module;
2 use strict;
3 use warnings;
4
5 sub new {
6     my ($class, $check_name, $config) = @_;
7     my $self = {};
8     $self->{config} = $config;
9     $self->{check_name} = $check_name;
10     bless ($self, $class);
11     return $self;
12 }
13
14 sub handler {
15     die "Monitor not implemented. Perhaps this is a wilcard only module?\n";
16 }
17
18 sub wildcard_handler {
19     die "Monitor not implemented. Perhaps this is a non-wildcard module?\n";
20 }
21
22 sub cache_metrics {
23     # Simple method to cache the results of a check
24     my $self = shift;
25     $self->{lastmetrics} = shift;
26     $self->{lastupdate} = time;
27 }
28
29 sub get_cached_metrics {
30     my $self = shift;
31     return undef unless $self->{check_interval};
32     my $now = time;
33     if(($self->{lastupdate} + $self->{check_interval}) >= $now) {
34         return $self->{lastmetrics};
35     }
36     return undef;
37 }
38
39 1;
Note: See TracBrowser for help on using the browser.