root/lib/Core/Resmon.pm

Revision 7e8cc9113dc35c2c65c1100e1cdb8a767ba0959d, 1.2 kB (checked in by Mark Harrison <mark@omniti.com>, 5 years ago)

Resmon::Module becomes Core::

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

  • Property mode set to 100644
Line 
1 package Core::Resmon;
2
3 use strict;
4 use warnings;
5
6 use base 'Resmon::Module';
7
8 use Sys::Hostname;
9
10 sub new {
11     my ($class, $check_name, $config) = @_;
12     my $self = $class->SUPER::new($check_name, $config);
13
14     # Get the svn revision
15     my $svnversion = 'svnversion';
16     if (defined($self->{config}->{svnversion_path})) {
17         $svnversion = $self->{config}->{svnversion_path};
18     }
19     $self->{svn_revision} = `$svnversion`;
20     if ($self->{svn_revision} eq "") {
21         $self->svn_revision = "unknown";
22     }
23     chomp $self->{svn_revision};
24
25     bless($self, $class);
26     return $self;
27 }
28
29 sub handler {
30     my $self = shift;
31
32     # Get the global config object
33     my $config = $main::config;
34     my $configstatus = $config->{'configstatus'};
35     my $modstatus = $config->{'modstatus'};
36
37     # The hostname command croaks (dies) if it fails, hence the eval
38     my $hostname = eval { hostname } || "Unknown";
39
40     return {
41         "revision" => [$self->{svn_revision}, "s"],
42         "hostname" => [$hostname, "s"],
43         "configstatus" => [$configstatus ? "BAD" : "OK", "s"],
44         "modstatus" => [scalar @$modstatus ? "BAD" : "OK", "s"],
45         "failed_modules" => [join(", ", @$modstatus), "s"]
46     };
47 };
48
49 1;
Note: See TracBrowser for help on using the browser.