CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: I need a program that...:
how to get proper snmpget values using perl script

 



venuyacha
New User

May 11, 2011, 5:02 AM

Post #1 of 4 (3794 views)
how to get proper snmpget values using perl script Can't Post

Hi,

I want to get the sysUptime(1.3.6.1.2.1.1.3.0) in a perl script.
I have installed Net-SNMP in my machine and snmp commands work in my machine.
I tried using the following way to retrieve the value
chomp($sysUpTime = `$SNMP_GET_CMD $SNMP_TARGET1 1.3.6.1.2.1.1.3.0`);

if I print $sysUpTime , I m getting the following output
"DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (61115500) 7 days, 1:45:55.00"

But I want to capture only the value i.e 61115500 .
Can someone help how to do that.
Let me know which perl module I can use to get the exact value of the MIB object instead of the complete display string .

Thanks in advance.


FishMonger
Veteran / Moderator

May 11, 2011, 3:00 PM

Post #2 of 4 (3785 views)
Re: [venuyacha] how to get proper snmpget values using perl script [In reply to] Can't Post

If you have Net::SNMP installed, why are you using a system command in backticks instead of using the module?

If you want to stick with the backticks approach, you'll need to use a regex to parse out the desired value.

If you use the module, I think it will return the value directly, but I can't test that until I get back to work tomorrow.


venuyacha
New User

May 11, 2011, 9:55 PM

Post #3 of 4 (3776 views)
Re: [FishMonger] how to get proper snmpget values using perl script [In reply to] Can't Post

I have installed Net-SNMP on my windows machine so that I can execute snmp methods(get,set,walk....) on windows command prompt. I havent installed any Perl module related to SNMP.
I tried exploring the SNMP modules available by googling. But couldnt find any specific to my requirement.
I appreciate any help you provide.
Thanks.


FishMonger
Veteran / Moderator

May 12, 2011, 5:33 AM

Post #4 of 4 (3765 views)
Re: [venuyacha] how to get proper snmpget values using perl script [In reply to] Can't Post

If you're using Activestate perl, then you'd use the ppm utility to install the module.

Quote
C:\>ppm install Net::SNMP


The module documentation can be found here: http://search.cpan.org/~dtown/Net-SNMP-v6.0.1/lib/Net/SNMP.pm

Other SNMP related modules: http://search.cpan.org/search?query=net%3A%3Asnmp&mode=all

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives