Dante_Graves has asked for the wisdom of the Perl Monks concerning the following question:

Monks, I'm in somewhat of a predicament, and hope you can help me out. I work for a Windows-only shop, and in this shop there's a Web balancer who spits out stats via SNMP on a non-standard port. I'm graphing certain stats via MRTG and all is well.

The problem is, when this machine reboots, most of the OIDs change, and thus I have to walk through a bunch of GetIfs to get it back to working properly.

The way it works is I'll have one OID, such as .1.3.6.1.4.1.140.625.190.1.40, and that OID points to several other OIDS that I need to map, like
.1.3.6.1.4.1.140.625.190.1.40.32.101.100.100.54.56.99.54.100.51.52.102 +.98.50.57.98.97.56.102.57.49.57.50.48.54.53.56.55.48.101.52.49.49.
I can't really script this via Win tools, as there really isn't any command line tools on Win that allow querying of an SNMP device that isn't using a standard port - but I see Net::SNMP does.

I'm looking for a way to query the device, retrieve the OIDs it's pointing to, and stick them in a MRTG config file. I plan on run it every hour or so, so it should look and see if the new OIDs it finds are the same as the ones in the config - if they are, it dies, other wise it does as above.

My problem is I really don't know much of Perl, nor the modules. So I'm looking for as much help as I can get! Thanks in advance!

Edit by tye, put CODE tags around long string

Replies are listed 'Best First'.
Re: Windows SNMP Querying?
by NetWallah (Canon) on Apr 12, 2004 at 17:17 UTC
    Instead of modifying the MRTG config file each time, I would suggest you use the "back-tick" option to run an external perl script. This script needs to do the digging into the OID's and retrieve the values. Read the section on "External Monitoring Scripts" in MRTG.

    Here is some skeleton SNMP access code, to get you started: (Stripped - to reduce complexity - version of working code).

    Offense, like beauty, is in the eye of the beholder, and a fantasy.
    By guaranteeing freedom of expression, the First Amendment also guarntees offense.
      Ah, thank you very much! Although I don't have the slightest idea on how to use this, I'll find out how! All I really needed was a little bit of a roadmap to point me in the direction I should go.