On Thu, 15 Jul 2004, Timothy Kohl wrote:

But of course, this isn't portable. It won't work on Windows -- which
was specifically asked for -- and it also won't work on OSX or various
other Unix variants.

Back to square one?


The point is, there is obviously no portable way to do this except code a bunch of different variants and bundle them together in one monolithic module.

Which, as I keep saying, is generally known as SNMP. And it's not just a Perl module, it's a big scary ISO standard that is already spoken today by gobs of hardware & software all around you if you just know to look.


And, as you seem suggest, that is probably the best approach here.

SNMP is a formal, massively over-engineered spec for getting and setting information of just about any kind for just about any kind of network addressable host, including such things as computers, printers, routers, wireless access points, monitors, carrier pigeons, etc.

The people that came up with SNMP developed this huge, overarching hierarchy of objects that you can get or set info about, and this hierarchy can be traversed or walked in useful ways. All of the elements in this hierarchy can be referred to by name (which is somewhat easier to remember, but there's so much hierarchy that no human is likely to bother) or by number (which is baffling, but if you bundle it all up in software you only have to look it up once).

Therefore, if you have the SNMP command line tools installed, you can do commands such as these:

  % snmpget solarisbox public .iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0
  % snmpget solarisbox public .1.3.6.1.2.1.1.1.0

And either way you get back output like this:

  system.sysDescr.0 = Sun SNMP Agent, Ultra-1

Luckily, because almost every query you're likely to be interested in is going to have the same prefix (note that we don't get to "internet" until the fourth level down), you can do abbreviated queries too, e.g.:

  % snmpget solarisbox public system.sysUpTime.0
  system.sysUpTime.0 = Timeticks: (5126167) 14:14:21.67

So, in order to solve the problem being asked in this thread, all you have to do is look up the path to the objects that relate usefully to the available memory on the device you want to poll, and then write a five line Perl script to retrieve that value.

This should be completely portable and, once the infrastructure is in place, more or less easy to manage. The tricky bit isn't portability, but in coping with the complexity of the spec -- I don't, for example, have the slightest clue where memory will be denoted, though it is probably nested in there somewhere (I've seen MRTG graphs that depict memory usage over time, so SNMP must be reporting it somehow).

For example DBI has to be taught (more or less) how to handle different flavored databases.

Right, but any device which supports SNMP has, by that very fact, already come up with the necessary handler; at the level we're dealing with, you never ever have to dirty your hands with such details.


On the downside, there are completely different, filthy details, but at least they're portably filthy. :-)


Really, don't do this from scratch, just set up some infrastructure (that is, make sure hosts you want info about are responding to SNMP queries properly) and then see if you can get a package like Mon to do the work for you. This may be overkill for a small project, but it makes whole classes of diagnostic problems into known quantities that you don't have to think about anymore, which is certainly appealing.




--
Chris Devers
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to