[rrd-users] Re: Pseudo Code

Arias, Sebastian Alejandro - (Ext Arg) Sebastian.Arias at attla.com
Tue Jul 3 17:11:41 MEST 2001


Sorry,  but i want to use the sleep external command:

system(`sleep 5`);

i only give to you  some help ... you can make some changes in the script to
get the best option !!!

Good Look.


Sebastian Arias
Associate
Infraestructure & Technology Services
AT&T Latin America
Tel. 5288-0173 - Fax 5288-0408


-----Mensaje original-----
De: owen at dixon.delong.sj.ca.us [mailto:owen at dixon.delong.sj.ca.us]
Enviado el: Martes, 03 de Julio de 2001 12:03 p.m.
Para: MSharpe at gemplex.com; rrd-users at list.ee.ethz.ch; Arias, Sebastian
Alejandro - (Ext Arg)
Asunto: [rrd-users] Re: Pseudo Code



> 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:MSharpe at gemplex.com]
> 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:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
> Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
> 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:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
> Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
> Archive     http://www.ee.ethz.ch/~slist/rrd-users
> WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi
> 
> 

--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
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:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the rrd-users mailing list