Re: Script for detecting RRDs not collecting and makingTOP "trafficers"

<[email protected]>
Newsgroups gmane.network.cricket.user
Message-ID <3D28EBDA36A6E6469582A86D3B5B639C01925363@tlrbeantmbx02.ERF.THOMSON.COM>
> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On 
> Behalf Of Nicolas Royo
> Sent: Tuesday, April 24, 2007 22:27
> To: [email protected]
> Subject: [cricket-users] Script for detecting RRDs not 
> collecting and makingTOP "trafficers"
> 
> Hi Folks,
>  
> Im using cricket for monitoring customized wireless APs and 
> therefore, clientes that are very dinamic.
> As the number of targets rises to about 4000 clients, I was 
> looking a way for detecting who have activity and who dont.
>  
> Have anyone of you have some tip or piece of code implemented 
> for fetching all DS values from a folder containing hughe 
> numbers of RRDs and logging the ones who are not?

I wrote this to go over our rrds each night to look for errors:
shell script:
#!/bin/sh

DATADIR=/home/cricket/cricket-data
PRINTTOOL="/home/cricket/bin/network-error-finder.plx"
TMP=`mktemp /tmp/_network_err-log.XXXXXXXXXX` || exit 1

rm -f $TMP

$PRINTTOOL $DATADIR/routers/router*/*.rrd > $TMP
$PRINTTOOL $DATADIR/switches/cat00/mod*/*.rrd >> $TMP
$PRINTTOOL $DATADIR/switches/cat*/*.rrd >> $TMP

/bin/mail -s "network errors `date -d yesterday +%F`" [email protected]
< $TMP
rm -f $TMP



And this perl script:
#!/usr/bin/perl -w

use strict;


my @rrdout;
my $i = 0;
my $j;
my $err_in;
my $err_out;

while ($i < @ARGV) {
        @rrdout = `/usr/bin/rrdtool fetch $ARGV[$i] AVERAGE -s
00:30am-1day -e 0am-0day -r 1800`;

        $j = 0;
        $err_in = 0;
        $err_out = 0;
        while ($j < @rrdout) {
                if ($rrdout[$j] =~ /:/) {
                        # print "$rrdout[$j]";
                        @_ = split / /, $rrdout[$j];
                        $err_in += $_[3];
                        $err_out += $_[4];
                }
                $j++;
        }

        if (($err_in > 0.01) || ($err_out > 0.01)) {
                print "$ARGV[$i]\n";
                print "errors in:\t$err_in\n";
                print "errors out:\t$err_out\n";
        }
        $i++;
}



It's crude but does the trick. I guess you can just change the DSes you
want to read to the ones that monitor traffic, and inverse the logic to
send you a list of hosts that don't have any traffic.

Take care.

// nick

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.