[collectd] feedback: traceroute collector idea

Hans-Cees Speel hanscees at hanscees.com
Tue Nov 8 21:22:51 CET 2005

> As always, bugreports and other feedback is welcome :)


this is other feedback.

1. traceroute as source of rrd
A friend of mine has an rrd setup which uses traceroute. Compared to 
ping this is more usefull, or additional  because:

- it will tell you where network problems might reside
- it will tell you when hops dissappear (when the network is changed 

The code he uses is a perl collector that talks to a named pipe. I 
know that is not compatible to collectd right now because you do not 
use named pipes. But if you might want to incorporate it it will cut 
down the work you would have to do. 

It might be a good idea, or perhaps not...., to extend collectd to 
accept input from named pipes. You could make a config file with RRD 
stuff defined like below, with the named pipe defined also.
Then collectd could act as an inbetween all kinds of collectors. The 
beauty of such a setup is the extendability and also that as a user 
you can run only those collectors you want. 
The problem is that your code might get too big and problematic or 
stuff like that. 

Well anyway, here is the info on the rrd collector with traceroute. 
It runs as a perl daemon, and without named pipe it echo's to the 

Here is the RRD stuff:

 GRAPH   traceroute            traceroute
 TYPE    traceroute            single
 LOWER   traceroute               0
 #UPPER  traceroute               100
 TITLE   traceroute            $LABEL
 DEF     traceroute            myhops=$RRD:hop:AVERAGE
 DEF     traceroute            myhop1=$RRD:hop1:AVERAGE
 DEF     traceroute            myhop2=$RRD:hop2:AVERAGE
 DEF     traceroute            myhop3=$RRD:hop3:AVERAGE
 COMMENT traceroute            $PERIOD
 LINE1   traceroute            myhops#00FF00:hops
 LINE1   traceroute            myhop1#00FFFF:hop1
 LINE1   traceroute            myhop2#FF00FF:hop2
 LINE1   traceroute            myhop3#0000FF:hop3

This is the code:

use POSIX qw(strftime);
use POSIX qw(uname);
use IO::Handle;

my ($kernel, $hostname, $release, $version, $hardware) = uname();

$0="traceroutedc"; # otherwise superps doesn't recognize us

$fifo = shift;
open(FIFO,"> $fifo") or die "cannot open $fifo\n";

sub print_counter{
    my ($subsystem, $output) = @_ ;
        $date = strftime("%Y%m%d%H%M%S", localtime());
        printf FIFO "sys=%s date=%s srv=%s %s\n", $hostname, $date, 
$subsystem, $output;
        printf "sys=%s date=%s srv=%s %s\n", $hostname, $date, 
$subsystem, $output;

open(PING,"traceroute -n|") or die "$! cannot open 
    my $n=0;
    my %hop = ();
        my ($hop,$ip,$r1,$ms1,$r2,$ms2,$r3,$ms3) = split;
        $r1+=0; $r2+=0; $r3+=0;
        $r1/=3 if($r1>0);

        "hop=$n hop1=$hop{1} hop2=$hop{2} hop3=$hop{3}");
Hans-cees Speel @ http://www.hanscees.com
Trees @ http://www.bomengids.nl

More information about the Collectd mailing list