[rrd-users] Re: Storing snmpget results in an array

Stephan Harren sh at abovenet.de
Tue Jul 22 14:57:08 MEST 2003


Quite easy,

try:

@var=qx(snmpwalk ....);

Now you have all your stuff line by line in an array named var.

To access it:

foreach (@var) {
	print "$_\n";
}

Or:

foreach $test (@var) {
	print "$test\n";
}

This way you'll get all the elements printed. Surely you can do anything you 
want with this values instead of printing them ...

HTH,

Stephan

Am Dienstag, 22. Juli 2003 14:52 schrieb Stephen Cheung:
> Hi all,
>
> I've read through the manuals and mailing lists, but didn't find anything.
> I'm trying to do the following:
>
> code to get snmp data values:
>
>         $var = `snmpget -Ov myipaddress public OID.0` (1,2,....etc)
>
> I can get single values and assign it to a variable. No problems.
>
> To get all values for that object, I can leave out the last value and get a
> list
>
>         snmpget -Ov myaddaddress public OID
>
> This command returns (say 1000) items in a list of values when run at a
> command prompt.
>
> C:\snmp>perl script.pl
> 0
> 0
> 0
> 0
> 4
> 6
> etc
>
> How can I enter this list into a perl array, so that when I perform the rrd
> update command, I can enter certain single element out of the array? Is
> this possible?
>
> eg rrdtool update myrrd.rrd N:$var[0]
>
> Do I use something like snmputil perl module?
>
>
> Thanks
> Steve
>
>
> --
> 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

-- 
Stephan Harren
Manager Site Operations
MFN-IS
-------------------------------
Phone +49 69 90554 153
Fax +49 69 90554 111
Cell +49 173 7011126

--
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