SNMP Printer Template

Templates, scripts for templates, scripts and requests for templates.

Moderators: Moderators, Developers

Author
Message
mazevedo
Posts: 3
Joined: Wed Apr 12, 2006 1:34 pm

SNMP Printer Template

#1 Post by mazevedo » Wed Apr 12, 2006 1:50 pm

I've created this bunch of XMLs to get generic SNMP Printer information:
  • * Get printer supply (toner, ink cartridge, etc...) and display a graph with the total capacity and remaining level of "ink"
    * Get the lifetime counter of impressions
    * Get the network interface statistics
You have inside this ZIP file the XMLs for:
  • * Data query to get Printer Supplies
    * Data template Get Printer Supply
    * Data template Get Printer Total Pages
    * Graph template Host MIB - Get Printer Supply
    * Host template SNMP Printer
    * XML SNMP Query template to put in <cactidir>/resource/snmp-queries/ in order to get the relevant OIDs
These should work on any Network Printer that has SNMP enabled. I've tested with the following printers:
  • * HP Laserjet 4050: Total page count working. I get the toner name, but level is -2, according with HP it's because I'm using a recycled toner
    * HP Laserjet 4250: Total page count working, toner and fuser levels working
    * HP Deskjet 1100: Total page count working, 4 ink levels working
    * Canon LPB1760e: Total page count working, toner name working, but level 0, probably same problem as HP
What I didn't figure out as a way to get the correct units for the supply levels, for instance, in the HP 4050 the units are in tenthsOfGrams and in the HP 4250 the units are in availablePrintPages. If only I could figure out a way of making the units appear in the graphs.

Don't forget to put the

Code: Select all

printer_supply.xml
file in the

Code: Select all

<cactidir>/resource/snmp-queries/
directory.
Hope this helps someone!
Attachments
SNMP Printer.zip
(22.07 KiB) Downloaded 122320 times

User avatar
gandalf
Developer
Posts: 22375
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: SNMP Printer Template

#2 Post by gandalf » Thu Apr 13, 2006 8:33 am

mazevedo wrote: What I didn't figure out as a way to get the correct units for the supply levels, for instance, in the HP 4050 the units are in tenthsOfGrams and in the HP 4250 the units are in availablePrintPages. If only I could figure out a way of making the units appear in the graphs.
Is there any OID that spits out these Units as a STRING? The define a new field using this OID but <direction>output</direction>. Now you may use |query_YourNewFieldName| for your Graphs
Reinhard

mazevedo
Posts: 3
Joined: Wed Apr 12, 2006 1:34 pm

Re: SNMP Printer Template

#3 Post by mazevedo » Thu Apr 13, 2006 1:25 pm

lvm wrote:Is there any OID that spits out these Units as a STRING? The define a new field using this OID but <direction>output</direction>. Now you may use |query_YourNewFieldName| for your Graphs
Reinhard
I've found in the Printer MIB this information:

Code: Select all

Name:             prtMarkerSuppliesSupplyUnit
Type:             OBJECT-TYPE
OID:              1.3.6.1.2.1.43.11.1.1.7

Parent:           prtMarkerSuppliesEntry
Previous sibling: prtMarkerSuppliesDescription
Next sibling:     prtMarkerSuppliesMaxCapacity
  	 
Numerical syntax: Integer (32bit)
Base syntax:      INTEGER
Composed syntax:  PrtMarkerSuppliesSupplyUnitTC
Status:           current
Max access:       read-only
   	 
Description: 	

Unit of measure of this marker supply container/receptacle.

NOTE: The above description has been modified from RFC 1759
for clarification.
The composed syntax is something like this:

Code: Select all

Name: 	PrtMarkerSuppliesSupplyUnitTC
Type: 	TEXTUAL-CONVENTION
Module: 	Printer-MIB
  	 
  	 
Base syntax:      INTEGER
Numerical syntax: Integer (32bit)
Composed syntax:  INTEGER
Value list:  	
  1:  other(1)
  2:  unknown(2)
  3:  tenThousandthsOfInches(3)
  4:  micrometers(4)
  5:  impressions(7)
  6:  sheets(8)
  7:  hours(11)
  8:  thousandthsOfOunces(12)
  9:  tenthsOfGrams(13)
  10: hundrethsOfFluidOunces(14)
  11: tenthsOfMilliliters(15)
  12: feet(16)
  13: meters(17)
  14: items(18)
  15: percent(19)
Status:           current
Description: 	

Unit of this marker supply container/receptacle.
I can't seem to obtain this values from the MIB, they're defined in the MIB RFC. Is there another way, like using an external program that receives this value from SNMP and returns a string with the unit?

User avatar
gandalf
Developer
Posts: 22375
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: SNMP Printer Template

#4 Post by gandalf » Thu Apr 13, 2006 2:43 pm

mazevedo wrote:I can't seem to obtain this values from the MIB, they're defined in the MIB RFC. Is there another way, like using an external program that receives this value from SNMP and returns a string with the unit?
How did you try? snmpwalk-ing the above OID failed? Then I'm at a loss
Reinhard

mazevedo
Posts: 3
Joined: Wed Apr 12, 2006 1:34 pm

Re: SNMP Printer Template

#5 Post by mazevedo » Fri Apr 14, 2006 7:35 am

lvm wrote:How did you try? snmpwalk-ing the above OID failed? Then I'm at a loss
Reinhard
This is what you get with an SNMP walk, just an integer.

Code: Select all

cacti:~# snmpwalk -c xxxxxxx -v 1 10.50.1.203  1.3.6.1.2.1.43.11.1.1 
SNMPv2-SMI::mib-2.43.11.1.1.2.1.1 = INTEGER: 1
SNMPv2-SMI::mib-2.43.11.1.1.2.1.2 = INTEGER: 1
SNMPv2-SMI::mib-2.43.11.1.1.3.1.1 = INTEGER: 0
SNMPv2-SMI::mib-2.43.11.1.1.3.1.2 = INTEGER: 0
SNMPv2-SMI::mib-2.43.11.1.1.4.1.1 = INTEGER: 3
SNMPv2-SMI::mib-2.43.11.1.1.4.1.2 = INTEGER: 3
SNMPv2-SMI::mib-2.43.11.1.1.5.1.1 = INTEGER: 21
SNMPv2-SMI::mib-2.43.11.1.1.5.1.2 = INTEGER: 15
SNMPv2-SMI::mib-2.43.11.1.1.6.1.1 = STRING: "Black Cartridge HP Q5942X"
SNMPv2-SMI::mib-2.43.11.1.1.6.1.2 = STRING: "Maintenance Kit HP 110V-Q5421A, 220V-Q5422A"
SNMPv2-SMI::mib-2.43.11.1.1.7.1.1 = INTEGER: 7
SNMPv2-SMI::mib-2.43.11.1.1.7.1.2 = INTEGER: 7
SNMPv2-SMI::mib-2.43.11.1.1.8.1.1 = INTEGER: 20000
SNMPv2-SMI::mib-2.43.11.1.1.8.1.2 = INTEGER: 225000
SNMPv2-SMI::mib-2.43.11.1.1.9.1.1 = INTEGER: 13799
SNMPv2-SMI::mib-2.43.11.1.1.9.1.2 = INTEGER: 144632
cacti:~# 
Look at values .7.1.1 and 7.1.2, you only get an integer for the unit type of each the toner and the maintenance kit supply values.

As I mentioned before, if you get into the Printer MIB specification you'll see that those values are defined, but you cannot obtain the units names from an actual SNMP walk, only the integers for that unit type name.

I've found out that each printer as it's own unit of measure. Most HP LaserJets 42xx and Deskjets 1xxx use tenthsOfGrams for units, while others use remaining prints available ( like this one=impressions(7) ), or others that use "meters" of pages available (?).

As I can't seem to get the units name from an actual SNMP walk, just the integer for that unit, it would be nice that Cacti had a "units" table, so when you get a particular integer unit type and you mention that that field is to be used with a "selectable" array of units, you could actually get the units name for that particular integer. There are other special fields like this one in other SNMP values.

Hope I did my best to make this clear, but even I look at my bad english and feel dizzy! :evil:

User avatar
gandalf
Developer
Posts: 22375
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

#6 Post by gandalf » Fri Apr 14, 2006 9:04 am

Your statements are absolutely correct. Even if it comes to the lookup table. Unfortunately, I'm not aware of any magic that would make cacti create and lookup such a table.
So, the only solution that comes to my memory would be a wrapper Script Query. This should simply perform all the SNMP lookups. And this would incorporate some "lookup table" in the code, changing ONLY this single OID from value to units. But this is very nasty, of course.
Reinhard

lucian.furtos
Posts: 1
Joined: Mon Jun 05, 2006 7:10 am

Need some SNMP information

#7 Post by lucian.furtos » Mon Jun 05, 2006 7:22 am

Hello,
My question is not about Cacti, but SNMP. I have to make a similar project about Printer management and I would like to ask you if you could help me with some links/docs about Printer management orver SNMP. Also I couldn't found a Printer v2 MIB. My email is: [email protected]rt.ro

Thank you for your time and please excuse me.

Lucian.

User avatar
gandalf
Developer
Posts: 22375
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

#8 Post by gandalf » Mon Jun 05, 2006 7:53 am

I'm not aware of any link that may help. AFAIK, manufacturers like to provide their own MIBs. And from some examples I deduced, that often SNMP support is less complete as e.g. http configuration, but that depends
Reinhard

User avatar
gandalf
Developer
Posts: 22375
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

#9 Post by gandalf » Tue Jul 25, 2006 11:52 am

That depends on the way you want to get things graphed. When using a COUNTER, you will get differences between polling intervals (perhaps normalized to a minute or so). That's your current settings.
But you may change to GAUGE to get those "increasing" values. So it depends on your likings
Reinhard

imro
Posts: 48
Joined: Thu Jun 15, 2006 11:36 am

#10 Post by imro » Tue Jul 25, 2006 2:18 pm

I just found that out ;-)
You have to go to Console -> Data Templates -> Host MIB -> Get Printer Total Pages and change the Data Source Type to Gauge

That's nice that it is to every bodies preference but it doesn't show total pages anywhere. That should be fixed.

Our kyocera printers don't have 1.3.6.1.2.1.43.11.1.1.1 so I had to change the <oid_index>.1.3.6.1.2.1.43.11.1.1.1</oid_index> to <oid_index>.1.3.6.1.2.1.43.11.1.1.2</oid_index> in printer_supply.xls. Even though I was able to choose the toner from printer_supply table it still won't show on graph.

imro
Posts: 48
Joined: Thu Jun 15, 2006 11:36 am

#11 Post by imro » Tue Jul 25, 2006 4:36 pm

As I said in previous reply mine snmp query for printer supply was not working until i changed printer_supply.xml. Now even though I am able to choose which supply I want to monitor the graph is not created. I get this in cacti log:

Code: Select all

07/25/2006 03:59:53 PM - CACTID: Poller[0] Host[12] DS[24] SNMP: v1: 192.168.11.164, dsname: supply_total, oid: .1.3.6.1.2.1.43.11.1.1.8.1, value: U
07/25/2006 03:59:53 PM - CACTID: Poller[0] Host[12] DS[24] WARNING: Result from SNMP not valid. Partial Result: ...
the oid is missing a 1 at the end it should be .1.3.6.1.2.1.43.11.1.1.8.1.1

when I walk the .1.3.6.1.2.1.43.11 I get this:

Code: Select all

SNMPv2-SMI::mib-2.43.11.1.1.2.1.1 = INTEGER: 1
SNMPv2-SMI::mib-2.43.11.1.1.2.1.2 = INTEGER: 1
SNMPv2-SMI::mib-2.43.11.1.1.3.1.1 = INTEGER: 0
SNMPv2-SMI::mib-2.43.11.1.1.3.1.2 = INTEGER: 0
SNMPv2-SMI::mib-2.43.11.1.1.4.1.1 = INTEGER: 3
SNMPv2-SMI::mib-2.43.11.1.1.4.1.2 = INTEGER: 4
SNMPv2-SMI::mib-2.43.11.1.1.5.1.1 = INTEGER: 3
SNMPv2-SMI::mib-2.43.11.1.1.5.1.2 = INTEGER: 4
SNMPv2-SMI::mib-2.43.11.1.1.6.1.1 = STRING: "Toner Container"
SNMPv2-SMI::mib-2.43.11.1.1.6.1.2 = STRING: "Waste Toner Box"
SNMPv2-SMI::mib-2.43.11.1.1.7.1.1 = INTEGER: 7
SNMPv2-SMI::mib-2.43.11.1.1.7.1.2 = INTEGER: 7
SNMPv2-SMI::mib-2.43.11.1.1.8.1.1 = INTEGER: 20000
SNMPv2-SMI::mib-2.43.11.1.1.8.1.2 = INTEGER: -2
SNMPv2-SMI::mib-2.43.11.1.1.9.1.1 = INTEGER: 20000
SNMPv2-SMI::mib-2.43.11.1.1.9.1.2 = INTEGER: -3
even though mine walk looks similar to mazevedo's (his misses the 1.3.6.1.2.1.43.11.1.1.1 entries too) the data query doesn't work unless i change <oid_index> in printer_supply.xml, so it has 2 at the end instead of 1.

User avatar
gandalf
Developer
Posts: 22375
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

#12 Post by gandalf » Thu Jul 27, 2006 2:30 pm

imro wrote:I just found that out ;-)
You have to go to Console -> Data Templates -> Host MIB -> Get Printer Total Pages and change the Data Source Type to Gauge

That's nice that it is to every bodies preference but it doesn't show total pages anywhere. That should be fixed.
To be precise, after changing the rrdtool option, you'll have to "rrdtool tune" all existing rrd files to mimic the wanted behaviour.
And by using the Summing function (see manual), it is well possible to get the totals (relative tpo the timespan of the current graph) displayed. You you may get daily total, weekly total ...
Our kyocera printers don't have 1.3.6.1.2.1.43.11.1.1.1 so I had to change the <oid_index>.1.3.6.1.2.1.43.11.1.1.1</oid_index> to <oid_index>.1.3.6.1.2.1.43.11.1.1.2</oid_index> in printer_supply.xls. Even though I was able to choose the toner from printer_supply table it still won't show on graph.
The first one belongs entirely to the printer manufacturers. As to your error, I would like to get the DEBUG code (the whole rrdtool graph statement) found from the Graph Management as well as the whole Data Template for this (including all OIDs you're using)
Reinhard

imro
Posts: 48
Joined: Thu Jun 15, 2006 11:36 am

#13 Post by imro » Fri Aug 04, 2006 10:31 am

I have used everything just as mazevedo has posted but I had to change the xml:

Code: Select all

<interface>
	<name>Get Printer Supply Information</name>
	<index_order_type>numeric</index_order_type>
	<oid_index>.1.3.6.1.2.1.43.11.1.1.[b]2[/b]</oid_index>

	<fields>
		<prtMarkersSupplyIndex>
			<name>Index</name>
			<method>walk</method>
			<source>value</source>
			<direction>input</direction>
			<oid>.1.3.6.1.2.1.43.11.1.1.[b]2[/b]</oid>
		</prtMarkersSupplyIndex>
		<prtMarkersSupplyDesc>
			<name>Description</name>
			<method>walk</method>
			<source>value</source>
			<direction>input</direction>
			<oid>.1.3.6.1.2.1.43.11.1.1.6</oid>
		</prtMarkersSupplyDesc>
		<prtMarkersSupplyUnits>
			<name>Supply Units</name>
			<method>walk</method>
			<source>value</source>
			<direction>input</direction>
			<oid>.1.3.6.1.2.1.43.11.1.1.7</oid>
		</prtMarkersSupplyUnits>

		<prtMarkersSupplySize>
			<name>Total Capacity</name>
			<method>walk</method>
			<source>value</source>
			<direction>output</direction>
			<oid>.1.3.6.1.2.1.43.11.1.1.8.[b]1[/b]</oid>
		</prtMarkersSupplySize>
		<prtMarkersSupplyUsed>
			<name>Total Used</name>
			<method>walk</method>
			<source>value</source>
			<direction>output</direction>
			<oid>.1.3.6.1.2.1.43.11.1.1.9.[b]1[/b]</oid>
		</prtMarkersSupplyUsed>
	</fields>
</interface>
The changes are in bold.

I know you said that OIDs depend on printer manufacturer, but as you can see mazevedo's snmp walk looks identical to mine - both are missing the index entries (.1.3.6.1.2.1.43.11.1.1.1). Have is it then that only I was having problem.

Also after I have changed the XML file the graph is working

jokerz
Posts: 13
Joined: Thu Oct 26, 2006 11:57 am

#14 Post by jokerz » Fri Oct 27, 2006 4:31 pm

I think i imported everything in fine.. but i get this error when i try to add a printer device with snmp enabled

Warning: file(c:/Inetpub/wwwroot/cacti/resource/snmp_queries/printer_supply.xml) [function.file]: failed to open stream: Permission denied in c:\Inetpub\wwwroot\cacti\lib\data_query.php on line 79

Warning: implode() [function.implode]: Bad arguments. in c:\Inetpub\wwwroot\cacti\lib\data_query.php on line 79


any help?

User avatar
adrianmarsh
Cacti User
Posts: 435
Joined: Wed Aug 17, 2005 8:51 am
Location: UK

#15 Post by adrianmarsh » Sun Oct 29, 2006 4:34 am

Would this also work for OKI printers? I've already created my own here..
Attachments
cacti_host_template_oki_printer.xml
OKI Host template
(44.23 KiB) Downloaded 2498 times
archive.zip
XML files for snmp_queries
(1.78 KiB) Downloaded 2533 times

Post Reply