ibanix has asked for the wisdom of the Perl Monks concerning the following question:
<-> In general, we find that those who disparage a given operating system, language, or philosophy have never had to use it in pratice. <->#!/usr/bin/perl use simplegraph; # %client_ip = (); # %frontend = (); # %total_conn = (); %vips = (); %scale = (); %name = (); $iteration = 0; # Set the graph max scale per server $scale{'64.210.209.50'} = 3500; $scale{'64.210.209.51'} = 2000; $scale{'64.210.209.54'} = 3500; $scale{'64.210.209.56'} = 100; $scale{'64.210.209.61'} = 3000; $scale{'64.210.209.132'} = 500; # Set VIPs -> names mapping $name{'64.210.209.50'} = 'www.zwire.com'; $name{'64.210.209.51'} = 'www.adquest3d.com'; $name{'64.210.209.54'} = 'bannerads.zwire.com'; $name{'64.210.209.56'} = 'sitemanager.zwire.com'; $name{'64.210.209.61'} = 'imagesource.zwire.com'; $name{'64.210.209.132'} = 'www.carcast.com'; # Loop forever while(1) { $iteration++; # Reset data @connections = `bigpipe conn dump`; foreach $line (@connections) { if ($line =~ /^\s*(\d+\.\d+\.\d+\.\d+):\d+ \s*->\s*(\d+\.\d+\.\d+\.\d+):\d+ \s*->\s*(\d+\.\d+\.\d+\.\d+)/x) { # $client_ip{$1}{$iteration}++; $vips{$2}{$iteration}++; # $frontend{$3}{$iteration}++; } } # Push our new data onto the stack, but remove from the queue if we ha +ve more than 50 foreach $k (keys %vips) { push @{$vips{$k}{'stack'}}, $vips{$k}{$iteration}; if ( $#{ $vips{$k}{'stack'} } > 50 ) { shift @{$vips{$k}{'stack'}}; } } # Make a graph for each VIP foreach $k (keys %vips) { if ($name{$k}) { $label = $name{$k}." connections"; } else { # Skip VIPs that aren't in %name, we don't care about +them next; } my $image = SimpleGraph->new( width => 230, height => 120, yscale => $scale{$k}, marginwidth => 5, borderright => 5, borderleft => 30, gridlabels => yes, gridlines => ($scale{$k} / 4), label => $label, ); my $temp = $vips{$k}{'stack'}; $image->PlotSeries( color => "0,0,255", data => $temp, ); $image->Draw(file => "/usr/local/www/local/connections$k.tmp") +; `mv -f /usr/local/www/local/connections$k.tmp /usr/local/www/l +ocal/connections$k.gif`; } sleep 10; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need some data structures cooked
by dreadpiratepeter (Priest) on Nov 19, 2002 at 21:14 UTC | |
|
Re: Need some data structures cooked
by dws (Chancellor) on Nov 19, 2002 at 21:30 UTC | |
|
Re: Need some data structures cooked
by UnderMine (Friar) on Nov 19, 2002 at 21:43 UTC | |
by petral (Curate) on Nov 21, 2002 at 15:55 UTC | |
|
Re: Need some data structures cooked
by BrowserUk (Patriarch) on Nov 20, 2002 at 00:52 UTC | |
by dws (Chancellor) on Nov 20, 2002 at 01:28 UTC |