root / plugins / apache / apache_blackbox @ 8589c6df
Historique | Voir | Annoter | Télécharger (1,77 ko)
| 1 | 2e187521 | Luis Peralta | #!/usr/bin/perl |
|---|---|---|---|
| 2 | # |
||
| 3 | # apache http status code monitoring |
||
| 4 | # |
||
| 5 | # luis peralta - luis@11870.com |
||
| 6 | # http://www.ziritione.org |
||
| 7 | # |
||
| 8 | # Installing: configure apache blackbox and set the logfile to /var/log/blackbox.log |
||
| 9 | 8589c6df | klemens | # or change the BLACKBOXLOG setting below. |
| 10 | 2e187521 | Luis Peralta | # |
| 11 | # Dependencies: apache mod_logio, apache blackbox |
||
| 12 | # http://www.devco.net/archives/2008/03/05/detailed_apache_stats.php |
||
| 13 | # |
||
| 14 | # Last version available at: http://www.ziritione.org/http_status |
||
| 15 | # |
||
| 16 | # Parameters: |
||
| 17 | # |
||
| 18 | # config |
||
| 19 | # autoconf |
||
| 20 | # |
||
| 21 | #%# family=auto |
||
| 22 | #%# capabilities=autoconf |
||
| 23 | |||
| 24 | use strict; |
||
| 25 | |||
| 26 | my $BLACKBOXLOG = "/var/log/blackbox.log"; |
||
| 27 | |||
| 28 | 656b6c6a | Russell Neufeld | my %WANTED = ( "apache.status.200" => "_200", |
| 29 | "apache.status.301" => "_301", |
||
| 30 | "apache.status.302" => "_302", |
||
| 31 | "apache.status.404" => "_404", |
||
| 32 | "apache.status.5xx" => "_5xx", |
||
| 33 | 2e187521 | Luis Peralta | ); |
| 34 | |||
| 35 | my $arg = shift(); |
||
| 36 | |||
| 37 | if ($arg eq 'config') {
|
||
| 38 | print_config(); |
||
| 39 | exit(); |
||
| 40 | } elsif ($arg eq 'autoconf') {
|
||
| 41 | print "yes\n"; |
||
| 42 | exit(); |
||
| 43 | } |
||
| 44 | |||
| 45 | |||
| 46 | open(SERVICE, "<$BLACKBOXLOG") |
||
| 47 | or die("Could not open '$BLACKBOXLOG': $!");
|
||
| 48 | |||
| 49 | while (<SERVICE>) {
|
||
| 50 | my ($k, $v) = (m/(apache.status.*)=(\d+)/); |
||
| 51 | next unless ($k); |
||
| 52 | if (exists $WANTED{$k} ) {
|
||
| 53 | print("$WANTED{$k}.value $v\n");
|
||
| 54 | } |
||
| 55 | } |
||
| 56 | |||
| 57 | close(SERVICE); |
||
| 58 | |||
| 59 | |||
| 60 | sub print_config {
|
||
| 61 | |||
| 62 | my $num = 0; |
||
| 63 | |||
| 64 | print("graph_title HTTP requests status
|
||
| 65 | graph_args --base 1000 |
||
| 66 | graph_vlabel requests / second |
||
| 67 | 65652aa0 | dipohl | graph_category webserver |
| 68 | 2e187521 | Luis Peralta | graph_total total\n"); |
| 69 | |||
| 70 | for my $key (sort { $WANTED{$a} cmp $WANTED{$b} } (keys %WANTED)) {
|
||
| 71 | my $title = $WANTED{$key};
|
||
| 72 | print("$title.label ${title}\n",
|
||
| 73 | "$title.min 0\n", |
||
| 74 | "$title.type DERIVE\n", |
||
| 75 | "$title.max 500000\n", |
||
| 76 | #"$title.draw ", ($num) ? "STACK" : "AREA" , "\n", |
||
| 77 | "$title.draw ", ($num) ? "AREA" : "AREA" , "\n", |
||
| 78 | ); |
||
| 79 | $num++; |
||
| 80 | } |
||
| 81 | |||
| 82 | } |
||
| 83 |
