[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: Tor service monitoring util available?





Andre Eisenbach wrote:


On Fri, 4 Feb 2005, admin wrote:


Does such a thing exist?


Most of the things you've described can be done with existing tools like MRTG, or RRDTOOL. Especially the Tor unrelated things (CPU usage etc) can be done with existing monitoring tools. Tor can be easily integrated into MRTG etc. to add the Tor specific information.


Munin (http://www.linpro.no/projects/munin/) is easy to extend to monitor all sorts of variables. I monitor Tor bandwidth by having munin poll and summarize iptables output, as each server has its own iptable entry.

For example, if you happened to be using firehol to setup firewall rules (http://firehol.sourceforge.net/), the following script could be placed in your munin plugin's directory in order to get a pretty graph of tor bandwidth.

regards,
Valient

#!/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 <<EOM;
graph_title Network data by Protocol
graph_args --base 1000 -l 1 --logarithmic --no-minor
graph_vlabel Bytes/sec
BLOCKED.label Blocked
BLOCKED.type COUNTER
BLOCKED.max 12500000
BLOCKED.draw AREA
EOM
	foreach my $interest (@interesting)
	{
	    my $base = ($interest =~ /(\w+)_/)[0];
	    my $style = $styles{$interest};
	    print <<EOM
$interest.label $base
$interest.type COUNTER
$interest.max 12500000
$interest.draw $style
EOM
	}
	exit 0;
    }
}


open(FILE, "sudo /sbin/iptables -vnx -L|")
    or die "can't run iptables: $!";

my %computed;
my $outName;
my $outSum = 0;
my $state = 0;
my $blocked = 0;
while(<FILE>)
{
    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";