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;