I'm using cacti for monitoring a french provider's backbone.
I'm actually working on a perl script to recover DSLAM's up conections number.
Code: Select all
#! /usr/bin/perl -w
# Ce fichier recupere le nombre de session active sur une carte du DSLAM huawei.
use strict;
my $IP;
my $TEMP;
my $i;
my $communaute;
my $NB_CO;
my $p1;
my $p2;
my @sp1;
my @sp2;
my @ETAT;
my $carte;
my $temp1;
my $temp2;
$temp1 = 'temp1.txt';
$temp2 = 'temp2.txt';
$communaute = 'communaute';
sub usage {
print STDERR <<EOF;
usage : executer tout simplement avec l'adresse ip du DSLAM comme parame tre.
exemple : script_total.pl -ip aaa.bbb.ccc.ddd -carte 1
EOF
}
sub getNextParam() {
if (@ARGV <= 1) {
usage();
exit(1);
}
shift(@ARGV);
return $ARGV[0];
}
if (@ARGV != 4) {
usage();
exit(1);
}
while (@ARGV > 1) {
if ($ARGV[0] eq '-ip') {
$IP = getNextParam();
} elsif ($ARGV[0] eq '-carte') {
$carte = getNextParam();
} else {
print STDERR "Option inconnue : $ARGV[0]\n";
}
shift(@ARGV);
}
system("/usr/bin/snmpwalk -v 1 -c $communaute $IP .1.3.6.1.4.1.2011.6.3.3.4.1.5. 0.$carte > $temp2");
open(TEMP2, $temp2);
$NB_CO = 0;
$i=0;
while (<TEMP2>)
{
@sp1 = split(/:/, $_);
$p1 = $sp1[1];
chomp ($p1);
if ($p1 eq " 1")
{
$NB_CO++;
}
$i++;
}
print "nb_co:$NB_CO nb_co_total:$i";
exit(0);
but when this one is execute by poller it return me a null valueSup-cacti:/usr/share/cacti/site/scripts# ./script_par_carte.pl -ip xxx.xxx.xxx.xxx -carte 1
nb_co:0 nb_co_total:32Sup-cacti:/usr/share/cacti/site/scripts#
07/20/2006 08:28:11 PM - CMDPHP: Poller[0] Host[401] CMD: /usr/bin/perl /usr/share/cacti/site/scripts/script_par_carte.pl -ip xxx.xxx.xxx.xxx -carte 1, output: nb_co:0 nb_co_total:0
I would like to know if you see something wrong with that.
Thank you for tour consideration.
I hope you can help me.
Best regards
Raphael.Grenier@altitudetelecom.fr