2009-02-23 12:37:23 +01:00
|
|
|
#!/usr/bin/perl
|
|
|
|
#
|
|
|
|
# apache http status code monitoring
|
|
|
|
#
|
|
|
|
# luis peralta - luis@11870.com
|
|
|
|
# http://www.ziritione.org
|
|
|
|
#
|
2018-08-02 02:03:42 +02:00
|
|
|
# Installing: configure apache blackbox and set the logfile to /var/log/blackbox.log
|
2017-04-17 22:43:38 +02:00
|
|
|
# or change the BLACKBOXLOG setting below.
|
2009-02-23 12:37:23 +01:00
|
|
|
#
|
2018-08-02 02:03:42 +02:00
|
|
|
# Dependencies: apache mod_logio, apache blackbox
|
2009-02-23 12:37:23 +01:00
|
|
|
# http://www.devco.net/archives/2008/03/05/detailed_apache_stats.php
|
|
|
|
#
|
|
|
|
# Last version available at: http://www.ziritione.org/http_status
|
|
|
|
#
|
|
|
|
# Parameters:
|
|
|
|
#
|
|
|
|
# config
|
|
|
|
# autoconf
|
|
|
|
#
|
|
|
|
#%# family=auto
|
|
|
|
#%# capabilities=autoconf
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
2018-08-02 02:03:42 +02:00
|
|
|
my $BLACKBOXLOG = "/var/log/blackbox.log";
|
2009-02-23 12:37:23 +01:00
|
|
|
|
2018-08-02 02:03:42 +02:00
|
|
|
my %WANTED = ( "apache.status.200" => "_200",
|
|
|
|
"apache.status.301" => "_301",
|
|
|
|
"apache.status.302" => "_302",
|
|
|
|
"apache.status.404" => "_404",
|
|
|
|
"apache.status.5xx" => "_5xx",
|
2009-02-23 12:37:23 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
my $arg = shift();
|
|
|
|
|
|
|
|
if ($arg eq 'config') {
|
|
|
|
print_config();
|
|
|
|
exit();
|
|
|
|
} elsif ($arg eq 'autoconf') {
|
|
|
|
print "yes\n";
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
open(SERVICE, "<$BLACKBOXLOG")
|
|
|
|
or die("Could not open '$BLACKBOXLOG': $!");
|
|
|
|
|
|
|
|
while (<SERVICE>) {
|
|
|
|
my ($k, $v) = (m/(apache.status.*)=(\d+)/);
|
|
|
|
next unless ($k);
|
|
|
|
if (exists $WANTED{$k} ) {
|
|
|
|
print("$WANTED{$k}.value $v\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
close(SERVICE);
|
|
|
|
|
|
|
|
|
|
|
|
sub print_config {
|
|
|
|
|
|
|
|
my $num = 0;
|
|
|
|
|
|
|
|
print("graph_title HTTP requests status
|
|
|
|
graph_args --base 1000
|
|
|
|
graph_vlabel requests / second
|
2017-02-21 22:15:07 +01:00
|
|
|
graph_category webserver
|
2009-02-23 12:37:23 +01:00
|
|
|
graph_total total\n");
|
|
|
|
|
|
|
|
for my $key (sort { $WANTED{$a} cmp $WANTED{$b} } (keys %WANTED)) {
|
|
|
|
my $title = $WANTED{$key};
|
|
|
|
print("$title.label ${title}\n",
|
|
|
|
"$title.min 0\n",
|
|
|
|
"$title.type DERIVE\n",
|
|
|
|
"$title.max 500000\n",
|
|
|
|
#"$title.draw ", ($num) ? "STACK" : "AREA" , "\n",
|
|
|
|
"$title.draw ", ($num) ? "AREA" : "AREA" , "\n",
|
|
|
|
);
|
|
|
|
$num++;
|
|
|
|
}
|
2018-08-02 02:03:42 +02:00
|
|
|
|
2009-02-23 12:37:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|