root/lib/Core/Fmadm.pm

Revision 06369f3cd47e3c778df3415ac82a4778b991ec2f, 1.5 kB (checked in by Eric Wilhelm <ewilhelm@cpan.org>, 1 year ago)

s/svcs_path/fmadm_path/ - vestigial docu-pasta?

  • Property mode set to 100644
Line 
1 package Core::Fmadm;
2
3 use strict;
4 use warnings;
5
6 use base 'Resmon::Module';
7
8 use Resmon::ExtComm qw(run_command cache_command);
9
10 =pod
11
12 =head1 NAME
13
14 Core::Fmadm - Monitor hardware fault conditions in Solaris
15
16 =head1 SYNOPSIS
17
18  Core::Fmadm {
19      failures : noop
20  }
21
22  Core::Fmadm {
23      failures : fmadm_path => /usr/sbin/fmadm
24  }
25
26 =head1 DESCRIPTION
27
28 This module monitors hardware fault conditions using the Solaris fmadm utility.
29
30 =head1 CONFIGURATION
31
32 =over
33
34 =item check_name
35
36 The check name is used for descriptive purposes only.  It is not used for
37 anything functional.
38
39 =item fmadm_path
40
41 Provide an alternate path to the fmadm command (optional).
42
43 =back
44
45 =head1 METRICS
46
47 =over
48
49 =item count
50
51 A count of how many services are in a faulted or degraded state. This should
52 normally be zero.
53
54 =item resources
55
56 Concatenated list of the resources (FMRI) and their respective state.  Each
57 entry will be separated by commas.
58
59 =back
60
61 =cut
62
63 sub handler {
64     my $self = shift;
65     my $config = $self->{'config'};
66     my $fmadm_path = $config->{'fmadm_path'} || 'fmadm';
67     my $osname = $^O;
68     my %results;
69
70     die "Unsupported platform: $osname\n"  unless ($osname eq 'solaris');
71
72     my $output = run_command("$fmadm_path faulty -r");
73     foreach (split(/\n/, $output)) {
74         /(\S+)\s+(\w+)/;
75         $results{$1} = $2;
76     }
77
78     return {
79         "count" => [scalar(keys %results), "i"],
80         "resources" => [join(", ", map { "$_ $results{$_}" } keys %results), "s"]
81     };
82 };
83
84 1;
85
Note: See TracBrowser for help on using the browser.