Verified Commit 5ee78040 authored by Florian Pritz's avatar Florian Pritz
Browse files

nginx-zabbix.pl: Add support for reduced log format


Signed-off-by: Florian Pritz's avatarFlorian Pritz <bluewind@xinu.at>
parent 9df95d11
......@@ -84,10 +84,16 @@ sub main {
#print "Got line: ".$line."\n";
$line = trim($line);
# main log format
if ($line =~ m/(?<remote_addr>\S+) (?<host>\S+) (?<remote_user>\S+) \[(?<time_local>.*?)\]\s+"(?<request>.*?)" (?<status>\S+) (?<body_bytes_sent>\S+) "(?<http_referer>.*?)" "(?<http_user_agent>.*?)" "(?<http_x_forwarded_for>\S+)"(?: (?<request_time>[\d\.]+|-))?/) {
update_stats_for_line($values_per_host, $stat_per_host, $value_template, \$modified_hostlist, \%+);
}
# reduced log format
if ($line =~ m/(?<host>\S+) \[(?<time_local>.*?)\]\s+"(?<request>.*?)" (?<status>\S+) (?<body_bytes_sent>\S+) "(?<http_referer>.*?)" "(?<http_user_agent>.*?)"/) {
update_stats_for_line($values_per_host, $stat_per_host, $value_template, \$modified_hostlist, \%+);
}
my $now = time;
if ($now >= $last_send_time + $interval) {
......@@ -135,9 +141,9 @@ sub update_stats_for_line {
my $stat = $stat_per_host->{$host};
my $values = $values_per_host->{$host};
$stat->add_data($val{request_time}) if $val{request_time} != 0;
$stat->add_data($val{request_time}) if defined($val{request_time}) and $val{request_time} != 0;
$values->{request_count}++;
$values->{cached_request_count}++ if $val{request_time} == 0;
$values->{cached_request_count}++ if defined($val{request_time}) and $val{request_time} == 0;
my $status_key = defined $values->{status}->{$val{status}} ? $val{status} : "other";
$values->{status}->{$status_key}++;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment