use reusable I/O utils, more solid error handling for Nagios::CheckMkAgent probe
[scpubgit/System-Introspector.git] / lib / System / Introspector / Nagios / CheckMkAgent.pm
CommitLineData
170951ca 1package System::Introspector::Nagios::CheckMkAgent;
2use Moo;
3
7b3254fd 4use System::Introspector::Util qw(
5 lines_from_command
6 transform_exceptions
7);
8
170951ca 9sub 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
28sub _get_check_mk_agent_output {
7b3254fd 29 return lines_from_command ['check_mk_agent'];
170951ca 30}
31
321;
33
34__END__
35
36=head1 NAME
37
38System::Introspector::Nagios::CheckMkAgent - Gather check_mk_agent output
39
40=head1 DESCRIPTION
41
42Parses 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