#!/usr/bin/perl -w use strict; #use simplegraph; my %vips = (); # Set the graph max scale per server my %scale = ( '64.210.209.50' => 3500, '64.210.209.51' => 2000, '64.210.209.54' => 3500, '64.210.209.56' => 100, '64.210.209.61' => 3000, '64.210.209.132' => 500 ); # Set VIPs -> names mapping my %name = ( '64.210.209.50' => 'www.zwire.com', '64.210.209.51' => 'www.adquest3d.com', '64.210.209.54' => 'bannerads.zwire.com', '64.210.209.56' => 'sitemanager.zwire.com', '64.210.209.61' => 'imagesource.zwire.com', '64.210.209.132' => 'www.carcast.com', ); my $re_ip = qr/(\d+\.\d+\.\d+\.\d+):\d+/; my $re_line = qr/ ^ \s* $re_ip \s* -> \s* $re_ip \s* -> \s* $re_ip /x; my $iteration = 0; # Loop forever do { $iteration++; # Reset data my @connections = `bigpipe conn dump`; # You'll have to check docs for bigpipe to decide what constitutes a failure code # warn "bigpipe failed with rc:$?\n" and next unless $? >> 8 == 0; # or whatever foreach my $line (@connections) { $vips{$2}{$iteration}++ if ($line =~ /$re_line/); } # Push our new data onto the stack, but remove from the queue if we have more than 50 foreach my $k (keys %vips) { push @{$vips{$k}{'stack'}}, $vips{$k}{$iteration}; shift @{$vips{$k}{'stack'}} if $#{$vips{$k}{'stack'}} > 50; ## THIS LINE SHOULD BE ADDED!! See [dws]'s post below. delete $vips{$k}{$iteration}; } # Make a graph for each VIP foreach my $k (keys %vips) { # Skip VIPs that aren't in %name, we don't care about them next unless $name{$k}; my $image = SimpleGraph->new( width => 230, height => 120, yscale => $scale{$k}, marginwidth => 5, borderright => 5, borderleft => 30, gridlabels => 'yes', gridlines => ($scale{$k} / 4), label => $name{$k}." connections", ); $image->PlotSeries( color => "0,0,255", data => $vips{$k}{'stack'} ); $image->Draw( file => "/usr/local/www/local/connections$k.tmp" ); `mv -f /usr/local/www/local/connections$k.tmp /usr/local/www/local/connections$k.gif`; # warn "mv failed with rc:$?\n" unless $? >> 8 == 0; # or whatever? } } while(sleep 10);