Tuesday September 26, 2006
Getting the OS version using SNMP
Having information about the operating system a server is running comes
in handy, specially if a quick job requires one to test/ build
something
on a specific version of an OS. It is very easy to correlate with
such a situation in our day to day life.
Most of the OSs run some flavor of SNMP agent which can be leveraged to
our advantage in figuring out what Operating System is running on a
particular server. (There are other cool things one can go figure about
the server but that's a different thread). Once we know the Object
Identifiers (SNMP way of accessing a variable) to go after, it is very
easy to convert the basic semantic into a script. The script in turn can be
consumed by a management application like Sun Management Center to
program and automate the whole process.
In addition to Object Identifier one also needs security
credentials to perform gets on these agents from remote. On servers running Solaris 9
and below where the SunMC
agent is not running, the way to get information is using SNMP get
operation on sunMIB.sunSystem.motd Object Identifier. Something
as shown below using net-snmp utilities under /usr/sfw/bin directory on a Solaris 10 system can
be used for querying OS type and version.
| $ snmpget -v1 -c public <hostName>:<portNo> 1.3.6.1.4.1.42.3.1.3.0 SNMPv2-SMI::enterprises.42.3.1.3.0 = STRING: "Sun Microsystems Inc..SunOS 5.9.Generic.May 2002." |
|
$ snmpget -v1 -c public <hostName>:<portNo> 1.3.6.1.2.1.1.1.0 SNMPv2-MIB::sysDescr.0 = STRING: SunOS rm1-rack10-v880 5.10 Generic sun4u |
| $ snmpget -v1 -c public <hostName>:<portNo> 1.3.6.1.4.1.42.2.12.2.1.2.1.3.0 .. and you'll see response as shown below depending upon the OS type SNMPv2-SMI::enterprises.42.2.12.2.1.2.1.3.0 = STRING: "SunOS 5.10, Generic" or SNMPv2-SMI::enterprises.42.2.12.2.1.2.1.3.0 = STRING: "SunOS 5.9, Generic" or SNMPv2-SMI::enterprises.42.2.12.2.1.2.1.3.0 = STRING: "Linux 2.4.21-4.ELsmp, #1 SMP Fri Oct 3 17:52:56 EDT 2003" |
| $ snmpget -v3 -a MD5 -A <digestPassPhrase> -x DES -X
<privacyPassPhrase> -l authPriv -u <userName>
<hostName>:<portNo> 1.3.6.1.4.1.42.2.12.2.1.2.1.3.0 |
Posted at 02:06PM Sep 26, 2006 by adikhit in SNMP | Comments[0]