Révision 17f78427
Whitespace cleanup
- remove trailing whitespace
- remove empty lines at the end of files
| plugins/http/http_load_ | ||
|---|---|---|
| 21 | 21 |
|
| 22 | 22 |
=head1 REQUIREMENTS |
| 23 | 23 |
|
| 24 |
- The server running this plugin must be allowed to connect to the web
|
|
| 24 |
- The server running this plugin must be allowed to connect to the web |
|
| 25 | 25 |
server(s) you are going to monitor. |
| 26 |
- Some perl modules:
|
|
| 26 |
- Some perl modules: |
|
| 27 | 27 |
Time::HiRes, LWP::UserAgent, HTML::LinkExtor, LWP::ConnCache |
| 28 | 28 |
|
| 29 | 29 |
=head1 CONFIGURATION |
| ... | ... | |
| 131 | 131 |
my %urls=(); |
| 132 | 132 |
if(-r $file){
|
| 133 | 133 |
open(FILE,'<'.$file); |
| 134 |
while (<FILE>) {
|
|
| 134 |
while (<FILE>) {
|
|
| 135 | 135 |
my $url=$_; |
| 136 | 136 |
chomp($url); |
| 137 | 137 |
my $id=get_id($url); |
| ... | ... | |
| 150 | 150 |
my %cache=(); |
| 151 | 151 |
if(-r $file){
|
| 152 | 152 |
open(FILE,'<'.$file); |
| 153 |
while (<FILE>) {
|
|
| 153 |
while (<FILE>) {
|
|
| 154 | 154 |
m/^(\S*)\s+(.*)$/; |
| 155 | 155 |
$cache{ $1 } = $2;
|
| 156 | 156 |
} |
| ... | ... | |
| 297 | 297 |
print "graph_total Total\n"; |
| 298 | 298 |
print "graph_info This graph is generated by a set of serial GETs to calculate the total time to load $urls{$id}. ";
|
| 299 | 299 |
print "Note that browsers usually fork() the GET requests, resulting in a shorter total loading time.\n"; |
| 300 |
|
|
| 300 |
|
|
| 301 | 301 |
if(keys(%cache)>0){
|
| 302 | 302 |
for my $key ( sort reverse keys %cache ){
|
| 303 | 303 |
my $value=$cache{$key};
|
| ... | ... | |
| 496 | 496 |
my $value=$cache{$key};
|
| 497 | 497 |
if($key =~ m/^([A-Za-z]+)\_(\S+)$/){
|
| 498 | 498 |
my $name=$2; |
| 499 |
|
|
| 499 |
|
|
| 500 | 500 |
if ($1 eq $type){
|
| 501 | 501 |
$name=get_fieldname($name); |
| 502 | 502 |
print $name . ".value " . $value . "\n"; |
| ... | ... | |
| 609 | 609 |
exit(0); |
| 610 | 610 |
|
| 611 | 611 |
} elsif($ARGV[0] and $ARGV[0] eq "cron") {
|
| 612 |
# This thing is run by cron and should write a cache file for munin-node to
|
|
| 612 |
# This thing is run by cron and should write a cache file for munin-node to |
|
| 613 | 613 |
# read from |
| 614 | 614 |
|
| 615 | 615 |
my $verbose=0; |
| ... | ... | |
| 629 | 629 |
|
| 630 | 630 |
while ( my ($id, $url) = each(%urls) ) {
|
| 631 | 631 |
$verbose && print "Fetching $url (id: $id)... \n"; |
| 632 |
|
|
| 632 |
|
|
| 633 | 633 |
$t0=0; |
| 634 | 634 |
$status=0; |
| 635 | 635 |
%output=(); |
| ... | ... | |
| 682 | 682 |
$tag=$$link[0] . " " . $$link[1]; |
| 683 | 683 |
} |
| 684 | 684 |
$output{"tags_" . $$link[0] . "-" . $$link[1]}+=1;
|
| 685 |
|
|
| 685 |
|
|
| 686 | 686 |
if(filter($tag)){
|
| 687 | 687 |
$verbose && print " Processing: " . $$link[0] . " " . $$link[1] . " " . $$link[2] . "\n"; |
| 688 | 688 |
|
| ... | ... | |
| 693 | 693 |
} |
| 694 | 694 |
|
| 695 | 695 |
my $suburl=$$link[2]; |
| 696 |
|
|
| 696 |
|
|
| 697 | 697 |
$t0 = [gettimeofday]; |
| 698 | 698 |
$response = $browser->get($suburl); |
| 699 | 699 |
$output{"loadtime_" . $host} += sprintf("%.6f",tv_interval ( $t0, [gettimeofday]));
|
| ... | ... | |
| 720 | 720 |
while ( my ($id, $value) = each(%input) ) {
|
| 721 | 721 |
$input{$id}="U";
|
| 722 | 722 |
} |
| 723 |
|
|
| 723 |
|
|
| 724 | 724 |
# Adding new values |
| 725 | 725 |
while ( my ($id, $value) = each(%output) ) {
|
| 726 | 726 |
$input{$id}=$value;
|
| 727 | 727 |
$verbose && print " Result: " . $id . " -> " . $value . "\n"; |
| 728 | 728 |
} |
| 729 |
|
|
| 729 |
|
|
| 730 | 730 |
# Writing the cache |
| 731 | 731 |
$verbose && print "Writing cache file: " . $cachefile . "... "; |
| 732 | 732 |
open(FILE,">".$cachefile); |
| ... | ... | |
| 739 | 739 |
exit(0); |
| 740 | 740 |
}elsif($ARGV[0] and $ARGV[0] eq "config") {
|
| 741 | 741 |
my %urls=&read_urls($url_file); |
| 742 |
|
|
| 742 |
|
|
| 743 | 743 |
$debug && print "Reading cache file\n"; |
| 744 | 744 |
my $cachefile=$cachedir . "/" . &get_cache_file_name($scriptname,$id); |
| 745 | 745 |
my %cache=read_cache($cachefile); |
| ... | ... | |
| 773 | 773 |
} else {
|
| 774 | 774 |
cache_values(\%cache, $type); |
| 775 | 775 |
} |
| 776 |
}
|
|
| 776 |
} |
|
| 777 | 777 |
|
| 778 | 778 |
# vim:syntax=perl |
Formats disponibles : Unified diff