Commit | Line | Data |
afd7c030 |
1 | package System::Introspector::Probe::Nagios::CheckMkAgent; |
170951ca |
2 | use Moo; |
3 | |
7b3254fd |
4 | use System::Introspector::Util qw( |
5 | lines_from_command |
6 | transform_exceptions |
7 | ); |
8 | |
170951ca |
9 | sub gather { |
10 | my ($self) = @_; |
7b3254fd |
11 | return transform_exceptions { |
12 | my @lines = $self->_get_check_mk_agent_output; |
13 | chomp @lines; |
14 | my %plugin; |
15 | my $current; |
16 | for my $line (@lines) { |
17 | if ($line =~ m{^<<<(.+)>>>$}) { |
18 | $plugin{ $1 } = $current = []; |
19 | next; |
20 | } |
21 | next unless $current; |
22 | push @$current, $line; |
170951ca |
23 | } |
7b3254fd |
24 | return { nagios_check_mk_agent => \%plugin }; |
25 | }; |
170951ca |
26 | } |
27 | |
28 | sub _get_check_mk_agent_output { |
7b3254fd |
29 | return lines_from_command ['check_mk_agent']; |
170951ca |
30 | } |
31 | |
32 | 1; |
33 | |
34 | __END__ |
35 | |
36 | =head1 NAME |
37 | |
38 | System::Introspector::Nagios::CheckMkAgent - Gather check_mk_agent output |
39 | |
40 | =head1 DESCRIPTION |
41 | |
42 | Parses the output of C<check_mk_agent> to gather data available to Nagios. |
43 | |
44 | =head1 SEE ALSO |
45 | |
46 | =over |
47 | |
48 | =item L<System::Introspector> |
49 | |
50 | =back |
51 | |
52 | =cut |
53 | |
54 | |