> If your Sys Op is linux or any unix, yo can run this script to do this, of
> course you will need to define some vars like $rrd, $community and $router.
> I dont know it this run ok, I do it under notepad a i cant test this :) ... 
> i hope that you will find this usefull.
> 
:-)  Well, I see at least one error which I'll correct below...

> Code beginning:
> 
> #!/usr/bin/perl
> 
> 
> $router="your.router.ip";
> $community="your.router.community.naturally.named.PUBLIC";
> $loop=1;
> $rrd="yourouter.rrd"
> 
> while ($loop)
>       {
>       $in=`/usr/bin/snmpget $router $community 2.2.1.10.4`;
>       $out=`/usr/bin/snmpget $router $community 2.2.1.16.4`;
>       $exec=`/usr/bin/rrdtool update $rrd N:$in:$out`;

>       sleep 5; <<<<WRONG... That's 5 seconds
        sleep 300; # This will sleep for 5 minutes.
>       }
> 

However, there are two problems with this.  First, it ignores the fact that
snmpget takes time to execute, and second, it's a big waste to call rrdtool
as an external program from PERL (snmpget too, but I don't have the .PMs
for SNMP handy, so I can't provide that.  A better iteration might look
something like:

#!/usr/bin/perl

use RRDs;

$router="your.router.ip"
$community="your.router.readcommunity.naturally.named.PUBLIC";
$rrd="yourrouter.rrd";

while (1)
{
        $now = time()
        $in=  `/usr/bin/snmpget $router $community 2.2.1.10.4`;
        $out= `/usr/bin/snmpget $router $community 2.2.1.16.4`;
        $r=RRDs::update($rrd, "$now:$in:$out");
        if (RRDs::error ne "")
        {
                print STDERR "Couldn't store $now:$in:$out in $rrd.\n";
        }
        sleep ($now+300-time());
}

Owen

> Sebastian Arias
> Associate
> Infraestructure & Technology Services
> AT&T Latin America
> Tel. 5288-0173 - Fax 5288-0408
> 
> 
> -----Mensaje original-----
> De: Sharpe, Michael [mailto:[EMAIL PROTECTED]
> Enviado el: Martes, 03 de Julio de 2001 10:27 a.m.
> Para: Rrd-Users (E-mail)
> Asunto: [rrd-users] Pseudo Code
> 
> 
> 
> Can someone please explain to me what this pseudo code is?
> 
> while not the end of the universe
>    do
>       get result of
>          snmpget router community 2.2.1.10.4
>       into variable $in
>       get result of
>          snmpget router community 2.2.1.16.4
>       into variable $out
>       rrdtool update myrouter.rrd N:$in:$out
>       wait for 5 minutes
>    done
> 
> I am simply trying to get some OIDs in to a test database I created.
> Thanks.
> 
> Mike 
> 
> 
> --
> Unsubscribe mailto:[EMAIL PROTECTED]
> Help        mailto:[EMAIL PROTECTED]
> Archive     http://www.ee.ethz.ch/~slist/rrd-users
> WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi
> Este mensaje es confidencial. El mismo contiene información reservada 
> y que no puede ser difundida. Si usted ha recibido este e-mail 
> por error, por favor avísenos inmediatamente vía e-mail y tenga la 
> amabilidad de eliminarlo de su sistema; no deberá copiar el mensaje 
> ni divulgar su contenido a ninguna persona. Muchas gracias.
>  
> This message is confidential. It contains information that is privileged and
> legally exempt from disclosure. If you have received this e-mail by mistake,
> 
> please let us know immediately by e-mail and delete it from your system; 
> you should also not copy the message nor disclose its contents to anyone. 
> Thank You.
> 
> 
> --
> Unsubscribe mailto:[EMAIL PROTECTED]
> Help        mailto:[EMAIL PROTECTED]
> Archive     http://www.ee.ethz.ch/~slist/rrd-users
> WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi
> 
> 

--
Unsubscribe mailto:[EMAIL PROTECTED]
Help        mailto:[EMAIL PROTECTED]
Archive     http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi

Reply via email to