use reusable I/O utils, more solid error handling for Puppet probe
[scpubgit/System-Introspector.git] / lib / System / Introspector / Nagios / CheckMkAgent.pm
CommitLineData
170951ca 1package System::Introspector::Nagios::CheckMkAgent;
2use Moo;
3
4sub 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
21sub _get_check_mk_agent_output {
22 return `check_mk_agent`;
23}
24
251;
26
27__END__
28
29=head1 NAME
30
31System::Introspector::Nagios::CheckMkAgent - Gather check_mk_agent output
32
33=head1 DESCRIPTION
34
35Parses 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