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