[1342359584] HOST;gambit;UP;1342120231;1338841399;0;128690206;774112;63789;0;0;1;1;1;1;0;0.00;0;1;1;(Host assumed to be up)
####
hoststatus {
host_name=gambit
modified_attributes=0
check_command=check-host-alive
check_period=
notification_period=24x7
check_interval=5.000000
retry_interval=1.000000
event_handler=
has_been_checked=1
should_be_scheduled=1
check_execution_time=0.008
check_latency=0.102
check_type=0
current_state=0
last_hard_state=0
last_event_id=0
current_event_id=0
current_problem_id=0
last_problem_id=0
plugin_output=PING OK - Packet loss = 0%, RTA = 0.31 ms
long_plugin_output=
performance_data=rta=0.305000ms;3000.000000;5000.000000;0.000000 pl=0%;80;100;0
last_check=1342363276
next_check=1342363586
check_options=0
current_attempt=1
max_attempts=10
state_type=1
last_state_change=1342285983
last_hard_state_change=1342285983
last_time_up=1342363286
last_time_down=0
last_time_unreachable=0
last_notification=0
next_notification=0
no_more_notifications=0
current_notification_number=0
current_notification_id=0
notifications_enabled=1
...
####
sub process_log($) {
my $file = shift || NAGIOS_STATUS_LOG;
my $rv = { };
open FILE, $file or return $rv;
while (my $l = ) {
chomp $l; next if ($l =~ m/^#/);
if ($l =~ m/^\[([^\]]+)\]\s+(.+)$/) {
my $ts = $1;
my $statusline = $2;
my @fields = split /\;/, $statusline;
my $numfields = @fields;
if ($numfields == 21) {
my $host = $fields[1];
next unless (want($host));
$rv->{$host}->{' HOSTCHECK'} = {
'status' => $fields[2],
'last_check_time' => $fields[3],
'last_state_change' => $fields[4],
'acknowledged' => $fields[5],
'time_up' => $fields[6],
'time_down' => $fields[7],
'time_unreachable' => $fields[8],
'last_notification_time' => $fields[9],
'current_notification_number' => $fields[10],
'notifications_enabled' => $fields[11],
'event_handlers_enabled' => $fields[12],
'checks_enabled' => $fields[13],
'flap_detection_enabled' => $fields[14],
'host_is_flapping' => $fields[15],
'percent_state_change' => $fields[16],
'scheduled_dd' => $fields[17],
'failure_prediction_enabled' => $fields[18],
'process_perf_data' => $fields[19],
'plugin_output' => $fields[20],
}
}
elsif ($numfields == 32) {
my $host = $fields[1];
my $service = $fields[2];
next unless (want($host));
$rv->{$host}->{$service} = {
'status' => $fields[3],
'retry_number' => $fields[4],
'state_type' => $fields[5],
'last_check_time' => $fields[6],
'next_check_time' => $fields[7],
'check_type' => $fields[8],
'checks_enabled' => $fields[9],
'accept_passive_checks' => $fields[10],
'event_handlers_enabled' => $fields[11],
'last_state_change' => $fields[12],
'acknowledged' => $fields[13],
'last_hard_state' => $fields[14],
'time_ok' => $fields[15],
'time_unknown' => $fields[16],
'time_warning' => $fields[17],
'time_critical' => $fields[18],
'last_notification_time' => $fields[19],
'current_notification_number' => $fields[20],
'notifications_enabled' => $fields[21],
'latency' => $fields[22],
'execution_time' => $fields[23],
'flap_detection_enabled' => $fields[24],
'service_is_flapping' => $fields[25],
'percent_state_change' => $fields[26],
'scheduled_dd' => $fields[27],
'failure_prediction_enabled' => $fields[28],
'process_perf_data' => $fields[29],
'obsess_over' => $fields[30],
'plugin_output' => $fields[31],
}
}
}
}
close FILE;
return $rv;