【发布时间】:2013-01-11 15:32:14
【问题描述】:
我可以使用以下代码从Nagios-Report Perl Module 打印出 Host UP 时间百分比:
#!/usr/bin/perl
use strict ;
use Nagios::Report ;
my $x = Nagios::Report->new(q<local_cgi localhost nagiosadmin>)
or die "Can't construct Nagios::Report object." ;
$x->mkreport(
[ qw(HOST_NAME PERCENT_TOTAL_TIME_UP) ],
sub {
my %F = @_; my $u = $F{PERCENT_TOTAL_TIME_UP}; $u =~ s/%//;
},
0,
sub {
my $F = shift @_ ;
}
) ;
$x->debug_dump ;
但我怎样才能只打印出服务 UP 时间百分比?我的意思是只输出百分比值。
我尝试了很多选项,但都无法做到。
【问题讨论】:
-
我建议您阅读您链接到的页面并搜索
service。例如,以下文本提示使用:HOST_OR_SERVICE is an optional scalar specifying the service report instead of the host report. If not set, the host report is produced. -
谢谢,我不懂如何制作服务报告。我应该设置什么?
-
@Zim3r 也许我的 $x = Nagios::Report->new(q
) -
感谢克雷格,这没有用,但帮助我找到了解决方案。我仍然不知道如何只检索正常运行时间值而不是完整报告。
标签: perl monitoring perl-module nagios