Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

HP Printers/SNMP Get Page Counts


  • Please log in to reply
11 replies to this topic

#1 mattbirk

mattbirk

  • Members
  • 106 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Chicago, IL
  • Local time:02:28 PM

Posted 01 March 2013 - 12:53 PM

So I am tasked with getting printer total page counts at the end of each month, and there are ~75 IP printers, all setup in HP WebJet Admin.

 

I am looking for a way to create a script or make it easier then visiting each printer IP address and going to Usage Page, then recording the page number individually for each one.

 

Can someone help me with SNMP? I have installed Net-SNMP, Quest Free Network Tools. I have ran some commands attempting to get the info, but I get errors such as Error In Packet No Such Variable Name in this MIB.

 

I am confused about MIBs. What are they? Where do I store them? Can I get this information from WebJet Admin? I have looked, but don't see any places as to where...

 

Any help is greatly appreciated!



BC AdBot (Login to Remove)

 


#2 mattbirk

mattbirk
  • Topic Starter

  • Members
  • 106 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Chicago, IL
  • Local time:02:28 PM

Posted 01 March 2013 - 01:43 PM

When I enter into command prompt:

snmpwalk -v1 -c public 140.192.106.48

 

I get a TON of data back with all the MIB numbers, and the String or Integer = and I found a line that listed the total page count, because I searched and got an exact number match. The line was:

SNMPv2-SMI::mib-2.43.10.2.1.4.1.1 = Counter32: 16101

 

(16,101 is the amount of total pages printed as of today)

 

So that's exactly what I want, but does anyone know how to only pull that piece of data? Otherwise I get thousands of lines back when I entered that code.



#3 Keiffer84

Keiffer84

  • Members
  • 4 posts
  • OFFLINE
  •  
  • Local time:08:28 PM

Posted 13 March 2013 - 07:32 AM

Not sure you've had an answer but for the benefit of others simply qualify the object name:

snmpwalk -v1 -c public 140.192.106.48 mib-2.43.10.2.1.4.1.1 

Results in the single line you have. Use other shell tools to extract actual page number.

 

hth



#4 mattbirk

mattbirk
  • Topic Starter

  • Members
  • 106 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Chicago, IL
  • Local time:02:28 PM

Posted 14 March 2013 - 06:20 PM

Thanks! That worked!

Will that same command work with other HP printer models?

Also, what do you mean when you say to use other shell tools to extract actual page numbers?

 

Anyway...THANKS SO MUCH!



#5 Keiffer84

Keiffer84

  • Members
  • 4 posts
  • OFFLINE
  •  
  • Local time:08:28 PM

Posted 15 March 2013 - 06:53 AM

As long as the printer has SNMP enabled, yes that OID corresponds with the printer page count on HP printers.

 

Shell tools to extract the actual page number include perl and sed. For example:

snmpwalk -v1 -c public 140.192.106.48 mib-2.43.10.2.1.4.1.1 | perl -pe 's/.* ([\d]+)$/$1/'

The pipe into sed would be

sed -e 's/.* \([[:digit:]]*\)$/\1/'

Both programs will reduce the output to the page count.



#6 mattbirk

mattbirk
  • Topic Starter

  • Members
  • 106 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Chicago, IL
  • Local time:02:28 PM

Posted 15 March 2013 - 10:07 AM

Thanks for the reply. I'm a bit confused, I downloaded and installed Perl Strawberry for Windows and ran the command in the Strawberry command prompt, but got the return:

 

Can't find string terminator "'" anywhere before EOF at -e line 1.

 

I don't really know exactly what I'm doing, but that was the error I received. Thanks



#7 Keiffer84

Keiffer84

  • Members
  • 4 posts
  • OFFLINE
  •  
  • Local time:08:28 PM

Posted 19 March 2013 - 06:19 AM

Ah! I was working on Linux. The quoting might be the cause of the issue. Try double quotes instead of the single quote. Windows interprets quotes differently to Linux.



#8 mattbirk

mattbirk
  • Topic Starter

  • Members
  • 106 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Chicago, IL
  • Local time:02:28 PM

Posted 16 April 2013 - 02:39 PM

That is excellent, thanks so much!

 

My next question for you, if you don't mind, is that I have created a Notepad document with all of the printers IP listed in that command and labeled each one for example like this:

 

 

#ALH 110#
snmpwalk -v1 -c public 140.192.106.48 mib-2.43.10.2.1.4.1.1 | perl -pe "s/.* ([\d]+)$/$1/"
 
ALH 110 is the room number, but it's not liking my # characters, which I thought would comment it out. 
 
Is there any way then to run the whole script but with some way to label each line by room number so I know which printer it corresponds with? 
 
Anyways, you have already saved me LOTS!!! of time, and I am very grateful! Thanks again!


#9 Keiffer84

Keiffer84

  • Members
  • 4 posts
  • OFFLINE
  •  
  • Local time:08:28 PM

Posted 17 April 2013 - 10:39 AM

That is excellent, thanks so much!

 

#ALH 110#
snmpwalk -v1 -c public 140.192.106.48 mib-2.43.10.2.1.4.1.1 | perl -pe "s/.* ([\d]+)$/$1/"
 
ALH 110 is the room number, but it's not liking my # characters, which I thought would comment it out. 
 
Is there any way then to run the whole script but with some way to label each line by room number so I know which printer it corresponds with? 

 

If that notepad document is a batch file, the comment will be either the word rem, short for remark. A batch file will have either .bat or .cmd as the extension. Nowadays one should be looking at running scripts with Powershell, which is another whole can of worms. Very powerful, but warps the brain, ;-). However, using the above with Powershell would require changes that are hardly beneficial given all you need to pull out.

 

So, change the first # in those comment lines to 'rem ' without quotes and the trailing space, and make sure the extension is .bat; running that on the command line will list the page counts.



#10 ryworld61

ryworld61

  • Members
  • 2 posts
  • OFFLINE
  •  
  • Local time:02:28 PM

Posted 16 April 2014 - 02:06 PM

Not sure if I can re-bump this thread, but I am doing the same thing, however I need to specify an SNMP string that is set for security purposes other than 'public'.  Do I just replace 'public' with the string or are there other hoops to jump through?  Thanks for any help in advance!



#11 ryworld61

ryworld61

  • Members
  • 2 posts
  • OFFLINE
  •  
  • Local time:02:28 PM

Posted 16 April 2014 - 02:11 PM

Apologies, should have just tested before asking.  Replacing the public string with the secure SNMP string that was generated worked!



#12 StarT3

StarT3

  • Members
  • 1 posts
  • OFFLINE
  •  
  • Local time:11:28 PM

Posted 18 April 2014 - 04:52 AM

I'm quite confused with the question itself. As far as i remember HP web jetadmin (or xerox centreware) - is a web service that periodically gets data from printers and print servers. So Web Jetadmin already contains all the data you need (page counters), and there is no need to ask each printer individually.

In my mind you should find a way to export data from Web Jetadmin server.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users