#!/usr/bin/perl -w use strict; # ordered roughly by decreasing scale, so that they overlay well on the graph.. my @interesting = qw{ tor_sum http_sum https_sum smtp_sum }; # drawing style for each protocol my %styles = ( http_sum => 'LINE2', https_sum => 'LINE2', smtp_sum => 'LINE1', tor_sum => 'LINE2', ); if($ARGV[0]) { if($ARGV[0] eq 'autoconf') { print "yes\n"; exit 0; } elsif($ARGV[0] eq 'config') { print <) { if(/\s*\d+\s+(\d+)\s(DROP|RETURN)/) { $blocked += $1; } elsif($state == 0) { if(/^Chain (in|out)_internet_(\w+)_/) { $outName = "$2_$1"; $outSum = 0; $state = 1; } } elsif($state == 1) { if(/^\s*\d+\s+(\d+)/) { $outSum += $1; } else { if(!/pkts/) { $state = 0; $computed{$outName} = $outSum; } } } } close(FILE); # post process foreach my $interest (@interesting) { my $value = 0; if($interest =~ /(\w+)_sum/) { $value = $computed{"$1_in"} + $computed{"$1_out"}; } else { $value = $computed{$interest}; } print "$interest.value $value\n"; } print "BLOCKED.value $blocked\n";