root/lib/Core/SmfMaintenance.pm

Revision 4330fa95594e44c1fac17f8161cc14f8dd4e9d85, 1.5 kB (checked in by Graham Knop <gknop@omniti.com>, 2 years ago)

return empty results if svcs fails, allowing SMF failures to be noticed

  • Property mode set to 100644
Line 
1 package Core::SmfMaintenance;
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::SmfMaintenance - Monitor services in maintenance mode
15
16 =head1 SYNOPSIS
17
18  Core::SmfMaintenance {
19      services: noop
20  }
21
22  Core::SmfMaintenance {
23      services: svcs_path => /bin/svcs
24  }
25
26 =head1 DESCRIPTION
27
28 This module monitors Solaris SMF services and reports on any that are in
29 maintenance mode.
30
31 =head1 CONFIGURATION
32
33 =over
34
35 =item check_name
36
37 The check name is descriptive only in this check. It is not used for anything.
38
39 =item svcs_path
40
41 Provide an alternate path to the svcs 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 maintenance mode. This should normally be
52 zero.
53
54 =item services
55
56 A list of the services in maintenance mode. If no services are in maintenance
57 mode, then this will be blank. The service names will be separated by
58 whitespace.
59
60 =back
61
62 =cut
63
64 sub handler {
65     my $self = shift;
66     my $config = $self->{config}; # All configuration is in here
67
68     my $svcs_path = $config->{svcs_path} || 'svcs';
69
70     my $output = run_command("$svcs_path");
71     my @maintenance_services = map((split(/\s+/, $_))[2],
72         grep(/^maintenance/, split(/\n/, $output)));
73
74     # svcs/smf is broken
75     if ($? && ! @maintenance_services) {
76         return {};
77     }
78
79     return {
80         "count" => [scalar(@maintenance_services), "i"],
81         "services" => [join(" ", @maintenance_services), "s"]
82     };
83 };
84
85 1;
Note: See TracBrowser for help on using the browser.