In a recent forum post, user ‘rmk’ came up with a Perl script to expose the software inventory through the SNMP hrSWInstalled OID for Debian and Ubuntu machines. User ‘zarxcky’ wrote up detailed instructions for deploying the solution and getting it to work with Ubuntu. Many thanks to these two for providing a very useful guide for the Zenoss community. Here is the write-up from ‘zarxcky’, the Perl script URL is listed at the end of the post.
How to make the hrSWInstalled OID working on Ubuntu
Credit to RMK for making this works!
Disclaimer:
This guide is intended to be used with hrswinstalled.pl to resolve hrSWInstalled OID on Ubuntu not revealing anything to Zenoss.
Prequisite Packages (Ubuntu .debs) to prepare for *snmp-perl:
Install this packages first before testing running the script.
apt-get install all software listed below before attempting to run the perl scripts:
- libnet-snmp-perl
- libyaml-perl
- libparse-debian-packages-perl
- libsnmp-info-perl
Place the hrswinstalled.pl within /etc/snmp/ folder.
Modify the snmpd.conf and add:
perl do "hrswinstalled.pl";
Note: if the "perl do" command not working when you try to snmpwalk the hrSWInstalled oid, this is because the SNMP agents (snmpd) are not perl-embedded enabled.
Since default snmpd Ubuntu package does not have embedded-perl support enabled (check using: net-snmp-config --configure-options), we need to rebuild back the Ubuntu snmpd (come from net-snmp) package with the --enable-embedded-perl option within the net-snmpfolder/debian/rules. Once we got the package, remove the original snmpd package installed and use the custom one that we just built.
Use the howtoforge reference below to rebuild debian packages under Ubuntu.
Note: after the ./configure step, check the net-snmp configuration summary, for example as shown below:
---------------------------------------------------------
Net-SNMP configuration summary:
---------------------------------------------------------
SNMP Versions Supported: 1 2c 3
Net-SNMP Version: 5.4.1
Building for: linux
Network transport support: Callback Unix TCP UDP
SNMPv3 Security Modules: usm
Agent MIB code: default_modules => snmpv3mibs mibII ucd_snmp notification notification-log-mib target agent_mibs agentx disman/event disman/schedule utilities host
Embedded Perl support: enabled
SNMP Perl modules: building -- embeddable
SNMP Python modules: disabled
Authentication support: MD5 SHA1
Encryption support: DES AES
---------------------------------------------------------
If we got "Embedded Perl support: enabled", then we know we on the right path to Nirvana ;o)
Continue with debuild command to build .deb packages (see Howtoforge link).
Listed .deb packages:
libsnmp15_5.4.1~dfsg-4ubuntu4.2_amd64.deb
libsnmp-python_5.4.1~dfsg-4ubuntu4.2_amd64.deb
libsnmp-base_5.4.1~dfsg-4ubuntu4.2_all.deb
snmp_5.4.1~dfsg-4ubuntu4.2_amd64.deb
libsnmp-dev_5.4.1~dfsg-4ubuntu4.2_amd64.deb
snmpd_5.4.1~dfsg-4ubuntu4.2_amd64.deb
libsnmp-perl_5.4.1~dfsg-4ubuntu4.2_amd64.deb
tkmib_5.4.1~dfsg-4ubuntu4.2_all.deb
Backup the /etc/snmp/snmpd.conf to a safe place
Install using dpkg -i for everything EXCEPT libsnmp-python & tkmib (since we not really need it)
Note: You might face dependencies problem especially with libsnmpd15 vs. apt-get. This is where the apt-get and/or dpkg kung-fu will be needed.
Double check for existence of --enable-embedded-perl parameter using "net-snmp-config --configure-options" command.
Configure the /etc/default/snmpd
Restore the snmpd.conf to /etc/snmp && restart snmpd.
Test by running:
snmpwalk -v 2c -c public hidro.logistics.com hrSWInstalled
You will start to see long lists of hrSWInstalled OID in actions, displaying and listing all software installed within any Ubuntu systems.
Example:
Before:
#snmpwalk -v 2c -c public hidro.logistics.com hrSWInstalled
HOST-RESOURCES-MIB::hrSWInstalled = No Such Object available on this agent at this OID
After:
#snmpwalk -v 2c -c hidro.logistics.com hrSWInstalled
HOST-RESOURCES-MIB::hrSWInstalledName.1 = STRING: "adduser 3.105ubuntu1/all (add and remove users and groups)"
HOST-RESOURCES-MIB::hrSWInstalledName.2 = STRING: "apache2 2.2.8-1ubuntu0.3/all (Next generation, scalable, extendable web serv
er)"
HOST-RESOURCES-MIB::hrSWInstalledName.3 = STRING: "apache2-mpm-worker 2.2.8-1ubuntu0.3/amd64 (High speed threaded model for Apa
che HTTPD)"
HOST-RESOURCES-MIB::hrSWInstalledName.4 = STRING: "apache2-utils 2.2.8-1ubuntu0.3/amd64 (utility programs for webservers)"
HOST-RESOURCES-MIB::hrSWInstalledName.5 = STRING: "apache2.2-common 2.2.8-1ubuntu0.3/amd64 (Next generation, scalable, extendab
le web server)"
HOST-RESOURCES-MIB::hrSWInstalledName.6 = STRING: "apparmor 2.1+1075-0ubuntu9.1/amd64 (User-space parser utility for AppArmor)"
HOST-RESOURCES-MIB::hrSWInstalledName.7 = STRING: "apparmor-utils 2.1+1075-0ubuntu9.1/amd64 (Utilities for controlling AppArmor
)"
HOST-RESOURCES-MIB::hrSWInstalledName.8 = STRING: "apt 0.7.9ubuntu17.1/amd64 (Advanced front-end for dpkg)"
.... and so on...
References:
SNMP Software Inventory for Debian and Ubuntu machines
http://www.net-snmp.org/wiki/index.php/Tut:Extending_snmpd_using_perl
http://pwet.fr/man/linux/formats/snmp/snmpd_conf
http://www.howtoforge.com/how-to-rebuild-the-squid-2.6-debian-package-with-support-for-x-forwarded-for-headers
The Perl script is available for downloading here: http://www.zenoss.com/Members/mray/hrswinstalled.pl



Hi,
I'm facing a problem trying to compile the snmpd package after adding the --enable-embedded-perl flag. I described it here:
http://ubuntuforums.org/showthread.php?p=7593401#post7593401
could any of you please tell me if i'm forgetting something?
thanks a lot