I was asked to get hold of the total pages counts for the 100+ printers we have at work. All of them are HP Laser or Business Jets of some description and the vast majority are connected via some form of HP JetDirect network card/switch. After many hours of typing in IP addresses and copying and pasting the relevant figure in to Excel I have now been asked to do this on a weekly basis. This led me to think there must be an easier way, as an IT professional I can surely work out some time saving method to solve this issue.
Suffice it to say I do not feel very professional now after a day or so of trying to make SNMP work for me!
From what I understand the first thing is to enable SNMP on the printer. Done. Next I would need something to query the SNMP bit. I decided to go open source and free and someone here recommended net-snmp as a decent tool (I would like to have just added the printers as nodes in SolarWinds but we are somewhat tight on licences apparently). Next I need the name of the MIB. For this I believe the HP-LASERJET-COMMON-MIB has the correct information in it. Downloaded this and added to net-snmp. Now I need the OID which I believe after much scouring is printed-media-simplex-count (we have no duplex printers, that we are interested in at least). Running the following command yields the following demoralising output:
snmpget -v 2c -c public 10.168.5.1 HP-LASERJET-COMMON-MIB:.1.3.6.1.2.1.1.16.1.1.1
(the OID was derived from running:
snmptranslate -IR -On printed-media-simplex-count
Unlinked OID in HP-LASERJET-COMMON-MIB: hp ::= { enterprises 11 }
Undefined identifier: enterprises near line 3 of C:/usr/share/snmp/mibs/HP-LASER
JET-COMMON-MIB..txt
.1.3.6.1.2.1.1.16.1.1.1 )
Unlinked OID in HP-LASERJET-COMMON-MIB: hp ::= { enterprises 11 }
Undefined identifier: enterprises near line 3 of C:/usr/share/snmp/mibs/HP-LASER
JET-COMMON-MIB..txt
HP-LASERJET-COMMON-MIB:.1.3.6.1.2.1.1.16.1.1.1:
Am I barking up the wrong tree completely with this? My aim was to script it all to output to a file for all the IP addresses of the printers and then plonk that in Excel for my lords and masters to digest at their leisure. I have a feeling I am using either the wrong MIB or the wrong OID from said MIB (or both). Does anyone have any pointers on this for me? Or should I give up and go back to navigationg each printers web page individually (hoping not).
Well this is fairly odd-I thought that information was exposed via SNMP. However a quick snmpwalk of one of our P4515s revealed only the number of pages printed with the currently installed fuser. To look at all the info exposed via snmp I did the following:
If the OID for the printed pages on the currently installed fuser is any use it is:
The standard 'total page count' is at 1.3.6.1.2.1.43.10.2.1.4.1.1
Different models use different OID for details, such as number of pages faxed/copied/printed/duplex/color/black/....
I can't help with the MIB I'm afraid but you could use PowerShell to take the grind out of grabbing the values from the web page on the printer. It should be possible to modify the example below to do what you need:
http://blogs.technet.com/b/otto/archive/2007/08/23/quick-and-dirty-web-site-monitoring-with-powershell.aspx
Perl/Python also have Web scraping modules if that's an option.