├── img
├── GrafanaLoadJSON.png
├── PagecountGraph.png
├── TrayStatusGraph.png
├── ConsumableOKGraph.png
├── ConsumableCriticalGraph.png
├── ConsumableWarningGraph.png
└── GrafanaDashboardImport.png
├── services-printers.conf
├── printer-metrics-graphis.ini
├── printer-pagecount.ini
├── printer-trays.ini
├── printer-consumables.ini
├── README.md
├── printers.conf
├── CHANGELOG.md
├── printer-metrics-graphite.json
├── LICENSE
├── check_snmp_printer
└── printer-metrics-influxdb.json
/img/GrafanaLoadJSON.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tylan/check_snmp_printer/HEAD/img/GrafanaLoadJSON.png
--------------------------------------------------------------------------------
/img/PagecountGraph.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tylan/check_snmp_printer/HEAD/img/PagecountGraph.png
--------------------------------------------------------------------------------
/img/TrayStatusGraph.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tylan/check_snmp_printer/HEAD/img/TrayStatusGraph.png
--------------------------------------------------------------------------------
/img/ConsumableOKGraph.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tylan/check_snmp_printer/HEAD/img/ConsumableOKGraph.png
--------------------------------------------------------------------------------
/img/ConsumableCriticalGraph.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tylan/check_snmp_printer/HEAD/img/ConsumableCriticalGraph.png
--------------------------------------------------------------------------------
/img/ConsumableWarningGraph.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tylan/check_snmp_printer/HEAD/img/ConsumableWarningGraph.png
--------------------------------------------------------------------------------
/img/GrafanaDashboardImport.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tylan/check_snmp_printer/HEAD/img/GrafanaDashboardImport.png
--------------------------------------------------------------------------------
/services-printers.conf:
--------------------------------------------------------------------------------
1 | apply Service for (snmp_printer => config in host.vars.snmp_printer) {
2 | import "generic-service"
3 |
4 | check_command = "snmp_printer"
5 |
6 | vars += config
7 | }
8 |
--------------------------------------------------------------------------------
/printer-metrics-graphis.ini:
--------------------------------------------------------------------------------
1 |
2 | [Consumables Status]
3 | dashboard = "printer-metrics"
4 | panelId = "1"
5 | orgId = ""
6 | repeatable = "no"
7 |
8 | [Tray Status]
9 | dashboard = "printer-metrics"
10 | panelId = "2"
11 | orgId = ""
12 | repeatable = "no"
13 |
14 | [Pagecount]
15 | dashboard = "printer-metrics"
16 | panelId = "3"
17 | orgId = ""
18 | repeatable = "no"
19 |
--------------------------------------------------------------------------------
/printer-pagecount.ini:
--------------------------------------------------------------------------------
1 | [printer-pagecount.graph]
2 | check_command = "snmp_printer"
3 |
4 | [printer-pagecount.metrics_filters]
5 | Black-and-White.value = "$service_name_template$.perfdata.Black-and-White.value"
6 | Color.value = "$service_name_template$.perfdata.Color.value"
7 |
8 | [printer-pagecount.urlparams]
9 | areaAlpha = "0.0"
10 | yUnitSystem = "none"
11 | yMin = "0"
12 |
13 | [printer-pagecount.functions]
14 | Black-and-White.value = "alias(color($metric$, '#000000'), 'Black-and-White')"
15 | Color.value = "alias(color($metric$, '#60f7c5'), 'Color')"
16 |
--------------------------------------------------------------------------------
/printer-trays.ini:
--------------------------------------------------------------------------------
1 | [printer-trays.graph]
2 | check_command = "snmp_printer"
3 |
4 | [printer-trays.metrics_filters]
5 | Tray_1.value = "$service_name_template$.perfdata.Tray_1.value"
6 | Tray_2.value = "$service_name_template$.perfdata.Tray_2.value"
7 | Tray_3.value = "$service_name_template$.perfdata.Tray_3.value"
8 | Tray_4.value = "$service_name_template$.perfdata.Tray_4.value"
9 | Drawer_1.value = "$service_name_template$.perfdata.Drawer_1.value"
10 | Drawer_2.value = "$service_name_template$.perfdata.Drawer_2.value"
11 | Drawer_3.value = "$service_name_template$.perfdata.Drawer_3.value"
12 | Drawer_4.value = "$service_name_template$.perfdata.Drawer_4.value"
13 | Stack_Bypass.value = "$service_name_template$.perfdata.Stack_Bypass.value"
14 | MP_Tray.value = "$service_name_template$.perfdata.MP_Tray.value"
15 | Mp_Tray.value = "$service_name_template$.perfdata.Mp_Tray.value"
16 | Multi-purpose_Tray.value = "$service_name_template$.perfdata.Multi-purpose_Tray.value"
17 | Manual_Paper.value = "$service_name_template$.perfdata.Manual_Paper.value"
18 | Manual_Envelope.value = "$service_name_template$.perfdata.Manual_Envelope.value"
19 |
20 | [printer-trays.urlparams]
21 | areaAlpha = "0.5"
22 | yMin = "0"
23 | yMax = "100"
24 | yUnitSystem = "si"
25 | vtitle = " Percentage Left"
26 |
27 |
28 | [printer-trays.functions]
29 | Tray_1.value = "alias(color($metric$, '#ff9700'), 'Tray 1')"
30 | Tray_2.value = "alias(color($metric$, '#8900ff'), 'Tray 2')"
31 | Tray_3.value = "alias(color($metric$, '#ff002f'), 'Tray 3')"
32 | Tray_4.value = "alias(color($metric$, '#34ff00'), 'Tray 4')"
33 | Drawer_1.value = "alias(color($metric$, '#ff9700'), 'Drawer 1')"
34 | Drawer_2.value = "alias(color($metric$, '#8900ff'), 'Drawer 2')"
35 | Drawer_3.value = "alias(color($metric$, '#ff002f'), 'Drawer 3')"
36 | Drawer_4.value = "alias(color($metric$, '#34ff00'), 'Drawer 4')"
37 | Stack_Bypass.value = "alias(color($metric$, '#00ffbd'), 'Stack Bypass')"
38 | MP_Tray.value = "alias(color($metric$, '#00ffbd'), 'MP Tray')"
39 | Mp_Tray.value = "alias(color($metric$, '#00ffbd'), 'MP Tray')"
40 | Multi-purpose_Tray.value = "alias(color($metric$, '#00ffbd'), 'MP Tray')"
41 | Manual_Paper.value = "alias(color($metric$, '#00ffbd'), 'Manual Paper')"
42 | Manual_Envelope.value = "alias(color($metric$, '#00ffbd'), 'Manual Envelope')"
43 |
--------------------------------------------------------------------------------
/printer-consumables.ini:
--------------------------------------------------------------------------------
1 | [printer-consumables-colors.graph]
2 | check_command = "snmp_printer"
3 |
4 | [printer-consumables-colors.metrics_filters]
5 | Yellow_Toner.value = "$service_name_template$.perfdata.Yellow_Toner.value"
6 | Black_Toner.value = "$service_name_template$.perfdata.Black_Toner.value"
7 | Magenta_Toner.value = "$service_name_template$.perfdata.Magenta_Toner.value"
8 | Cyan_Toner.value = "$service_name_template$.perfdata.Cyan_Toner.value"
9 |
10 | [printer-consumables-colors.urlparams]
11 | areaAlpha = "0.5"
12 | yMin = "0"
13 | yMax = "100"
14 | yUnitSystem = "si"
15 | vtitle = " Percentage Left"
16 |
17 | [printer-consumables-colors.functions]
18 | Yellow_Toner.value = "alias(color($metric$, '#ffff00'), 'Yellow')"
19 | Black_Toner.value = "alias(color($metric$, '#000000'), 'Black')"
20 | Magenta_Toner.value = "alias(color($metric$, '#ff00ff'), 'Magenta')"
21 | Cyan_Toner.value = "alias(color($metric$, '#00ffff'), 'Cyan')"
22 |
23 | [printer-consumables-others.graph]
24 | check_command = "snmp_printer"
25 |
26 | [printer-consumables-others.metrics_filters]
27 | Transfer_Unit.value = "$service_name_template$.perfdata.Transfer_Unit.value"
28 | Fuser.value = "$service_name_template$.perfdata.Fuser.value"
29 | Color_Imaging_Kit.value = $service_name_template$.perfdata.Color_Imaging_Kit.value"
30 | Black_Imaging_Unit.value = $service_name_template$.perfdata.Black_Imaging_Unit.value"
31 | Document_Feeder_Kit.value = "$service_name_template$.perfdata.Document_Feeder_Kit.value"
32 | Maintenance_Kit.value = "$service_name_template$.perfdata.Maintenance_Kit.value"
33 | Clean_Rollers.value = "$service_name_template$.perfdata.Clean_Rollers.value"
34 | Puncher_Waste.value = "$service_name_template$.perfdata.Puncher_Waste.value"
35 | Saddle_Staples.value = "$service_name_template$.perfdata.Saddle_Staples.value"
36 | Staples.value = "$service_name_template$.perfdata.Staples.value"
37 | Stapler.value = "$service_name_template$.perfdata.Stapler.value"
38 |
39 | [printer-consumables-others.urlparams]
40 | areaAlpha = "0.5"
41 | yMin = "0"
42 | yMax = "100"
43 | yUnitSystem = "si"
44 | vtitle = " Percentage Left"
45 |
46 | [printer-consumables-others.functions]
47 | Transfer_Unit.value = "alias(color($metric$, '#49ba23'), 'Transfer Unit')"
48 | Fuser.value = "alias(color($metric$, '#ba8823'), 'Fuser')"
49 | Color_Imaging_Kit.value = "alias(color($metric$, '#c76fb6'), 'Color Imaging Kit')"
50 | Black_Imaging_Unit.value = "alias(color($metric$, '#000000'), 'Black Imaging Unit')"
51 | Document_Feeder_Kit.value = "alias(color($metric$, '#00008b'), 'Document Feeder Kit')"
52 | Maintenance_Kit.value = "alias(color($metric$, '#ba232a'), 'Maintenance Kit')"
53 | Clean_Rollers.value = "alias(color($metric$, '#2393ba'), 'Clean Rollers')"
54 | Puncher_Waste.value = "alias(color($metric$, '#ff99cc'), 'Puncher Waste')"
55 | Saddle_Staples.value = "alias(color($metric$, '#999966'), 'Saddle Staples')"
56 | Staples.value = "alias(color($metric$, '#996600'), 'Staples')"
57 | Stapler.value = "alias(color($metric$, '#996600'), 'Stapler')"
58 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # check_snmp_printer
2 | Nagios and Icinga Plugin for Checking SNMP Printer Status (Trays, Consumables and Pagecounts) which includes PerfData.
3 |
4 | ## 2.0.0 POSSIBLE CODE BREAKING UPDATE
5 |
6 | Must have Net-SNMP and its libraries installed. Can be compiled from source from www.net-snmp.org (latest version) or via package managers:
7 |
8 | Debian:
9 | ```
10 | sudo apt-get install snmp
11 | sudo apt-get install libsnmp-perl
12 | ```
13 |
14 | Centos/RHEL:
15 | ```
16 | sudo yum install net-snmp
17 | sudo yum install net-snmp-utils
18 | sudo yum install net-snmp-devel
19 | sudo yum install net-snmp-perl
20 | ```
21 |
22 | Supported Printer Models:
23 |
24 | * Canon
25 | * HP
26 | * Xerox
27 | * Ricoh
28 | * Brother
29 | * Lexmark
30 | * Kyocera
31 | * Olivetti
32 |
33 | __Your specific printer not supported? Open an issue on Github and we'll work to get it supported.__
34 |
35 | Forked and modified from Franky Van Liedekerke's 2014 version.
36 |
37 | **Consumables**
38 |
39 | 
40 |
41 | **Tray Status**
42 |
43 | 
44 |
45 | **Page Count**
46 |
47 | 
48 |
49 | ## Getting Started
50 |
51 | These instructions assume your Icinga2 is installed on a RHEL/CentOS system. You may need to modify slightly to work with other systems.
52 |
53 | ### Prerequisites
54 |
55 | Perl >= 5.10
56 |
57 | Net-SNMP and Libraries:
58 |
59 | Debian:
60 | ```
61 | sudo apt-get install snmp
62 | sudo apt-get install libsnmp-perl
63 | ```
64 |
65 | Centos/RHEL:
66 | ```
67 | sudo yum install net-snmp
68 | sudo yum install net-snmp-utils
69 | sudo yum install net-snmp-devel
70 | sudo yum install net-snmp-perl
71 | ```
72 |
73 | Nagios plugins installed and located in one of the following directories:
74 |
75 | ```
76 | /usr/lib/nagios/plugins
77 | /usr/lib64/nagios/plugins
78 | ```
79 |
80 | ### Installing
81 |
82 | Copy check_snmp_printer into your plugin directory and give it executable writes:
83 |
84 | ```
85 | sudo cp ./check_snmp_printer /usr/lib64/nagios/plugins/
86 | chmod a+x /usr/lib64/nagios/plugins/check_snmp_printer
87 | ```
88 |
89 | Copy printers.conf into plugins-contrib.d folder:
90 |
91 | ```
92 | sudo cp ./printers.conf /usr/share/icinga2/include/plugins-contrib.d/
93 | ```
94 | Append services-printers.conf to the end of your Icinga2 services.conf:
95 |
96 | ```
97 | cat ./services-printers.conf >> /etc/icinga2/conf.d/services.conf
98 | ```
99 |
100 | If using Graphite, copy graphite templates to Icinga2 Graphite template folder:
101 |
102 | ```
103 | sudo cp ./printer-consumables.ini /usr/share/icingaweb2/modules/graphite/templates/
104 | sudo cp ./printer-trays.ini /usr/share/icingaweb2/modules/graphite/templates/
105 | sudo cp ./printer-pagecount.ini /usr/share/icingaweb2/modules/graphite/templates/
106 | ```
107 |
108 | If using Grafana, import JSON Dashboard (Graphite or InfluxDB) file and add graph dashboard information into module making sure to name the Dashboard printer-metrics:
109 |
110 | 
111 |
112 | 
113 |
114 | ```
115 | sudo cat printer-metrics-graphs.ini >> /etc/icingaweb2/modules/grafana/graphs.ini
116 | ```
117 |
118 | Restart Icinga2:
119 |
120 | ```
121 | sudo systemctl restart icinga2
122 | ```
123 |
124 | ## Acknowledgments
125 |
126 | * Franky Van Liedekerke for porting Jason Leonard's initial BASH script to Perl.
127 | * Jason Leonard for writing the initial code that this was ultimately based upon.
128 |
--------------------------------------------------------------------------------
/printers.conf:
--------------------------------------------------------------------------------
1 |
2 | object CheckCommand "snmp_printer" {
3 | command = [ PluginDir + "/check_snmp_printer" ]
4 |
5 | arguments = {
6 | "-H" = {
7 | value = "$snmp_printer_hostname$"
8 | description = "IP or DNS of host."
9 | }
10 | "--messages" = {
11 | value = "$snmp_printer_messages$"
12 | description = "Print the messages of the printer."
13 | }
14 | "--model" = {
15 | value = "$snmp_printer_model$"
16 | description = "Prints the model of the printer"
17 | }
18 | "--pagecount" = {
19 | value = "$snmp_printer_pagecount$"
20 | description = "Prints the number of pages printed"
21 | }
22 | "--trays" = {
23 | value = "$snmp_printer_trays$"
24 | description = "Checks trays for paper status"
25 | }
26 | "--consum" = {
27 | value = "$snmp_printer_consum$"
28 | description = "Checks consumables for status"
29 | }
30 | "--metric" = {
31 | value = "$snmp_printer_metric$"
32 | description = "Changes to Metric system. (default: imperial)"
33 | }
34 | "--nofeeder" = {
35 | value = "$snmp_printer_nofeeder$"
36 | description = "Disables checking of the manual feeder tray"
37 | }
38 | "--nofuser" = {
39 | value = "$snmp_printer_nofuser$"
40 | description = "Disables checking of the fuser unit."
41 | }
42 | "--metric" = {
43 | value = "$snmp_printer_metric$"
44 | description = "Converts output to metric. Default: imperial."
45 | }
46 | "--ignoreoffline" = {
47 | value = "$snmp_printer_ignoreoffline$"
48 | description = "Ignores timeouts and sets OK status for powered off printers."
49 | }
50 | "-C" = {
51 | value = "$snmp_printer_community$"
52 | description = "The community string of the SNMP agent. (default: public)"
53 | }
54 | "-v" = {
55 | value = "$snmp_printer_snmpver$"
56 | description = "The version of SNMP to use. 1 and 2 are supported. (default: 1)"
57 | }
58 | "-w" = {
59 | value = "$snmp_printer_warning$"
60 | description = "The warning limit level to alert on. (default: 20)"
61 | }
62 | "-c" = {
63 | value = "$snmp_printer_critical$"
64 | description = "The critical limit level to alert on. (default: 5)"
65 | }
66 | "-t" = {
67 | value = "$snmp_printer_timeout$"
68 | description = "The number of seconds to wait for a response."
69 | }
70 | "-r" = {
71 | value = "$snmp_printer_retries$"
72 | description = "The number of retries to attempt."
73 | }
74 | "-u" = {
75 | value = "$snmp_printer_user$"
76 | description = "User for SNMPv3 authentication."
77 | }
78 | "-A" = {
79 | value = "$snmp_printer_authpass$"
80 | description = "SNMPv3 authentication password."
81 | }
82 | "-a" = {
83 | value = "$snmp_printer_authproto$"
84 | description = "SNMPv3 authentication protocol."
85 | }
86 | "-X" = {
87 | value = "$snmp_printer_privpass$"
88 | description = "SNMPv3 privacy password."
89 | }
90 | "-x" = {
91 | value = "$snmp_printer_privproto$"
92 | description = "SNMPv3 privacy protocol."
93 | }
94 | "-y" = {
95 | value = "$snmp_printer_authkey$"
96 | description = "SNMPv3 authentication key."
97 | }
98 | "-z" = {
99 | value = "$snmp_printer_privkey$"
100 | description = "SNMPv3 privacy key."
101 | }
102 | "-n" = {
103 | value = "$snmp_printer_contextname$"
104 | description = "Contextname for SNMPv3."
105 | }
106 | "-l" = {
107 | value = "$snmp_printer_lang$"
108 | description = "Change ouput language. Available: English.."
109 | }
110 | }
111 |
112 | vars.snmp_printer_hostname = {{
113 | var addr_v4 = macro("$address$")
114 | var addr_v6 = macro("$address6$")
115 |
116 | if (addr_v4) {
117 | return addr_v4
118 | } else {
119 | return "udp6:[" + addr_v6 + "]"
120 | }
121 | }}
122 | vars.snmp_printer_community = "public"
123 | vars.snmp_printer_snmpver = "1"
124 | vars.snmp_printer_retries = "3"
125 | }
126 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 |
2 | # [2.0.1](https://github.com/Tylan/check_snmp_printer/compare/v2.0.0...v2.0.1) (2023-03-28)
3 |
4 | ### Features
5 |
6 | * Added option to disable CRITICAL alerts on timeouts for printers that may be regularly powered off (Issue #31)
7 |
8 | ### Bug Fixes
9 |
10 | * Toned down the max limit on the bulkwalk as the high amount was not necessary (Issue #31)
11 |
12 | ### Other Fixes
13 |
14 | * Removed Waste Cartridge from reporting
15 | * Adjusted "[Color] Imaging Unit" output to strip off Printer model and part numbers
16 |
17 |
18 | # [2.0.0](https://github.com/Tylan/check_snmp_printer/compare/v1.3.1...v2.0.0) (2023-03-24)
19 |
20 | ### Features
21 |
22 | * Revamped SNMP code to now use Net-SNMP vs Net::SNMP due to limitations and quirkiness of Net::SNMP
23 | * Updated printers.conf
24 | * Added a new switch to check firmware revision and when able the firmware date and when it was installed (printer specific).
25 |
26 | ### Bug Fixes
27 | * Fixed issue where sometimes --nofeeder wasn't removing the correct tray (Issue #30)
28 | * Fixed Lexmark Model output so it excludes the Serial and Firmware revision as those are displayed elsewhere.
29 |
30 |
31 | # [1.3.1](https://github.com/Tylan/check_snmp_printer/compare/v1.3.0...v1.3.1) (2022-09-27)
32 |
33 | ### Features
34 |
35 | * Added support for printers that have German or French text in their OID output
36 |
37 | ### Bug Fixes
38 | * Added decoding of hex SNMP results. (Issue #26)
39 | * Fixed issue with disabling criticals and/or warnings for tray status. (Issue #18)
40 | * Fixed sorting of output from --messages. (Issue #28)
41 |
42 |
43 | # [1.3.0](https://github.com/Tylan/check_snmp_printer/compare/v1.2.3...v1.3.0) (2021-09-24)
44 |
45 | ### Features
46 |
47 | * Added SNMPv3 support
48 | * Added --nofuser option to remove reporting on the Fuser
49 |
50 | ### Other Fixes
51 | * Added support for more Kyocera toners
52 |
53 | # [1.2.3](https://github.com/Tylan/check_snmp_printer/compare/v1.2.2...v1.2.3) (2020-10-14)
54 |
55 | ### Bug Fixes
56 | * Fixed output for --messages option so it will display for more devices.
57 |
58 | ### Features
59 | * Added German word niedrig to warning list on messages output
60 |
61 |
62 | # [1.2.2](https://github.com/Tylan/check_snmp_printer/compare/v1.2.1...v1.2.2) (2020-09-06)
63 |
64 | ### Features
65 |
66 | * Added support for Kyocera printers
67 | * Added support for Lexmark printers
68 | * Changed perfdata to display percentage for paper tray output. If it cannot accurate determine a percentage it is statically set based upon further inspection from other OID sources.
69 |
70 | ### Bug Fixes
71 | * Fixed the --nofeeder option as it was removing Tray 1 even though it was not a feeder tray in some circumstances.
72 |
73 | ### Other Fixes
74 |
75 | * Slight verbage change to some outputs
76 |
77 | # [1.2.1](https://github.com/Tylan/check_snmp_printer/compare/v1.2.0...v1.2.1) (2020-08-03)
78 |
79 | ### Bug Fixes
80 |
81 | * Fixed Brother consumable reporting as it was not reporting correctly - it is now OK or NOT OK due to OID restrictions
82 |
83 | ### Features
84 |
85 | * Added WARNING and CRITICAL states based on certain printer messages with the messages option
86 |
87 | # [1.2.0](https://github.com/Tylan/check_snmp_printer/compare/v1.1.4...v1.2.0) (2020-07-15)
88 |
89 | ### Bug Fixes
90 |
91 | * Added library check for /usr/lib/nagios/plugins folder to support Debian systems
92 | * Fixed typo in OID lookup for serial number
93 | * Fixed it so you can disable tray status warning and critical messages by setting their value to 0
94 |
95 | ### Features
96 |
97 | * Added support for Ricoh printers
98 | * Added support for Brother printers
99 | * Added the ability to disable checking of the manual feed tray
100 |
101 |
102 | # [1.1.4](https://github.com/Tylan/check_snmp_printer/compare/v1.1.3...v1.1.4) (2020-01-21)
103 |
104 | ### Bug Fixes
105 |
106 | * Fixed check for HP devices that have Image Transfer and Image Fuser Kits
107 | * Some HP printers output Tray as TRAY - corrected this on plugin output
108 | * Some older printers would occasionally report an SNMP genError. Wrote a retry subroutine for this scenario
109 |
110 | ### Performance Improvements
111 |
112 | * Search print model name first by converting to lowercase compatibility
113 |
114 | ### Features
115 |
116 | * Added a retries option to allow for retries before timing out - defaults to 3 retries
117 | * Added consumable support for Olivetti printers
118 |
119 |
120 | # [1.1.3](https://github.com/Tylan/check_snmp_printer/compare/v1.1.2...v1.1.3) (2020-01-20)
121 |
122 | ### Bug Fixes
123 |
124 | * Fixed Tray status for some newer HP MFPs
125 |
126 | ### Performance Improvements
127 |
128 | * Changed code for tray size to do equations based upon specific OID outputs to determine in or mm values
129 | * Converted to hash arrays for OID variables
130 |
131 | ### Features
132 |
133 | * Changed pagecount to measure total B&W and total Color separately with corresponding graph modifications
134 |
135 |
136 |
137 |
138 | # [1.1.2](https://github.com/Tylan/check_snmp_printer/compare/v1.1.1...v1.1.2) (2020-01-13)
139 |
140 |
141 | ### Performance Improvements
142 |
143 | * Replaced given/when code with if/else statements for better compatibility
144 |
145 |
146 |
147 |
148 | # [1.1.1](https://github.com/Tylan/check_snmp_printer/compare/v1.1.0...v1.1.1) (2020-01-13)
149 |
150 |
151 | ### Features
152 |
153 | * Fixed a bug with HP Color LaserJet Pro M454dw toner not reporting correctly when levele are really low
154 | * Compensated for HP Color LaserJet Pro M454dw OID .1.3.6.1.2.1.43.11.1.1.6.1 which has Magenta typo'd
155 |
156 |
157 |
158 |
159 | # [1.1.0](https://github.com/Tylan/check_snmp_printer/compare/v1.0.3...v1.1.1) (2020-01-13)
160 |
161 |
162 | ### Features
163 |
164 | * Added support for a couple more paper sizes
165 | * Added support for more consumables (Stapler, Staples, Saddle Staples and Puncher Waste)
166 | * Sorted display results so that CRITICAL are shown first then WARNING followed by OK
167 |
168 | ### Performance Improvements
169 |
170 | * Fixed display output for non measurable toners
171 | * Cleaned up code
172 |
173 |
174 |
175 |
176 | # [1.0.3](https://github.com/Tylan/check_snmp_printer/compare/v1.0.2...v1.0.3) (2019-12-26)
177 |
178 | ### Features
179 |
180 | * Added graph support for Grafana
181 |
182 |
183 | # [1.0.2](https://github.com/Tylan/check_snmp_printer/compare/v1.0.1...v1.0.2) (2019-05-27)
184 |
185 |
186 | ### Bug Fixes
187 |
188 | * Fixed Canon consumable output display
189 | * Fixed consumable critical detection alerts
190 |
191 | ### Features
192 |
193 | * Added perfdata for Pagecount
194 |
195 | ### Performance Improvements
196 |
197 | * Changed plugin newline output from \
to \n
198 |
199 |
200 |
201 |
202 | # [1.0.1](https://github.com/Tylan/check_snmp_printer/compare/v1.0.0...v1.0.1) (2019-05-02)
203 |
204 | ### Bug Fixes
205 |
206 | * Fixed default SNMP version
207 |
208 |
209 |
210 |
211 | # [1.0.0] (Initial Release) (2019-05-01)
212 |
213 | * Forked from Franky Van Liedekerke version
214 |
215 | ### Bug Fixes
216 |
217 | * Fixed status changes to properly work with Icinga
218 |
219 | ### Performance Improvements
220 |
221 | * Made consumables and trays all or nothing for simplicity
222 | * Added perfdata collection for consumables
223 | * Added support for metric system output
224 | * Better formated output strings
225 |
--------------------------------------------------------------------------------
/printer-metrics-graphite.json:
--------------------------------------------------------------------------------
1 | {
2 | "__inputs": [
3 | {
4 | "name": "DS_GRAPHITE",
5 | "label": "Graphite",
6 | "description": "",
7 | "type": "datasource",
8 | "pluginId": "graphite",
9 | "pluginName": "Graphite"
10 | }
11 | ],
12 | "__requires": [
13 | {
14 | "type": "grafana",
15 | "id": "grafana",
16 | "name": "Grafana",
17 | "version": "6.7.2"
18 | },
19 | {
20 | "type": "panel",
21 | "id": "graph",
22 | "name": "Graph",
23 | "version": ""
24 | },
25 | {
26 | "type": "datasource",
27 | "id": "graphite",
28 | "name": "Graphite",
29 | "version": "1.0.0"
30 | }
31 | ],
32 | "annotations": {
33 | "list": [
34 | {
35 | "$$hashKey": "object:456",
36 | "builtIn": 1,
37 | "datasource": "-- Grafana --",
38 | "enable": true,
39 | "hide": true,
40 | "iconColor": "rgba(0, 211, 255, 1)",
41 | "name": "Annotations & Alerts",
42 | "type": "dashboard"
43 | }
44 | ]
45 | },
46 | "editable": true,
47 | "gnetId": null,
48 | "graphTooltip": 0,
49 | "id": null,
50 | "iteration": 1599495748114,
51 | "links": [],
52 | "panels": [
53 | {
54 | "aliasColors": {
55 | "Black-and-White": "#000000",
56 | "Color": "#60f7c5"
57 | },
58 | "bars": false,
59 | "dashLength": 10,
60 | "dashes": false,
61 | "datasource": "${DS_GRAPHITE}",
62 | "fill": 0,
63 | "fillGradient": 0,
64 | "gridPos": {
65 | "h": 8,
66 | "w": 12,
67 | "x": 0,
68 | "y": 0
69 | },
70 | "hiddenSeries": false,
71 | "id": 3,
72 | "legend": {
73 | "avg": false,
74 | "current": false,
75 | "max": false,
76 | "min": false,
77 | "show": true,
78 | "total": false,
79 | "values": false
80 | },
81 | "lines": true,
82 | "linewidth": 1,
83 | "nullPointMode": "connected",
84 | "options": {
85 | "dataLinks": []
86 | },
87 | "percentage": false,
88 | "pointradius": 2,
89 | "points": false,
90 | "renderer": "flot",
91 | "seriesOverrides": [],
92 | "spaceLength": 10,
93 | "stack": false,
94 | "steppedLine": false,
95 | "targets": [
96 | {
97 | "refId": "A",
98 | "target": "aliasByNode(icinga2.$hostname.services.$service.snmp_printer.perfdata.*.value, 6)"
99 | }
100 | ],
101 | "thresholds": [],
102 | "timeFrom": null,
103 | "timeRegions": [],
104 | "timeShift": null,
105 | "title": "$service",
106 | "tooltip": {
107 | "shared": true,
108 | "sort": 0,
109 | "value_type": "individual"
110 | },
111 | "type": "graph",
112 | "xaxis": {
113 | "buckets": null,
114 | "mode": "time",
115 | "name": null,
116 | "show": true,
117 | "values": []
118 | },
119 | "yaxes": [
120 | {
121 | "format": "short",
122 | "label": null,
123 | "logBase": 1,
124 | "max": null,
125 | "min": null,
126 | "show": true
127 | },
128 | {
129 | "format": "short",
130 | "label": null,
131 | "logBase": 1,
132 | "max": null,
133 | "min": null,
134 | "show": true
135 | }
136 | ],
137 | "yaxis": {
138 | "align": false,
139 | "alignLevel": null
140 | }
141 | },
142 | {
143 | "aliasColors": {
144 | "Drawer_1": "#ff9700",
145 | "Drawer_2": "#8900ff",
146 | "Drawer_3": "#ff002f",
147 | "Drawer_4": "#34ff00",
148 | "MP_Tray": "#00ffbd",
149 | "Manual_Envelope": "#00ffbd",
150 | "Manual_Paper": "#00ffbd",
151 | "Mp_Tray": "#00ffbd",
152 | "Multi-purpose_Tray": "#00ffbd",
153 | "Stack_Bypass": "#00ffbd",
154 | "Tray_1": "#ff9700",
155 | "Tray_2": "#8900ff",
156 | "Tray_3": "#ff002f",
157 | "Tray_4": "#34ff00"
158 | },
159 | "bars": false,
160 | "dashLength": 10,
161 | "dashes": false,
162 | "datasource": "${DS_GRAPHITE}",
163 | "fill": 0,
164 | "fillGradient": 0,
165 | "gridPos": {
166 | "h": 8,
167 | "w": 12,
168 | "x": 0,
169 | "y": 8
170 | },
171 | "hiddenSeries": false,
172 | "id": 2,
173 | "legend": {
174 | "avg": false,
175 | "current": false,
176 | "max": false,
177 | "min": false,
178 | "show": true,
179 | "total": false,
180 | "values": false
181 | },
182 | "lines": true,
183 | "linewidth": 1,
184 | "nullPointMode": "connected",
185 | "options": {
186 | "dataLinks": []
187 | },
188 | "percentage": false,
189 | "pointradius": 2,
190 | "points": false,
191 | "renderer": "flot",
192 | "seriesOverrides": [],
193 | "spaceLength": 10,
194 | "stack": false,
195 | "steppedLine": false,
196 | "targets": [
197 | {
198 | "refId": "A",
199 | "target": "aliasByNode(icinga2.$hostname.services.$service.snmp_printer.perfdata.*.value, 6)"
200 | }
201 | ],
202 | "thresholds": [],
203 | "timeFrom": null,
204 | "timeRegions": [],
205 | "timeShift": null,
206 | "title": "$service",
207 | "tooltip": {
208 | "shared": true,
209 | "sort": 0,
210 | "value_type": "individual"
211 | },
212 | "type": "graph",
213 | "xaxis": {
214 | "buckets": null,
215 | "mode": "time",
216 | "name": null,
217 | "show": true,
218 | "values": []
219 | },
220 | "yaxes": [
221 | {
222 | "format": "short",
223 | "label": null,
224 | "logBase": 1,
225 | "max": null,
226 | "min": null,
227 | "show": true
228 | },
229 | {
230 | "format": "short",
231 | "label": null,
232 | "logBase": 1,
233 | "max": null,
234 | "min": null,
235 | "show": true
236 | }
237 | ],
238 | "yaxis": {
239 | "align": false,
240 | "alignLevel": null
241 | }
242 | },
243 | {
244 | "aliasColors": {
245 | "Black_Imaging_Unit": "#000000",
246 | "Black_Toner": "rgb(0, 0, 0)",
247 | "Clean_Rollers": "#2393ba",
248 | "Color_Imaging_Kit": "#c76fb6",
249 | "Cyan_Toner": "rgb(57, 223, 234)",
250 | "Document_Feeder_Kit": "dark-blue",
251 | "Fuser": "#ba8823",
252 | "Gelb_Toner": "yellow",
253 | "Magenta_Toner": "rgb(192, 20, 194)",
254 | "Maintenance_Kit": "#ba232a",
255 | "Puncher_Waste": "#ff99cc",
256 | "Saddle_Staples": "#999966",
257 | "Schwarz_Toner": "rgb(0, 0, 0)",
258 | "Stapler": "#996600",
259 | "Staples": "#996600",
260 | "Transfer_Unit": "#49ba23",
261 | "Yellow_Toner": "yellow"
262 | },
263 | "bars": false,
264 | "dashLength": 10,
265 | "dashes": false,
266 | "datasource": "${DS_GRAPHITE}",
267 | "fill": 0,
268 | "fillGradient": 0,
269 | "gridPos": {
270 | "h": 8,
271 | "w": 12,
272 | "x": 0,
273 | "y": 16
274 | },
275 | "hiddenSeries": false,
276 | "id": 1,
277 | "legend": {
278 | "avg": false,
279 | "current": false,
280 | "max": false,
281 | "min": false,
282 | "show": true,
283 | "total": false,
284 | "values": false
285 | },
286 | "lines": true,
287 | "linewidth": 1,
288 | "nullPointMode": "connected",
289 | "options": {
290 | "dataLinks": []
291 | },
292 | "percentage": false,
293 | "pointradius": 2,
294 | "points": false,
295 | "renderer": "flot",
296 | "seriesOverrides": [],
297 | "spaceLength": 10,
298 | "stack": false,
299 | "steppedLine": false,
300 | "targets": [
301 | {
302 | "refId": "A",
303 | "target": "aliasByNode(icinga2.$hostname.services.$service.snmp_printer.perfdata.*.value, 6)",
304 | "textEditor": false
305 | }
306 | ],
307 | "thresholds": [],
308 | "timeFrom": null,
309 | "timeRegions": [],
310 | "timeShift": null,
311 | "title": "$service",
312 | "tooltip": {
313 | "shared": true,
314 | "sort": 0,
315 | "value_type": "individual"
316 | },
317 | "type": "graph",
318 | "xaxis": {
319 | "buckets": null,
320 | "mode": "time",
321 | "name": null,
322 | "show": true,
323 | "values": []
324 | },
325 | "yaxes": [
326 | {
327 | "format": "short",
328 | "label": null,
329 | "logBase": 1,
330 | "max": null,
331 | "min": null,
332 | "show": true
333 | },
334 | {
335 | "format": "short",
336 | "label": null,
337 | "logBase": 1,
338 | "max": null,
339 | "min": null,
340 | "show": true
341 | }
342 | ],
343 | "yaxis": {
344 | "align": false,
345 | "alignLevel": null
346 | }
347 | }
348 | ],
349 | "schemaVersion": 22,
350 | "style": "dark",
351 | "tags": [],
352 | "templating": {
353 | "list": [
354 | {
355 | "allValue": null,
356 | "current": {},
357 | "datasource": "${DS_GRAPHITE}",
358 | "definition": "icinga2.*",
359 | "hide": 0,
360 | "includeAll": false,
361 | "index": -1,
362 | "label": null,
363 | "multi": false,
364 | "name": "hostname",
365 | "options": [],
366 | "query": "icinga2.*",
367 | "refresh": 1,
368 | "regex": "",
369 | "skipUrlSync": false,
370 | "sort": 0,
371 | "tagValuesQuery": "",
372 | "tags": [],
373 | "tagsQuery": "",
374 | "type": "query",
375 | "useTags": false
376 | },
377 | {
378 | "allValue": null,
379 | "current": {},
380 | "datasource": "${DS_GRAPHITE}",
381 | "definition": "icinga2.$hostname.services.*",
382 | "hide": 0,
383 | "includeAll": false,
384 | "index": -1,
385 | "label": null,
386 | "multi": false,
387 | "name": "service",
388 | "options": [],
389 | "query": "icinga2.$hostname.services.*",
390 | "refresh": 1,
391 | "regex": "",
392 | "skipUrlSync": false,
393 | "sort": 0,
394 | "tagValuesQuery": "",
395 | "tags": [],
396 | "tagsQuery": "",
397 | "type": "query",
398 | "useTags": false
399 | },
400 | {
401 | "allValue": null,
402 | "current": {},
403 | "datasource": "${DS_GRAPHITE}",
404 | "definition": "icinga2.$hostname.*.*",
405 | "hide": 0,
406 | "includeAll": false,
407 | "index": -1,
408 | "label": null,
409 | "multi": false,
410 | "name": "command",
411 | "options": [],
412 | "query": "icinga2.$hostname.*.*",
413 | "refresh": 1,
414 | "regex": "",
415 | "skipUrlSync": false,
416 | "sort": 0,
417 | "tagValuesQuery": "",
418 | "tags": [],
419 | "tagsQuery": "",
420 | "type": "query",
421 | "useTags": false
422 | }
423 | ]
424 | },
425 | "time": {
426 | "from": "now-6h",
427 | "to": "now"
428 | },
429 | "timepicker": {
430 | "refresh_intervals": [
431 | "5s",
432 | "10s",
433 | "30s",
434 | "1m",
435 | "5m",
436 | "15m",
437 | "30m",
438 | "1h",
439 | "2h",
440 | "1d"
441 | ]
442 | },
443 | "timezone": "",
444 | "title": "printer-metrics-graphite",
445 | "uid": "Q47JmGLWz",
446 | "variables": {
447 | "list": []
448 | },
449 | "version": 53
450 | }
451 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/check_snmp_printer:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #########################################################
3 | # #
4 | # #
5 | # SNMP Printer Check Plugin #
6 | # for #
7 | # Icinga / Nagios #
8 | # #
9 | # Version 2.0.1 (April 5, 2023) #
10 | # by Bob McLoughlin #
11 | # E-mail: rmcloughlin@outlook.com #
12 | # #
13 | # #
14 | # Based on: #
15 | # check_snmp_printer (Perl) #
16 | # Version 1.6 (September 08, 2014) #
17 | # ( by Franky Van Liedekerke #
18 | # E-mail: liedekef@telenet.be ) #
19 | # #
20 | # Which was further based on: #
21 | # check_snmp_printer.sh #
22 | # Version 1.5 (January 15, 2010) #
23 | # ( by Jason Leonard #
24 | # E-mail: jason_leonard@yahoo.com ) #
25 | # #
26 | # Version History #
27 | # - Refer to CHANGELOG.md #
28 | # #
29 | # Like the original, this plugin is distributed #
30 | # under the GNU GPL license. You may re-destribute only #
31 | # according to the terms of the GNU GPL. #
32 | # #
33 | #########################################################
34 | #########################################################
35 | # #
36 | # DEPENDS On #
37 | # SNMP installed (http://www.net-snmp.org/ #
38 | # Nagios plugins installed #
39 | # #
40 | #########################################################
41 |
42 | use strict;
43 | use lib qw ( /usr/local/nagios/libexec /usr/lib/nagios/plugins /usr/lib64/nagios/plugins );
44 | use utils qw( %ERRORS $TIMEOUT &print_revision &support &usage );
45 | use SNMP;
46 | use Getopt::Long;
47 | use Data::Dumper;
48 |
49 | # globals
50 | use vars qw(
51 | $PROGNAME $VERSION %procs $snmp $errstr $oid
52 | $opt_version $opt_help $opt_timeout $opt_retries $opt_host
53 | $opt_community $opt_snmpver $opt_warning $opt_critical
54 | $opt_messages $opt_model $opt_consum $opt_tray $opt_pagecount
55 | $opt_metric $opt_nofeeder $opt_nofuser $opt_user $opt_authpass
56 | $opt_authkey $opt_authproto $opt_privkey $opt_privpass
57 | $opt_privproto $opt_contextname $opt_lang $opt_firmware
58 | $opt_ignoffline
59 | );
60 | my (@consumables,@status,@trays,@strays,@percentages,@mresults,@message,@measurables);
61 | my ($state,$statuscode,$EXITSTRING,$snmpcmds);
62 | my ($i,$tcount,$scount,$traynumber,$cnumber,$mnumber,$critcount,$warncount) = 0;
63 |
64 | my %STATUS_CODE =
65 | ( 'UNKNOWN' => '3', 'OK' => '0', 'WARNING' => '1', 'CRITICAL' => '2' );
66 |
67 | # config
68 | $PROGNAME = $0;
69 | $VERSION = '2.0.1';
70 |
71 | # init options
72 | $opt_version = undef;
73 | $opt_help = undef;
74 | $opt_timeout = $TIMEOUT;
75 | $opt_retries = 3;
76 | $opt_host = undef;
77 | $opt_community = 'public';
78 | $opt_snmpver = 1;
79 | $opt_warning = 20; # warning percentage: if lower: warning
80 | $opt_critical = 5; # critical percentage: if lower: critical
81 | $opt_messages = undef;
82 | $opt_model = undef;
83 | $opt_consum = undef;
84 | $opt_tray = undef;
85 | $opt_pagecount = undef;
86 | $opt_metric = undef;
87 | $opt_user = undef;
88 | $opt_authpass = undef;
89 | $opt_authproto = undef;
90 | $opt_authkey = undef;
91 | $opt_privpass = undef;
92 | $opt_privproto = undef;
93 | $opt_privkey = undef;
94 | $opt_contextname = undef;
95 | $opt_lang = undef;
96 | $opt_firmware = undef;
97 | $opt_ignoffline = undef;
98 |
99 | # get options
100 | Getopt::Long::Configure('bundling');
101 | GetOptions(
102 | 'V|version' => \$opt_version,
103 | 'h|help' => \$opt_help,
104 | 't|timeout=i' => \$opt_timeout,
105 | 'r|retries=i' => \$opt_retries,
106 | 'H|host=s' => \$opt_host,
107 | 'C|community=s' => \$opt_community,
108 | 'v|snmpver=s' => \$opt_snmpver,
109 | 'w|warning=i' => \$opt_warning,
110 | 'c|critical=i' => \$opt_critical,
111 | 'messages' => \$opt_messages,
112 | 'model' => \$opt_model,
113 | 'consum' => \$opt_consum,
114 | 'trays' => \$opt_tray,
115 | 'pagecount' => \$opt_pagecount,
116 | 'nofeeder' => \$opt_nofeeder,
117 | 'nofuser' => \$opt_nofuser,
118 | 'metric' => \$opt_metric,
119 | 'firmware' => \$opt_firmware,
120 | 'ignoreoffline' => \$opt_ignoffline,
121 | 'u|user=s' => \$opt_user,
122 | 'A|authpass=s' => \$opt_authpass,
123 | 'a|authproto=s' => \$opt_authproto,
124 | 'y|authkey=s' => \$opt_authkey,
125 | 'X|privpass=s' => \$opt_privpass,
126 | 'x|privproto=s' => \$opt_privproto,
127 | 'z|privkey=s' => \$opt_privkey,
128 | 'n|contextname=s' => \$opt_contextname,
129 | 'l|lang=s' => \$opt_lang
130 | ) or do {
131 | print_usage();
132 | exit($ERRORS{'UNKNOWN'});
133 | };
134 |
135 | if ($opt_version) {
136 | print_version();
137 | exit($ERRORS{'UNKNOWN'});
138 | }
139 |
140 | if ($opt_help) {
141 | print_help();
142 | exit($ERRORS{'UNKNOWN'});
143 | }
144 |
145 | if (!$opt_host) {
146 | print "Host option not given\n";
147 | print_usage();
148 | exit($ERRORS{'UNKNOWN'});
149 | }
150 |
151 | if ($opt_lang) {
152 | if ($opt_lang =~ m/English|english/) {
153 | $opt_lang = lc ($opt_lang);
154 | } else {
155 | print "Translation to $opt_lang not supported at this time.\n";
156 | print "Available languages: English\n";
157 | exit($ERRORS{'UNKNOWN'});
158 | }
159 | }
160 |
161 | # only use one of messages|model|consum|tray|pagecount|firmware options
162 | my $count=0;
163 | ($opt_messages) && ($count++);
164 | ($opt_model) && ($count++);
165 | ($opt_consum) && ($count++);
166 | (defined($opt_tray)) && ($count++);
167 | ($opt_pagecount) && ($count++);
168 | ($opt_firmware) && ($count++);
169 | if ($count>1) {
170 | print "Only use one of messages|model|consum|trays|pagecount|firmware options\n";
171 | print_help();
172 | exit($ERRORS{'UNKNOWN'});
173 | }
174 | if ($count<1) {
175 | print "Only use one of messages|model|consum|trays|pagecount|firmware options\n";
176 | print_help();
177 | exit($ERRORS{'UNKNOWN'});
178 | }
179 |
180 | sub print_usage {
181 | my $tab = ' ' x length($PROGNAME);
182 | print <get([$oid]);
271 | if ($MODEL =~ /(Lexmark \w+) (\w+) (\w+\.\w+\.\w+)/ ) { $MODEL = $1; $SERIAL = $2; }
272 | if ($snmp->{ErrorStr}) {
273 | if ($snmp->{ErrorStr} =~ m/Timeout/ and ($opt_ignoffline)) {
274 | stop("OK - Printer offline and check was ignored.", 'OK');
275 | } else {
276 | stop("CRITICAL - $snmp->{ErrorStr}", 'CRITICAL');
277 | }
278 | }
279 | if ($pcheck == 2) { return lc $MODEL; }
280 | }
281 | if ($pcheck == 1) {
282 | if (!$MODEL =~ m/Lexmark/) {
283 | $oid=".1.3.6.1.2.1.43.5.1.1.17.1";
284 | $SERIAL=$snmp->get([$oid]);
285 | $SERIAL =~ s/\"//g;
286 | }
287 | print "$MODEL, Serial # $SERIAL\n";
288 | }
289 | }
290 |
291 | sub check_messages {
292 | my ($mcheck) = @_;
293 | my ($oid,$result,$model,$mcount);
294 | my @mresults;
295 | my $k = 0;
296 | my $MESSAGES = "";
297 |
298 | $model = check_model(2);
299 | if ($model =~ m/hp/) {
300 | $oid=".1.3.6.1.4.1.11.2.3.9.1.1.3";
301 | } else {
302 | $oid=".1.3.6.1.2.1.43.16";
303 | }
304 |
305 | my @result = $snmp->bulkwalk(0, 10, $oid);
306 | for my $key (@result) {
307 | for my $v (@$key) {
308 | push @{ $mresults[$k] }, $v->[0], $v->[2];
309 | }
310 | $k++;
311 | }
312 | $k = 0;
313 | @mresults = sort { $a->[0] cmp $b->[0] } @mresults;
314 | $mcount = (scalar @mresults);
315 | while ($mcount > 0) {
316 | if ($mresults[$k][1] ne "") {
317 | $MESSAGES .= "$mresults[$k][1]";
318 | if ($mcount > 1) {
319 | $MESSAGES .= " / ";
320 | }
321 | }
322 | $mcount--;
323 | $k++;
324 | }
325 |
326 | chomp $MESSAGES;
327 | if ((substr $MESSAGES, -3) eq " / ") { $MESSAGES =~ s/.{3}$//; }
328 |
329 | if ($MESSAGES eq "") {
330 | $MESSAGES= "(Can't determine messages)";
331 | }
332 | if ($mcheck == 2) { return $MESSAGES; }
333 | my @messages = split('\n',$MESSAGES);
334 | foreach my $message (@messages) {
335 | $message = lc $message;
336 | if ($message =~ m/toner low|wenig toner|cartridge low|niedrig|attention|reorder/) {
337 | $state = "WARNING";
338 | }
339 | elsif ($message =~ m/replace toner|toner ersetzen|error|paper is out/) {
340 | $state = "CRITICAL";
341 | } else { $state = "OK"; }
342 | push @{ $status[$mnumber] }, $state;
343 | $mnumber++;
344 | }
345 | print "$MESSAGES\n";
346 | }
347 |
348 | sub check_firmware {
349 | use Time::Piece;
350 | use Time::Seconds;
351 | my ($ldy, $dt);
352 |
353 | my ($model,$fwdate,$fwrev,$fwupg,$fwinst);
354 | $model = check_model(2);
355 |
356 | if ($model =~ m/hp/) {
357 | $fwdate = $snmp->get(['.1.3.6.1.4.1.11.2.3.9.4.2.1.1.3.5.0']);
358 | $fwrev = $snmp->get(['.1.3.6.1.4.1.11.2.3.9.4.2.1.1.3.6.0']);
359 | } elsif ($model =~ m/xerox/) {
360 | (localtime->yy) =~ /\d(\d)/;
361 | my $ldy = $1;
362 | $fwrev = $snmp->get(['.1.3.6.1.2.1.25.6.3.1.2.2']);
363 | chomp($fwupg = `snmpget $snmpcmds .1.3.6.1.2.1.25.6.3.1.5.2`);
364 | if ( $fwrev =~ /(\d+\.\d+\.\d+\.\d+)/ ) { $fwrev = $1; }
365 | if ( $fwrev =~ /(\d)\.(\d\d\d)\d\d/ ) {
366 | if ($1 gt $ldy) {
367 | $dt = Time::Piece->strptime( "201" . $1 . "0101", '%Y%m%d');
368 | } else {
369 | $dt = Time::Piece->strptime( "202" . $1 . "0101", '%Y%m%d');
370 | }
371 | $dt += ONE_DAY * $2;
372 | $fwdate = $dt->strftime('%Y%m%d');
373 | }
374 | if ( $fwupg =~ /(\d+-\d+-\d+)\,(\d+:\d+:\d+)/ ) { $fwinst = "Installed on: $1 at $2\n"; }
375 | } elsif ($model =~ m/kyocera|ecosys|taskalfa|4200dn/) {
376 | $fwrev = $snmp->get(['.1.3.6.1.4.1.1347.43.5.4.1.5.1.1']);
377 | } elsif ($model =~ m/canon/) {
378 | $fwrev = $snmp->get(['.1.3.6.1.4.1.1602.1.1.1.4.0']);
379 | } elsif ($model =~ m/lexmark/) {
380 | $fwrev = $snmp->get(['.1.3.6.1.2.1.25.3.2.1.3.1']);
381 | if ($fwrev =~ /Lexmark \w+ \w+ (\w+)\.(\w+)\.(\w+)/ ) { $fwrev = "$1.$2.$3"; }
382 | if ($1 eq "LW20") { $fwdate = "August 2013"; }
383 | if ($1 eq "LW30") { $fwdate = "March 2014"; }
384 | if ($1 eq "LW40") { $fwdate = "July 2014"; }
385 | if ($1 eq "LW41") { $fwdate = "May 2015"; }
386 | if ($1 eq "LW50") { $fwdate = "April 2015"; }
387 | if ($1 eq "LW60") { $fwdate = "February 2016"; }
388 | if ($1 eq "LW62") { $fwdate = "November 2016"; }
389 | if ($1 eq "LW63") { $fwdate = "August 2017"; }
390 | if ($1 eq "LW70") { $fwdate = "June 2018"; }
391 | if ($1 eq "LW71") { $fwdate = "October 2018"; }
392 | if ($1 eq "LW72") { $fwdate = "May 2019"; }
393 | if ($1 eq "LW73") { $fwdate = "August 2019"; }
394 | if ($1 eq "LW74") { $fwdate = "December 2019"; }
395 | if ($1 eq "LW75") { $fwdate = "March 2020"; }
396 | if ($1 eq "LW80") { $fwdate = "January 2022"; }
397 | } elsif ($model =~ m/ricoh/) {
398 | $fwrev = $snmp->get(['.1.3.6.1.4.1.367.3.2.1.2.20.1.2.1.1']);
399 | }
400 | if (!$fwrev) { $EXITSTRING = "No current firmware found for this printer. Make a feature request to have it added."; }
401 | else { $EXITSTRING = "Revision: $fwrev"; }
402 | if ($fwdate) { $EXITSTRING .= " (Date: $fwdate)\n"; } else { $EXITSTRING .= "\n"; }
403 | if ($fwinst) { $EXITSTRING .= $fwinst; }
404 | stop($EXITSTRING, 'OK');
405 | }
406 |
407 | sub check_page_count {
408 | my ($oid,$result,$model,$t_oid,$c_oid,$m_oid,
409 | $m_a3_oid,$m_a4_oid,$c_a3_oid,$c_a4_oid,
410 | $m_a3,$m_a4,$c_a3,$c_a4,$MonoPagecount,$ColorPagecount,$TotalPagecount);
411 | my (%ttmpprs,%ctmpprs,%mtmpprs) = ();
412 |
413 | $model = check_model(2);
414 | if ($model =~ m/hp/) {
415 | $c_oid='.1.3.6.1.4.1.11.2.3.9.4.2.1.4.1.2.7.0';
416 | $m_oid='.1.3.6.1.4.1.11.2.3.9.4.2.1.4.1.2.6.0';
417 | }
418 | if ($model =~ m/canon/) {
419 | $t_oid='.1.3.6.1.4.1.1602.1.11.1.3.1.4.101';
420 | $c_oid='.1.3.6.1.4.1.1602.1.11.1.3.1.4.105';
421 | $m_oid='.1.3.6.1.4.1.1602.1.11.1.3.1.4.108';
422 | $m_a3_oid='.1.3.6.1.4.1.1602.1.11.1.3.1.4.112';
423 | $m_a4_oid='.1.3.6.1.4.1.1602.1.11.1.3.1.4.113';
424 | $c_a3_oid='.1.3.6.1.4.1.1602.1.11.1.3.1.4.222';
425 | $c_a4_oid='.1.3.6.1.4.1.1602.1.11.1.3.1.4.223';
426 | }
427 | if ($model =~ m/xerox/) {
428 | $c_oid='.1.3.6.1.4.1.253.8.53.13.2.1.6.1.20.33';
429 | $m_oid='.1.3.6.1.4.1.253.8.53.13.2.1.6.1.20.34';
430 | }
431 | if ($model =~ m/lexmark/) {
432 | $c_oid='.1.3.6.1.4.1.641.6.4.2.2.1.7.1.1';
433 | $m_oid='.1.3.6.1.4.1.641.6.4.2.2.1.6.1.1';
434 | }
435 | if ($model =~ m/ricoh/) {
436 | $c_oid='.1.3.6.1.4.1.367.3.2.1.2.19.5.1.9.21';
437 | $m_oid='.1.3.6.1.4.1.367.3.2.1.2.19.5.1.9.22';
438 | }
439 | if ($model =~ m/kyocera|ecosys|taskalfa|4200dn/) {
440 | $t_oid='.1.3.6.1.4.1.1347.42.2.1.1.1.6.1';
441 | $c_oid='.1.3.6.1.4.1.1347.42.2.1.1.1.8.1';
442 | $m_oid='.1.3.6.1.4.1.1347.42.2.1.1.1.7.1';
443 | }
444 |
445 | $oid=".1.3.6.1.2.1.43.10.2.1.4.1.1";
446 |
447 | if (defined($snmp->get([$m_a3_oid]))) { $m_a3 = $snmp->get([$m_a3_oid]) }
448 | if (defined($snmp->get([$m_a4_oid]))) { $m_a4 = $snmp->get([$m_a4_oid]) }
449 | if (defined($snmp->get([$c_a3_oid]))) { $c_a3 = $snmp->get([$c_a3_oid]) }
450 | if (defined($snmp->get([$c_a4_oid]))) { $c_a4 = $snmp->get([$c_a4_oid]) }
451 | if (($m_a3 || $m_a4) > 0) {
452 | $MonoPagecount = $m_a3 + $m_a4;
453 | } elsif ($model =~ m/kyocera|ecosys|taskalfa|4200dn/) {
454 | my @tresult = $snmp->bulkwalk(0, 20, $t_oid);
455 | my @cresult = $snmp->bulkwalk(0, 20, $c_oid);
456 | my @mresult = $snmp->bulkwalk(0, 20, $m_oid);
457 | for my $tkey (@tresult) {
458 | for my $tval (@$tkey) {
459 | $TotalPagecount = $TotalPagecount + $tval->[2];
460 | }
461 | }
462 | for my $ckey (@cresult) {
463 | for my $cval (@$ckey) {
464 | $ColorPagecount = $ColorPagecount + $cval->[2];
465 | }
466 | }
467 | for my $mkey (@mresult) {
468 | for my $mval (@$mkey) {
469 | $MonoPagecount = $MonoPagecount + $mval->[2];
470 | }
471 | }
472 | } else {
473 | $result=$snmp->get([$m_oid]);
474 | if((not defined($result)) || (lc($result) eq 'nosuchinstance') || (lc($result) eq 'nosuchobject')) {
475 | $result=$snmp->get([$t_oid]);
476 | if((not defined($result)) || (lc($result) eq 'nosuchinstance') || (lc($result) eq 'nosuchobject')) {
477 | $result=$snmp->get([$oid]);
478 | if(not defined($result)) {
479 | $state = "CRITICAL";
480 | $EXITSTRING = "$state - " . $snmp->{ErrorStr} . "\n";
481 | stop($EXITSTRING, $state);
482 | } else { $TotalPagecount=$result; }
483 | } else { $TotalPagecount=$result; }
484 | } else { $MonoPagecount=$result; }
485 | }
486 | if (($c_a3 || $c_a4) > 0) {
487 | $ColorPagecount = $c_a3 + $c_a4;
488 | } else {
489 | $result=$snmp->get([$c_oid]);
490 | if(not defined($result)) {
491 | } else { $ColorPagecount=$result; }
492 | }
493 | if (($TotalPagecount) or (($model =~ m/kyocera|ecosys|taskalfa|4200dn/))) {
494 | $EXITSTRING = "Pagecount is $TotalPagecount";
495 | if ($model =~ m/kyocera|ecosys|taskalfa|4200dn/) {
496 | $EXITSTRING.= " Total, $MonoPagecount Black-and-White";
497 | }
498 | } else { $EXITSTRING = "Pagecount is $MonoPagecount Black-and-White"; }
499 | if ($ColorPagecount > 0) {
500 | $EXITSTRING.= ", $ColorPagecount Color";
501 | }
502 | $EXITSTRING.= "\n";
503 | if (($TotalPagecount) or ($model =~ m/kyocera|ecosys|taskalfa|4200dn/)) {
504 | $EXITSTRING.= "|Total=$TotalPagecount;;;;";
505 | if ($model =~ m/kyocera|ecosys|taskalfa|4200dn/) {
506 | $EXITSTRING.= " Black-and-White=$MonoPagecount;;;;";
507 | }
508 | } else { $EXITSTRING.= "|Black-and-White=$MonoPagecount;;;;"; }
509 | if ($ColorPagecount > 0) {
510 | $EXITSTRING.= " Color=$ColorPagecount;;;;";
511 | }
512 | }
513 |
514 | sub get_consumables {
515 | my ($result,$Table,$Names,$CurCap,$MaxCap) = @_;
516 | my %tmpprs = ();
517 | my ($consumable, $curcap_pct, $inum);
518 | my ($puncher, $found) = 0;
519 |
520 | foreach my $key (keys(%$result)) {
521 | my($base, $index) = ($key =~ /($Table\.\d+\.\d+)\.(\d+)/);
522 | if($base eq $Names ) {
523 | $result->{$key} =~ s/[^\w\s]//g;
524 | $tmpprs{$index}{name} = $result->{$key};
525 | }
526 | if($base eq $CurCap) { $tmpprs{$index}{curcap} = $result->{$key}; }
527 | if($base eq $MaxCap) { $tmpprs{$index}{maxcap} = $result->{$key}; }
528 | }
529 |
530 | foreach my $key (keys(%tmpprs)) {
531 | my $name=$tmpprs{$key}{name};
532 | if ($name =~ m/Imaging Unit|Imaging Kit|Patrone|Cartouche|Unité|Courroie|Kit d/) {
533 | if ($name =~ /(\w+) Imaging Unit/) {
534 | $consumable = "$1 Imaging Unit";
535 | } else {
536 | $consumable = $name;
537 | }
538 | }
539 | else { ($consumable = $name) =~ s/(\w+).*/$1/; }
540 | if (($consumable =~ m/Fuser|Fixiererkit/ and $opt_nofuser)) { next; }
541 | if ($consumable eq "Canon") {
542 | my @split = split(' ',$consumable = $name);
543 | foreach my $cconsumable (@split) {
544 | if ($cconsumable =~ m/Black|Yellow|Magenta|Cyan/) { $consumable = $cconsumable; }
545 | else { next; }
546 | }
547 | }
548 | if ($consumable eq "Image") {
549 | my @split = split(' ',$consumable = $name);
550 | foreach my $iconsumable (@split) {
551 | if ($iconsumable =~ m/Transfer|Fuser/) { $consumable = $iconsumable. " Kit"; }
552 | else { next; }
553 | }
554 | }
555 | if (check_model(2) =~ m/generic 30c-9/) {
556 | my @split = split(' ',$consumable = $name);
557 | foreach my $gconsumable (@split) {
558 | if ($gconsumable =~ m/Toner/) {
559 | ($consumable) = $name =~ /\((.*)\)/;
560 | } elsif ($gconsumable =~ m/Image|Fusing/) {
561 | $consumable = $name;
562 | } else {
563 | next;
564 | }
565 | }
566 | }
567 | if (check_model(2) =~ m/ricoh/) {
568 | my @split = split(' ',$consumable = $name);
569 | foreach my $rconsumable (@split) {
570 | if ($rconsumable =~ m/Toner/) {
571 | ($consumable) = $name =~ /(?<=Toner )(\w+)/;
572 | } else {
573 | next;
574 | }
575 | }
576 | }
577 |
578 | my $curcap=$tmpprs{$key}{curcap};
579 | my $maxcap=$tmpprs{$key}{maxcap};
580 | if ($name =~ m/Drum|Resttoner|Waste|Belt|Developer|200K|300K|Photoconductor|Staples G|Trommel|Tambour|dév|récupération/) {
581 | next;
582 | }
583 | if ($name =~ m/Main Staple/) { $consumable = "Staples"; }
584 | if ($name =~ m/Transfer Roll/) { $consumable = "Transfer"; }
585 | if ($opt_lang eq 'english') {
586 | if ($consumable =~ m/noir|Noir/) { $consumable = "Black"; }
587 | if ($consumable =~ m/jaune|Jaune/) { $consumable = "Yellow"; }
588 | if ($consumable =~ m/Courroie de transfert/) { $consumable = "Transfer Belt"; }
589 | if ($consumable =~ m/Rouleaux|Wazlen/) { $consumable = "Clean Rollers"; }
590 | if ($consumable =~ m/Rouleau d/) { $consumable = "Pickup Rollers"; }
591 | if ($consumable =~ m/Rouleau s/) { $consumable = "Separation Roller"; }
592 | if ($consumable =~ m/Kit du rouleau du bac/) {
593 | ($inum) = $name =~ /(?<=Kit du rouleau du bac )(\d+)/;
594 | $consumable = "Bin Roller Kit" . " $inum";
595 | }
596 | if ($consumable =~ m/Fixiererkit|Kit de fusion/) { $consumable = "Fuser Kit"; }
597 | if ($consumable =~ m/Tonerauffangeinheit/) { $consumable = "Toner Collection Kit"; }
598 | if ($consumable =~ m/Hefter/) { $consumable = "Stapler"; }
599 | if ($consumable =~ m/Transferkit/) { $consumable = "Transfer Kit"; }
600 | }
601 | # German
602 | if ($consumable =~ m/Fixiererkit/) { $consumable = "Fixiererkit"; }
603 | if ($consumable =~ m/Wazlen/) { $consumable = "Walzen reinigen"; }
604 | if ($consumable =~ m/Tonerauffangeinheit/) { $consumable = "Tonerauffangeinheit"; }
605 | if ($consumable =~ m/Hefter/) { $consumable = "Hefter"; }
606 | if ($consumable =~ m/Transferkit/) { $consumable = "Transferkit"; }
607 | # French
608 | if ($consumable =~ m/noir|Noir/) { $consumable = "Toner Noir"; }
609 | if ($consumable =~ m/jaune|Jaune/) { $consumable = "Toner Juane"; }
610 | if ($consumable =~ m/Courroie de transfert/) { $consumable = "Courroie de transfert"; }
611 | if ($consumable =~ m/Rouleaux/) { $consumable = "Rouleaux de transfert"; }
612 | if ($consumable =~ m/Rouleau d/) { $consumable = "Rouleau d'entraînement"; }
613 | if ($consumable =~ m/Rouleau s/) { $consumable = "Rouleau séparation"; }
614 | if ($consumable =~ m/Kit de fusion/) { $consumable = "Kit de fusion"; }
615 | if ($consumable =~ m/Kit du rouleau du bac/) {
616 | ($inum) = $name =~ /(?<=Kit du rouleau du bac )(\d+)/;
617 | $consumable = "Kit du rouleau du bac" . " $inum";
618 | }
619 |
620 | if ($consumable =~ m/Imaging Unit|Vorlageneinzugskit|nettoyage/) { }
621 | elsif ($consumable =~ m/Patrone/) { # German
622 | if ($opt_lang eq 'english') {
623 | if ($consumable =~ m/Schwarz/) { $consumable = "Black Toner"; }
624 | if ($consumable =~ m/Gelb/) { $consumable = "Yellow Toner"; }
625 | if ($consumable =~ m/Magenta/) { $consumable = "Magenta Toner"; }
626 | if ($consumable =~ m/Cyan/) { $consumable = "Cyan Toner"; }
627 | } else {
628 | if ($consumable =~ m/Schwarz/) { $consumable = "Patrone Schwarz"; }
629 | if ($consumable =~ m/Gelb/) { $consumable = "Patrone Gelb"; }
630 | if ($consumable =~ m/Magenta/) { $consumable = "Patrone Magenta"; }
631 | if ($consumable =~ m/Cyan/) { $consumable = "Patrone Cyan"; }
632 | }
633 | }
634 | elsif ($consumable =~ m/Black|Yellow|Magenta|Cyan/) { $consumable = $consumable." Toner"; }
635 | elsif ($consumable =~ m/Schwarz|Gelb/) {
636 | if ($opt_lang = 'english') {
637 | # German
638 | if ($consumable =~ m/Schwarz/) { $consumable = "Black"; }
639 | if ($consumable =~ m/Gelb/) { $consumable = "Yellow"; }
640 | }
641 | $consumable = $consumable." Toner";
642 | }
643 | # Kyocera reports toner as model number so we need to convert that to something human readable
644 | if ($consumable =~ m/TK|CK/) {
645 | if ($consumable =~ /CS$|C$/) { $consumable = "Cyan Toner"; }
646 | elsif ($consumable =~ /MS$|M$/) { $consumable = "Magenta Toner"; }
647 | elsif ($consumable =~ /YS$|Y$/) { $consumable = "Yellow Toner"; }
648 | elsif ($consumable =~ /KS$|K$/) { $consumable = "Black Toner"; }
649 | else { $consumable = "Black Toner"; }
650 | }
651 | # Some HP reports toner as model number so we need to convert that to something human readable
652 | if ($consumable =~ m/CE/) {
653 | if ($consumable =~ /1A$/) { $consumable = "Cyan Toner"; }
654 | elsif ($consumable =~ /3A$/) { $consumable = "Magenta Toner"; }
655 | elsif ($consumable =~ /2A$/) { $consumable = "Yellow Toner"; }
656 | elsif ($consumable =~ /0A$/) { $consumable = "Black Toner"; }
657 | else { $consumable = "Black Toner"; }
658 | }
659 | if ($name =~ m/Toner cyan|Toner Cyan/) { $consumable = "Toner Cyan"; }
660 | if ($name =~ m/Toner magenta|Toner Magenta/) { $consumable = "Toner Magenta"; }
661 | if ($consumable eq 'Magneta') { $consumable = "Magenta Toner"; } # New HP OID has a typo
662 | if ($consumable eq 'Clean') { $consumable = $consumable." Rollers"; }
663 | if ($consumable eq 'Document') { $consumable = $consumable." Feeder Kit"; }
664 | if ($consumable eq 'Maintenance') { $consumable = $consumable." Kit"; }
665 | if ($consumable eq 'Transfer') { $consumable = $consumable." Unit"; }
666 | if ($consumable eq 'Fuser') { $consumable = $consumable." Kit"; }
667 | if ($consumable eq 'Stapler') { }
668 | if ($consumable eq 'Staples') { }
669 | if ($consumable eq 'Saddle') { $consumable = $consumable." Staples"; }
670 | if ($consumable eq 'Hole') { $puncher = 1; $consumable = $consumable. " Punch Box"; }
671 | if ($consumable eq 'Puncher') { $puncher = 1; $consumable = $consumable. " Waste"; }
672 | push (@consumables, $consumable);
673 |
674 | $found=1;
675 | if ($puncher == 1) {
676 | if ($curcap > 99) {
677 | $state = "CRITICAL";
678 | } elsif ($curcap >= 96) {
679 | $state = "WARNING";
680 | } else {
681 | $state = "OK";
682 | }
683 | push (@measurables, '1');
684 | push (@percentages, $curcap);
685 | } else {
686 | if ($maxcap>0 && $curcap>0) {
687 | $curcap_pct=sprintf("%.2f",$curcap*100/$maxcap);
688 | if ($curcap_pct<=$opt_critical) {
689 | # critical messages come first
690 | $state = "CRITICAL";
691 | } elsif ($curcap_pct<=$opt_warning) {
692 | $state = "WARNING";
693 | } else {
694 | $state = "OK";
695 | }
696 | push (@measurables, '1');
697 | push (@percentages, $curcap_pct);
698 | } elsif ($maxcap == 100 && $curcap == 0) {
699 | $state = "CRITICAL";
700 | push (@measurables, '1');
701 | push (@percentages, 0);
702 | } else {
703 | if (check_model(2) =~ m/brother/) {
704 | my ($bresult,$bstatus,$boid);
705 | if ($consumable =~ m/Black|Schwarz/) {
706 | $boid = ".1.3.6.1.4.1.2435.2.3.9.1.1.2.10.1";
707 | }
708 | if ($consumable =~ m/Cyan/) {
709 | $boid = ".1.3.6.1.4.1.2435.2.3.9.1.1.2.10.2";
710 | }
711 | if ($consumable =~ m/Magenta/) {
712 | $boid = ".1.3.6.1.4.1.2435.2.3.9.1.1.2.10.3";
713 | }
714 | if ($consumable =~ m/Yellow|Gelb/) {
715 | $boid = ".1.3.6.1.4.1.2435.2.3.9.1.1.2.10.4";
716 | }
717 | if (defined($snmp->get($boid))) {
718 | $bstatus = $bresult->{$oid};
719 | if ($bstatus == 0) { $state = "OK"; push (@measurables, 'b0'); $curcap = 100; }
720 | if ($bstatus == 1) { $state = "WARNING"; push (@measurables, 'b1'); $curcap = 10; }
721 | if ($bstatus == 2) { $state = "CRITICAL"; push (@measurables, 'b2'); $curcap = 0; }
722 | if ($bstatus == 3) { $state = "CRITICAL"; push (@measurables, 'b3'); $curcap = 0; }
723 | } else { ($state,$curcap) = nonmeasurable($curcap,$maxcap,$name); }
724 | } else {
725 | $state = nonmeasurable($curcap,$maxcap,$name);
726 | }
727 | push (@percentages, $curcap);
728 | }
729 | }
730 | $puncher = 0;
731 | push @{ $status[$cnumber] }, $state;
732 | $cnumber++;
733 | }
734 | }
735 |
736 | sub nonmeasurable {
737 | my ($curcap,$maxcap,$name) = @_;
738 |
739 | # Our object is not measurable - it's either FULL or EMPTY (such as a punch dust box)
740 | # Let's report on it's status using appropriate terminology
741 | if (check_model(2) =~ m/brother/) {
742 | if ($curcap == -3) { $state = "OK"; push (@measurables, 'b0'); }
743 | else {
744 | my $smessage = check_messages(2);
745 | my @messages = split('\n',$smessage);
746 | foreach my $message (@messages) {
747 | $message = lc $message;
748 | if ($message =~ m/toner low|wenig toner/) {
749 | $state = "WARNING";
750 | push (@measurables, 'b1');
751 | $curcap = 10;
752 | }
753 | elsif ($message =~ m/replace toner|toner ersetzen/) {
754 | $state = "CRITICAL";
755 | push (@measurables, 'b3');
756 | $curcap = 0;
757 | }
758 | }
759 | }
760 | push (@measurables, '1');
761 | return $state, $curcap;
762 | } elsif ($curcap==-3) {
763 | if ($maxcap>0) { $state = "WARNING"; push (@measurables, 'lt'); }
764 | else { $state = "OK"; (@measurables, 'gt'); }
765 | } elsif ($curcap==-2) {
766 | # The value (-2) means unknown
767 | if ($name =~ m/W2020A|W2021A|W2022A|W2023A/) { # HP Color LaserJet Pro M454dw Toner
768 | $state = "CRITICAL";
769 | push (@measurables, '1');
770 | } else { $state = "WARNING"; push (@measurables, '0'); }
771 | } elsif ($curcap==0) {
772 | # Something is empty!
773 | $state = "CRITICAL";
774 | }
775 | return $state;
776 | }
777 |
778 | sub prioritize_results {
779 | my ($metric) = @_;
780 | my ($mcount,$scode);
781 |
782 | if ((scalar @consumables) > 0) { $mcount = (scalar @consumables); }
783 | if ((scalar @strays) > 0) { $mcount = (scalar @strays); }
784 |
785 | $i = 0;
786 |
787 | while ($mcount > 0) {
788 | if ($status[$i][0] eq 'CRITICAL') { $scode = 1; }
789 | if ($status[$i][0] eq 'WARNING') { $scode = 2; }
790 | if ($status[$i][0] eq 'OK') { $scode = 3; }
791 |
792 | if ($metric eq "consumables") {
793 | push @{ $mresults[$i] }, $scode, $status[$i][0], $consumables[$i], $message[$i];
794 | }
795 | if ($metric eq "trays") {
796 | push @{ $mresults[$i] }, $scode, $status[$i][0], $strays[$i][0], $message[$i];
797 | }
798 | $mcount--;
799 | $i++;
800 | }
801 |
802 | @mresults = sort { $a->[0] cmp $b->[0] } @mresults;
803 |
804 | $i = 0;
805 | $mcount = (scalar @mresults);
806 | while ($mcount > 0) {
807 | print "$mresults[$i][1]: $mresults[$i][2]$mresults[$i][3]\n";
808 | $mcount--;
809 | $i++;
810 | }
811 | }
812 |
813 | sub check_consumables {
814 | my %pr_oids = (
815 | 'Table' => '.1.3.6.1.2.1.43.11.1.1',
816 | 'Names' => '.1.3.6.1.2.1.43.11.1.1.6.1',
817 | 'CurCap' => '.1.3.6.1.2.1.43.11.1.1.9.1',
818 | 'MaxCap' => '.1.3.6.1.2.1.43.11.1.1.8.1',
819 | 'CTable' => '.1.3.6.1.2.1.43.31.1.1',
820 | 'CNames' => '.1.3.6.1.2.1.43.31.1.1.5.1',
821 | 'CCurCap' => '.1.3.6.1.2.1.43.31.1.1.8.1',
822 | 'CMaxCap' => '.1.3.6.1.2.1.43.31.1.1.7.1'
823 | );
824 |
825 | my ($consumable,$measurable,$perfcount,$rindex,$result);
826 | my $pct_remaining = "";
827 | my %nsioids;
828 | my $nsicounter = 1;
829 | my $nsioidrow = 1;
830 | my @results;
831 | my (%hresults,%chresults);
832 |
833 | @results = ($snmp->bulkwalk(0, 20, $pr_oids{Names}),
834 | $snmp->bulkwalk(0, 20, $pr_oids{CurCap}),
835 | $snmp->bulkwalk(0, 20, $pr_oids{MaxCap}));
836 |
837 | if ($snmp->{ErrorStr}) {
838 | if ($snmp->{ErrorStr} =~ m/Timeout/ and ($opt_ignoffline)) {
839 | stop("OK - Printer offline and check was ignored.", 'OK');
840 | } else {
841 | stop("CRITICAL - $snmp->{ErrorStr}", 'CRITICAL');
842 | }
843 | }
844 |
845 | for my $key (@results) {
846 | for my $v (@$key) {
847 | $rindex = $v->[0] . "." . $v->[1];
848 | $hresults{$rindex} = $v->[2];
849 | }
850 | }
851 | my $result = \%hresults;
852 |
853 | if(not defined($result)) {
854 | if ($snmp->{ErrorStr} =~ m/The requested entries are empty or do not exist/) {
855 | while ($nsicounter gt 0) {
856 | my $nsiName = "$pr_oids{Names}.$nsioidrow";
857 | my $nsiCurCap = "$pr_oids{CurCap}.$nsioidrow";
858 | my $nsiMaxCap = "$pr_oids{MaxCap}.$nsioidrow";
859 | my $nsiNresult = $snmp->get($nsiName);
860 | my $nsiCresult = $snmp->get($nsiCurCap);
861 | my $nsiMresult = $snmp->get($nsiMaxCap);
862 | if (lc($nsiNresult->{$nsiName}) eq "nosuchinstance") { $nsicounter = 0; }
863 | else {
864 | %nsioids = (%nsioids,
865 | $nsiName => $nsiNresult->{$nsiName},
866 | $nsiCurCap => $nsiCresult->{$nsiCurCap},
867 | $nsiMaxCap => $nsiMresult->{$nsiMaxCap});
868 | }
869 | $nsioidrow++;
870 | }
871 | $result = \%nsioids;
872 | } elsif ($snmp->{ErrorStr} =~ m/Timeout/ and ($opt_ignoffline)) {
873 | stop("OK - Printer offline and check was ignored.", 'OK');
874 | } else {
875 | stop("CRITICAL - $snmp->{ErrorStr}", 'CRITICAL');
876 | }
877 | }
878 |
879 | my @cresults = ($snmp->bulkwalk(0, 20, $pr_oids{CNames}),
880 | $snmp->bulkwalk(0, 20, $pr_oids{CCurCap}),
881 | $snmp->bulkwalk(0, 20, $pr_oids{CMaxCap}));
882 |
883 | for my $ckey (@cresults) {
884 | for my $cv (@$ckey) {
885 | $rindex = $cv->[0] . "." . $cv->[1];
886 | $chresults{$rindex} = $cv->[2];
887 | }
888 | }
889 | my $cresult = \%chresults;
890 |
891 | get_consumables($result, $pr_oids{Table}, $pr_oids{Names}, $pr_oids{CurCap}, $pr_oids{MaxCap});
892 | get_consumables($cresult, $pr_oids{CTable}, $pr_oids{CNames}, $pr_oids{CCurCap}, $pr_oids{CMaxCap});
893 |
894 | $tcount = (scalar @consumables);
895 | if (@percentages != 0 ) { $measurable = 1; }
896 | if ($measurable) {
897 | if ($consumables[0] =~ m/Puncher Waste|Hole Punch Box/) {
898 | $pct_remaining = " is ".$percentages[0]. "% full.";
899 | } elsif ($consumables[0] eq "Stapler") {
900 | $pct_remaining = "";
901 | } elsif (check_model(2) =~ m/brother/) {
902 | if ($measurables[$i] eq "b0") {
903 | $pct_remaining = " levels are OK.";
904 | }
905 | if ($measurables[$i] eq "b1") {
906 | $pct_remaining = " levels are LOW.";
907 | }
908 | if ($measurables[$i] eq "b2") {
909 | $pct_remaining = " has no toner installed.";
910 | }
911 | if ($measurables[$i] eq "b3") {
912 | $pct_remaining = " levels are EMPTY.";
913 | }
914 | } elsif ($percentages[$i] eq "-2") {
915 | if ($measurables[$i] eq "0") {
916 | $pct_remaining = " levels cannot be measured.";
917 | } else { $pct_remaining = " is at 0% remaining."; }
918 | } else {
919 | $pct_remaining = " is at ".$percentages[0]. "% remaining.";
920 | }
921 | push (@message, $pct_remaining);
922 | }
923 | my $perfcount = $tcount;
924 | if ($tcount > 1) {
925 | $tcount--;
926 | while ($tcount > 0) {
927 | $i++;
928 | if ($consumables[$i] eq "Waste") {
929 | $tcount--;
930 | next;
931 | }
932 | if ($measurable) {
933 | if ($consumables[$i] =~ m/Puncher Waste|Hole Punch Box/) {
934 | $pct_remaining = " is ".$percentages[$i]. "% full.";
935 | } elsif ($consumables[$i] eq "Stapler") {
936 | $pct_remaining = "";
937 | } elsif (check_model(2) =~ m/brother/) {
938 | if ($measurables[$i] eq "b0") {
939 | $pct_remaining = " levels are OK.";
940 | }
941 | if ($measurables[$i] eq "b1") {
942 | $pct_remaining = " levels are LOW.";
943 | }
944 | if ($measurables[$i] eq "b2") {
945 | $pct_remaining = " has no toner installed.";
946 | }
947 | if ($measurables[$i] eq "b3") {
948 | $pct_remaining = " levels are EMPTY.";
949 | }
950 | } elsif ($percentages[$i] eq "-2") {
951 | if ($measurables[$i] eq "0") {
952 | $pct_remaining = " levels cannot be measured.";
953 | } else { $pct_remaining = " is at 0% remaining."; }
954 | } elsif ($percentages[$i] eq "-3") {
955 | if ($measurables[$i] eq "lt") {
956 | $pct_remaining = " levels are LOW.";
957 | }
958 | if ($measurables[$i] eq "gt") {
959 | $pct_remaining = " levels are OK.";
960 | }
961 | } else {
962 | $pct_remaining = " is at ".$percentages[$i]. "% remaining.";
963 | }
964 | }
965 | push (@message, $pct_remaining);
966 | $tcount--;
967 | }
968 | }
969 | prioritize_results('consumables');
970 | $i = 0;
971 | $EXITSTRING.= "|";
972 | while ($perfcount > 0) {
973 | if ($consumables[$i] eq "Waste") {
974 | $i++;
975 | $perfcount--;
976 | next;
977 | }
978 | ($consumable = $consumables[$i]) =~ s/ /_/g;
979 | if ($measurable) {
980 | if ($consumable eq "Stapler") {
981 | if ($status[$i] eq 'CRITICAL') { $EXITSTRING.= $consumable."=0"; }
982 | elsif ($status[$i] eq 'OK') { $EXITSTRING.= $consumable."=100"; }
983 | } elsif ($percentages[$i] eq "-2") {
984 | if ($measurables[$i] eq "0") { }
985 | else { $EXITSTRING.= "$consumable=0"; }
986 | } else {
987 | $EXITSTRING.= $consumable."=".$percentages[$i];
988 | }
989 | } else {
990 | if ($status[$i] == "CRITICAL") {
991 | $EXITSTRING.= $consumable."=0";
992 | } else {
993 | $EXITSTRING.= $consumable."=1";
994 | }
995 | }
996 | $i++;
997 | $perfcount--;
998 | if ($perfcount == 0) { $EXITSTRING.= ";;;;"; } else { $EXITSTRING.=";;;; "; }
999 | }
1000 | }
1001 |
1002 | sub check_paper_trays {
1003 | my $found=0;
1004 | my %tmpprs = ();
1005 | my ($name,$lcname,$feeder,$cap,$tstatus,$traymessage,$maxcap,$feeddim,$xfeeddim,$cap_pct,$result,$rindex);
1006 | my %hresults;
1007 | my %tray_oids = (
1008 | 'Table' => '.1.3.6.1.2.1.43.8.2.1',
1009 | 'Cap' => '.1.3.6.1.2.1.43.8.2.1.10.1',
1010 | 'Status' => '.1.3.6.1.2.1.43.8.2.1.11.1',
1011 | 'MaxCap' => '.1.3.6.1.2.1.43.8.2.1.9.1',
1012 | 'Name' => '.1.3.6.1.2.1.43.8.2.1.13.1',
1013 | 'FeedDim' => '.1.3.6.1.2.1.43.8.2.1.4.1',
1014 | 'FeedDimUnits' => '.1.3.6.1.2.1.43.8.2.1.2.1',
1015 | 'XFeedDim' => '.1.3.6.1.2.1.43.8.2.1.5.1',
1016 | 'XFeedDimUnits' => '.1.3.6.1.2.1.43.8.2.1.3.1'
1017 | );
1018 |
1019 | my @results = ($snmp->bulkwalk(0, 10, $tray_oids{Name}),
1020 | $snmp->bulkwalk(0, 10, $tray_oids{Cap}),
1021 | $snmp->bulkwalk(0, 10, $tray_oids{MaxCap}),
1022 | $snmp->bulkwalk(0, 10, $tray_oids{FeedDim}),
1023 | $snmp->bulkwalk(0, 10, $tray_oids{FeedDimUnits}),
1024 | $snmp->bulkwalk(0, 10, $tray_oids{XFeedDim}),
1025 | $snmp->bulkwalk(0, 10, $tray_oids{XFeedDimUnits}),
1026 | $snmp->bulkwalk(0, 10, $tray_oids{Status}));
1027 |
1028 | for my $key (@results) {
1029 | for my $v (@$key) {
1030 | $rindex = $v->[0] . "." . $v->[1];
1031 | $hresults{$rindex} = $v->[2];
1032 | }
1033 | }
1034 | $result = \%hresults;
1035 | my $model = check_model(2);
1036 | foreach my $key (keys(%$result)) {
1037 | my($base, $index) = ($key =~ /($tray_oids{Table}\.\d+\.\d+)\.(\d+)/);
1038 | $result->{$key} =~ s/\"//g;
1039 | if($base eq $tray_oids{Cap}) { $tmpprs{$index}{cap} = $result->{$key}; }
1040 | if($base eq $tray_oids{Status}) { $tmpprs{$index}{tstatus} = $result->{$key}; }
1041 | if($base eq $tray_oids{MaxCap}) { $tmpprs{$index}{maxcap} = $result->{$key}; }
1042 | if($base eq $tray_oids{Name}) { $tmpprs{$index}{name} = $result->{$key}; }
1043 | if($base eq $tray_oids{FeedDim}) { $tmpprs{$index}{feeddim} = $result->{$key}; }
1044 | if($base eq $tray_oids{XFeedDim}) { $tmpprs{$index}{xfeeddim} = $result->{$key}; }
1045 | }
1046 |
1047 | if ($opt_nofeeder) {
1048 | foreach my $key (keys(%tmpprs)) {
1049 | if (lc($tmpprs{$key}{name}) =~ m/bypass|mp tray|manual paper|manual envelope|multi-purpose_tray/) { $feeder=1; }
1050 | }
1051 | }
1052 |
1053 | foreach my $key (keys(%tmpprs)) {
1054 | $name=$tmpprs{$key}{name};
1055 | $cap=$tmpprs{$key}{cap};
1056 | $tstatus=$tmpprs{$key}{tstatus};
1057 | $maxcap=$tmpprs{$key}{maxcap};
1058 | $feeddim=$tmpprs{$key}{feeddim};
1059 | $xfeeddim=$tmpprs{$key}{xfeeddim};
1060 |
1061 | # if name is empty, make one with the number
1062 | if ($name eq "") {
1063 | $name="Tray $key";
1064 | }
1065 | if ($name =~ m/(MPT)/) {
1066 | $name =~ s/ \(MPT\)//g;
1067 | }
1068 | if ($name =~ m/Paper Tray/) {
1069 | ($name) = $name =~ /[^ ]* (.*)/;
1070 | }
1071 | $name =~ s/\n/\!/g;
1072 | if ($name =~ m/TRAY/) {
1073 | if ($name =~ /(?<=TRAY)[0-9]/) {
1074 | my @split = split(/(?<=\d)(?=\D)|(?<=\D)(?=\d)/, $name);
1075 | $name = @split[0]." ".@split[1];
1076 | }
1077 | $name = (ucfirst(lc($name)));
1078 | }
1079 | $lcname = lc($name);
1080 | if ($opt_nofeeder) {
1081 | if (($lcname =~ m/tray 1/) and (scalar(keys(%tmpprs) > 1)) and (!$feeder)) { next; }
1082 | elsif ($lcname =~ m/bypass|mp tray|manual paper|manual envelope|multi-purpose_tray/) { next; }
1083 | }
1084 | $found=1;
1085 | push @{ $trays[$traynumber] }, $name, $cap, $maxcap, $feeddim, $xfeeddim, $tstatus;
1086 | $traynumber++;
1087 | }
1088 |
1089 | $traynumber = 0;
1090 | @strays = sort { $a->[0] cmp $b->[0] } @trays;
1091 | $tcount = scalar(@strays);
1092 | my $perfcount = $tcount;
1093 |
1094 | while ($tcount > 0) {
1095 | $name = $strays[$i][0];
1096 | $cap = $strays[$i][1];
1097 | $maxcap = $strays[$i][2];
1098 | $feeddim = $strays[$i][3];
1099 | $xfeeddim = $strays[$i][4];
1100 | $tstatus = $strays[$i][5];
1101 | $lcname = lc($name);
1102 |
1103 | if ($feeddim eq '-2') { $feeddim = "Any"; }
1104 | if ($xfeeddim eq '-2') { $xfeeddim = "Any"; }
1105 |
1106 | $model = check_model(2);
1107 | if (($feeddim || $xfeeddim) ne 'Any') {
1108 | if ($model =~ m/canon|xerox|ricoh|brother/) {
1109 | if ($opt_metric) {
1110 | $feeddim = sprintf("%.0f", $feeddim * .001)."mm";
1111 | $xfeeddim = sprintf("%.0f", $xfeeddim * .001)."mm";
1112 | } else {
1113 | $feeddim = sprintf("%.2f", (($feeddim / 2.54) * .0001))."in";
1114 | $xfeeddim = sprintf("%.2f", (($xfeeddim / 2.54) * .0001))."in";
1115 | }
1116 | } else {
1117 | if ($opt_metric) {
1118 | $feeddim = sprintf("%.0f", (($feeddim * 2.54) * .001))."mm";
1119 | $xfeeddim = sprintf("%.0f", (($xfeeddim * 2.54) * .001))."mm";
1120 | } else {
1121 | $feeddim = sprintf("%.2f", $feeddim * .0001)."in";
1122 | $xfeeddim = sprintf("%.2f", $xfeeddim * .0001)."in";
1123 | }
1124 | }
1125 | }
1126 | if ($cap == -3) {
1127 | # The value (-3) means that the printer knows that at least one unit remains.
1128 | if ($model =~ m/lexmark/) { # When -3, Lexmark is really low status.
1129 | if (($opt_critical == 0) or ($opt_warning == 0 )) {
1130 | $state = "OK";
1131 | } else {
1132 | $state = "WARNING";
1133 | }
1134 | $traymessage = " is LOW. ($xfeeddim x $feeddim)";
1135 | } else {
1136 | $state = "OK";
1137 | $traymessage = " ($xfeeddim x $feeddim)";
1138 | }
1139 | } elsif ($cap == -2) {
1140 | # The value (-2) means unknown
1141 | # so lets check the tray status instead
1142 | if ($tstatus eq '0') {
1143 | if ($model =~ m/canon|hp|ricoh/) {
1144 | $state = "OK";
1145 | $traymessage = " ($xfeeddim x $feeddim)";
1146 | } else {
1147 | $state = "WARNING";
1148 | $traymessage = " is in an UNKNOWN state.";
1149 | }
1150 | if (($lcname =~ m/tray 1|stack bypass|mp tray|manual paper|manual envelope|multi-purpose_tray/) and ($state ne 'WARNING')) {
1151 | $traymessage = "";
1152 | }
1153 | } elsif ($tstatus eq '4') {
1154 | if ($model =~ m/lexmark/) {
1155 | $state = "OK";
1156 | $traymessage = " ($xfeeddim x $feeddim)";
1157 | }
1158 | } elsif ($tstatus eq '9') {
1159 | if ($model =~ m/hp/) {
1160 | $state = "OK";
1161 | $traymessage = " ($xfeeddim x $feeddim)";
1162 | }
1163 | } else {
1164 | # still unknown so we'll mark it warning because we just don't know
1165 | $state = "WARNING";
1166 | $traymessage = " is in UNKNOWN status.";
1167 | }
1168 | if ($opt_warning == 0) { $state = "OK"; }
1169 | } elsif ($cap == 0) {
1170 | # 0 means there is no paper left! This is our only critical value.
1171 | # first lets check to see if it's a bypass tray, we'll always assume Tray 1 is such.
1172 | if ($lcname =~ m/tray 1|stack bypass|mp tray|manual paper|manual envelope|multi-purpose_tray/) {
1173 | $state = "CRITICAL";
1174 | if (($xfeeddim || $feeddim) ne 'Any') {
1175 | $traymessage = " ($xfeeddim x $feeddim)";
1176 | } else { $traymessage = " is empty."; }
1177 | } else {
1178 | if ($opt_critical > 0) {
1179 | $state = "CRITICAL";
1180 | } else {
1181 | $state = "OK";
1182 | }
1183 | $traymessage = " ($xfeeddim x $feeddim) is at 0% paper remaining.";
1184 | }
1185 | $cap_pct=sprintf("%.2f",$cap*100/$maxcap);
1186 | if ($opt_critical == 0) { $state = "OK"; }
1187 | } else {
1188 | ($maxcap==0) && ($maxcap=1);
1189 | $cap_pct=sprintf("%.2f",$cap*100/$maxcap);
1190 | if (($cap_pct <= $opt_warning) and ($opt_warning > 0 )) {
1191 | $state = "WARNING";
1192 | } else {
1193 | $state = "OK";
1194 | }
1195 | $traymessage = " ($xfeeddim x $feeddim) is at $cap_pct% paper remaining.";
1196 | if ($opt_warning == 0 ) { $state = "OK"; }
1197 | }
1198 | push @{ $status[$traynumber] }, $state, $cap_pct;
1199 | push (@message, $traymessage);
1200 | $traynumber++;
1201 | $tcount--;
1202 | $i++;
1203 | }
1204 | prioritize_results('trays');
1205 | $i = 0;
1206 | $EXITSTRING.= "|";
1207 | while ($perfcount > 0) {
1208 | (my $tray = $strays[$i][0]) =~ s/ /_/g;
1209 | if ($status[$i][0] eq 'CRITICAL') {
1210 | if ($status[$i][1] != "") {
1211 | $EXITSTRING.= $tray."=$status[$i][1]";
1212 | } else { $EXITSTRING.= $tray."=0"; }
1213 | }
1214 | if ($status[$i][0] eq 'WARNING') {
1215 | if ($status[$i][1] != "") {
1216 | $EXITSTRING.= $tray."=$status[$i][1]";
1217 | } else { $EXITSTRING.= $tray."=10"; }
1218 | }
1219 | if ($status[$i][0] eq 'OK') {
1220 | if ($status[$i][1] != "") {
1221 | $EXITSTRING.= $tray."=$status[$i][1]";
1222 | } else { $EXITSTRING.= $tray."=100"; }
1223 | }
1224 | $i++;
1225 | $perfcount--;
1226 | if ($perfcount == 0) { $EXITSTRING.= ";;;;"; } else { $EXITSTRING.=";;;; "; }
1227 | }
1228 | }
1229 |
1230 | # set alarm in case we hang
1231 | $SIG{ALRM} = sub {
1232 | if ($opt_ignoffline) {
1233 | stop("OK - Printer offline and check ignored.", "OK");
1234 | } else {
1235 | print "CRITICAL - Timeout after $opt_timeout seconds\n";
1236 | exit($ERRORS{'CRITICAL'});
1237 | }
1238 | };
1239 | alarm($opt_timeout*$opt_retries);
1240 |
1241 | # Convert timeout to microseconds
1242 | my $stimeout = ($opt_timeout * 250000);
1243 |
1244 | # Check snmp version, set snmp parameters
1245 | #if (!$opt_authpass) { $opt_authpass = $opt_authkey; }
1246 | #if (!$opt_privpass) { $opt_privpass = $opt_privkey; }
1247 |
1248 | #base snmp arguments
1249 | my %snmpargs = (DestHost => $opt_host,
1250 | Version => $opt_snmpver,
1251 | RemotePort => 161,
1252 | Timeout => $stimeout,
1253 | Retries => $opt_retries,
1254 | UseNumeric => '1',
1255 | );
1256 | if ($opt_snmpver eq 2) {
1257 | $snmpcmds = "-v" . $opt_snmpver . "c -Cf -On -Oa";
1258 | } else {
1259 | $snmpcmds = "-v$opt_snmpver -Cf -On -Oa";
1260 | }
1261 |
1262 | #snmp v1 and v2c specific arguments
1263 | my (%snmpv12,%snmpv3);
1264 | if ($opt_snmpver ne 3) {
1265 | %snmpv12 = ( Community => $opt_community,);
1266 | $snmpcmds .= " -c $opt_community";
1267 | } else { #snmpv3 arguments
1268 | #base
1269 | %snmpv3 = ( SecName => $opt_user, );
1270 | $snmpcmds .= " -u $opt_user";
1271 | }
1272 |
1273 | if ( ($opt_user) and ($opt_authproto or $opt_privproto) ) {
1274 | my (%snmpv3pl,%snmpv3ap,%snmpv3pp,%snmpv3aa,%snmpv3pa);
1275 |
1276 | # Auth Privilege
1277 | if ( $opt_authproto and $opt_privproto ) {
1278 | %snmpv3pl = ( SecLevel => 'authPriv', );
1279 | $snmpcmds .= " -l authPriv";
1280 | } elsif ( $opt_authproto ) {
1281 | %snmpv3pl = ( SecLevel => 'authNoPriv', );
1282 | $snmpcmds .= " -l authNoPriv";
1283 | } else {
1284 | %snmpv3pl = ( SecLevel => 'noAuthNoPriv', );
1285 | $snmpcmds .= " -l noAuthNoPriv";
1286 | }
1287 |
1288 | # Auth Protocols
1289 | if ($opt_authproto) {
1290 | %snmpv3ap = ( AuthProto => $opt_authproto, );
1291 | $snmpcmds .= " -a $opt_authproto";
1292 | }
1293 | if ($opt_privproto) {
1294 | %snmpv3pp = ( PrivProto => $opt_privproto, );
1295 | $snmpcmds .= " -x $opt_privproto";
1296 | }
1297 |
1298 | # Auth Passphrase or Key
1299 | if ($opt_authpass) {
1300 | %snmpv3aa = ( AuthPass => $opt_authpass, );
1301 | $snmpcmds .= " -A '" . $opt_authpass . "'";
1302 | }
1303 | if ($opt_authkey) {
1304 | %snmpv3aa = ( AuthLocalizedKey => $opt_authkey, );
1305 | $snmpcmds .= " -3k '" . $opt_authkey . "'";
1306 | }
1307 | # Priv Passphrase or Key
1308 | if ($opt_privpass) {
1309 | %snmpv3pa = ( PrivPass => $opt_privpass, );
1310 | $snmpcmds .= " -X '" . $opt_privpass . "'";
1311 | }
1312 | if ($opt_privkey) {
1313 | %snmpv3pa = ( PrivLocalizedKey => $opt_privkey, );
1314 | $snmpcmds .= " -3K '" . $opt_privkey . "'";
1315 | }
1316 |
1317 | %snmpv3 = ( %snmpv3, %snmpv3pl, %snmpv3ap, %snmpv3pp, %snmpv3aa, %snmpv3pa );
1318 |
1319 | if ( $opt_contextname ) {
1320 | %snmpv3 = ( %snmpv3, Context => $opt_contextname, );
1321 | $snmpcmds .= " -n $opt_contextname";
1322 | }
1323 | }
1324 | $snmpcmds .= " $opt_host ";
1325 | if ( $opt_snmpver le 2 ) {
1326 | %snmpargs = ( %snmpargs, %snmpv12 );
1327 | } elsif ( $opt_snmpver eq 3 ) {
1328 | %snmpargs = ( %snmpargs, %snmpv3 );
1329 | } else {
1330 | $state = 'UNKNOWN';
1331 | stop( "$state: It appears you are missing one or more parameters necessary for v$opt_snmpver to function.\n",$state );
1332 | }
1333 | $snmp = new SNMP::Session( %snmpargs );
1334 | if ($opt_messages) {check_messages();}
1335 | if ($opt_model) {check_model(1); exit($ERRORS{'OK'});}
1336 | if ($opt_pagecount) {check_page_count();}
1337 | if ($opt_consum) {check_consumables();}
1338 | if ($opt_firmware) {check_firmware();}
1339 | if (defined($opt_tray)) {check_paper_trays($opt_tray);}
1340 |
1341 | $i = 0;
1342 | $scount = (scalar @status);
1343 | while ($scount > 0) {
1344 | if ($status[$i][0] eq "CRITICAL") { $critcount++; }
1345 | if (($status[$i][0] eq "WARNING") && ($state ne "CRITICAL")) { $warncount++; }
1346 | $scount--;
1347 | $i++;
1348 | }
1349 |
1350 | if ($critcount > 0) { $state = "CRITICAL"; }
1351 | elsif ($warncount > 0) { $state = "WARNING"; }
1352 | else { $state = "OK"; }
1353 |
1354 | stop($EXITSTRING, $state);
1355 | sub stop {
1356 | my $result = shift;
1357 | my $exit_code = shift;
1358 | print $result . "\n";
1359 | exit ( $STATUS_CODE{$exit_code} );
1360 | }
1361 |
--------------------------------------------------------------------------------
/printer-metrics-influxdb.json:
--------------------------------------------------------------------------------
1 | {
2 | "__inputs": [
3 | {
4 | "name": "DS_INFLUXDB",
5 | "label": "InfluxDB",
6 | "description": "",
7 | "type": "datasource",
8 | "pluginId": "influxdb",
9 | "pluginName": "InfluxDB"
10 | }
11 | ],
12 | "__requires": [
13 | {
14 | "type": "grafana",
15 | "id": "grafana",
16 | "name": "Grafana",
17 | "version": "6.7.2"
18 | },
19 | {
20 | "type": "panel",
21 | "id": "graph",
22 | "name": "Graph",
23 | "version": ""
24 | },
25 | {
26 | "type": "datasource",
27 | "id": "influxdb",
28 | "name": "InfluxDB",
29 | "version": "1.0.0"
30 | }
31 | ],
32 | "annotations": {
33 | "list": [
34 | {
35 | "$$hashKey": "object:1759",
36 | "builtIn": 1,
37 | "datasource": "-- Grafana --",
38 | "enable": true,
39 | "hide": true,
40 | "iconColor": "rgba(0, 211, 255, 1)",
41 | "name": "Annotations & Alerts",
42 | "type": "dashboard"
43 | }
44 | ]
45 | },
46 | "editable": true,
47 | "gnetId": null,
48 | "graphTooltip": 0,
49 | "id": null,
50 | "iteration": 1599497014340,
51 | "links": [],
52 | "panels": [
53 | {
54 | "aliasColors": {
55 | "Black-and-White": "#000000",
56 | "Color": "#60f7c5"
57 | },
58 | "bars": false,
59 | "dashLength": 10,
60 | "dashes": false,
61 | "datasource": "${DS_INFLUXDB}",
62 | "fill": 0,
63 | "fillGradient": 0,
64 | "gridPos": {
65 | "h": 8,
66 | "w": 12,
67 | "x": 0,
68 | "y": 0
69 | },
70 | "hiddenSeries": false,
71 | "id": 3,
72 | "legend": {
73 | "avg": false,
74 | "current": false,
75 | "max": false,
76 | "min": false,
77 | "show": true,
78 | "total": false,
79 | "values": false
80 | },
81 | "lines": true,
82 | "linewidth": 2,
83 | "nullPointMode": "connected",
84 | "options": {
85 | "dataLinks": []
86 | },
87 | "percentage": false,
88 | "pointradius": 2,
89 | "points": false,
90 | "renderer": "flot",
91 | "seriesOverrides": [],
92 | "spaceLength": 10,
93 | "stack": false,
94 | "steppedLine": false,
95 | "targets": [
96 | {
97 | "alias": "Black-and-White",
98 | "groupBy": [],
99 | "measurement": "snmp_printer",
100 | "orderByTime": "ASC",
101 | "policy": "default",
102 | "refId": "A",
103 | "resultFormat": "time_series",
104 | "select": [
105 | [
106 | {
107 | "params": [
108 | "value"
109 | ],
110 | "type": "field"
111 | }
112 | ]
113 | ],
114 | "tags": [
115 | {
116 | "key": "hostname",
117 | "operator": "=~",
118 | "value": "/^$hostname$/"
119 | },
120 | {
121 | "condition": "AND",
122 | "key": "service",
123 | "operator": "=",
124 | "value": "Pagecount"
125 | },
126 | {
127 | "condition": "AND",
128 | "key": "metric",
129 | "operator": "=",
130 | "value": "Black-and-White"
131 | }
132 | ]
133 | },
134 | {
135 | "alias": "Color",
136 | "groupBy": [],
137 | "measurement": "snmp_printer",
138 | "orderByTime": "ASC",
139 | "policy": "default",
140 | "refId": "B",
141 | "resultFormat": "time_series",
142 | "select": [
143 | [
144 | {
145 | "params": [
146 | "value"
147 | ],
148 | "type": "field"
149 | }
150 | ]
151 | ],
152 | "tags": [
153 | {
154 | "key": "hostname",
155 | "operator": "=~",
156 | "value": "/^$hostname$/"
157 | },
158 | {
159 | "condition": "AND",
160 | "key": "service",
161 | "operator": "=",
162 | "value": "Pagecount"
163 | },
164 | {
165 | "condition": "AND",
166 | "key": "metric",
167 | "operator": "=",
168 | "value": "Color"
169 | }
170 | ]
171 | }
172 | ],
173 | "thresholds": [],
174 | "timeFrom": null,
175 | "timeRegions": [],
176 | "timeShift": null,
177 | "title": "$service",
178 | "tooltip": {
179 | "shared": true,
180 | "sort": 0,
181 | "value_type": "individual"
182 | },
183 | "transparent": true,
184 | "type": "graph",
185 | "xaxis": {
186 | "buckets": null,
187 | "mode": "time",
188 | "name": null,
189 | "show": true,
190 | "values": []
191 | },
192 | "yaxes": [
193 | {
194 | "format": "short",
195 | "label": null,
196 | "logBase": 1,
197 | "max": null,
198 | "min": null,
199 | "show": true
200 | },
201 | {
202 | "format": "short",
203 | "label": null,
204 | "logBase": 1,
205 | "max": null,
206 | "min": null,
207 | "show": false
208 | }
209 | ],
210 | "yaxis": {
211 | "align": false,
212 | "alignLevel": null
213 | }
214 | },
215 | {
216 | "aliasColors": {
217 | "Drawer 1": "#ff9700",
218 | "Drawer 2": "#8900ff",
219 | "Drawer 3": "#ff002f",
220 | "Drawer 4": "#34ff00",
221 | "MP Tray": "#00ffbd",
222 | "Manual Envelope": "#00ffbd",
223 | "Manual Paper": "#00ffbd",
224 | "Mp Tray": "#00ffbd",
225 | "Multi-purpose_Tray": "#00ffbd",
226 | "Stack Bypass": "#00ffbd",
227 | "Tray 1": "#ff9700",
228 | "Tray 2": "#8900ff",
229 | "Tray 3": "#ff002f",
230 | "Tray 4": "#34ff00"
231 | },
232 | "bars": false,
233 | "dashLength": 10,
234 | "dashes": false,
235 | "datasource": "${DS_INFLUXDB}",
236 | "fill": 0,
237 | "fillGradient": 0,
238 | "gridPos": {
239 | "h": 8,
240 | "w": 12,
241 | "x": 0,
242 | "y": 8
243 | },
244 | "hiddenSeries": false,
245 | "id": 2,
246 | "legend": {
247 | "avg": false,
248 | "current": false,
249 | "max": false,
250 | "min": false,
251 | "show": true,
252 | "total": false,
253 | "values": false
254 | },
255 | "lines": true,
256 | "linewidth": 2,
257 | "nullPointMode": "connected",
258 | "options": {
259 | "dataLinks": []
260 | },
261 | "percentage": false,
262 | "pointradius": 2,
263 | "points": false,
264 | "renderer": "flot",
265 | "seriesOverrides": [],
266 | "spaceLength": 10,
267 | "stack": false,
268 | "steppedLine": false,
269 | "targets": [
270 | {
271 | "alias": "Tray 1",
272 | "groupBy": [],
273 | "measurement": "snmp_printer",
274 | "orderByTime": "ASC",
275 | "policy": "default",
276 | "refId": "A",
277 | "resultFormat": "time_series",
278 | "select": [
279 | [
280 | {
281 | "params": [
282 | "value"
283 | ],
284 | "type": "field"
285 | }
286 | ]
287 | ],
288 | "tags": [
289 | {
290 | "key": "hostname",
291 | "operator": "=~",
292 | "value": "/^$hostname$/"
293 | },
294 | {
295 | "condition": "AND",
296 | "key": "service",
297 | "operator": "=",
298 | "value": "Tray Status"
299 | },
300 | {
301 | "condition": "AND",
302 | "key": "metric",
303 | "operator": "=",
304 | "value": "Tray_1"
305 | }
306 | ]
307 | },
308 | {
309 | "alias": "Tray 2",
310 | "groupBy": [],
311 | "measurement": "snmp_printer",
312 | "orderByTime": "ASC",
313 | "policy": "default",
314 | "query": "SELECT \"value\" FROM \"snmp_printer\" WHERE (\"hostname\" =~ /^$hostname$/ AND \"service\" = 'Tray Status' AND \"metric\" = 'Tray_2') AND $timeFilter",
315 | "rawQuery": true,
316 | "refId": "B",
317 | "resultFormat": "time_series",
318 | "select": [
319 | [
320 | {
321 | "params": [
322 | "value"
323 | ],
324 | "type": "field"
325 | }
326 | ]
327 | ],
328 | "tags": [
329 | {
330 | "key": "hostname",
331 | "operator": "=~",
332 | "value": "/^$hostname$/"
333 | },
334 | {
335 | "condition": "AND",
336 | "key": "service",
337 | "operator": "=",
338 | "value": "Tray Status"
339 | },
340 | {
341 | "condition": "AND",
342 | "key": "metric",
343 | "operator": "=",
344 | "value": "Tray_2"
345 | }
346 | ]
347 | },
348 | {
349 | "alias": "Tray 3",
350 | "groupBy": [
351 | {
352 | "params": [
353 | "$__interval"
354 | ],
355 | "type": "time"
356 | },
357 | {
358 | "params": [
359 | "null"
360 | ],
361 | "type": "fill"
362 | }
363 | ],
364 | "orderByTime": "ASC",
365 | "policy": "default",
366 | "query": "SELECT \"value\" FROM \"snmp_printer\" WHERE (\"hostname\" =~ /^$hostname$/ AND \"service\" = 'Tray Status' AND \"metric\" = 'Tray_3') AND $timeFilter",
367 | "rawQuery": true,
368 | "refId": "C",
369 | "resultFormat": "time_series",
370 | "select": [
371 | [
372 | {
373 | "params": [
374 | "value"
375 | ],
376 | "type": "field"
377 | },
378 | {
379 | "params": [],
380 | "type": "mean"
381 | }
382 | ]
383 | ],
384 | "tags": [
385 | {
386 | "key": "hostname",
387 | "operator": "=~",
388 | "value": "/^$hostname$/"
389 | },
390 | {
391 | "condition": "AND",
392 | "key": "service",
393 | "operator": "=",
394 | "value": "Tray Status"
395 | },
396 | {
397 | "condition": "AND",
398 | "key": "metric",
399 | "operator": "=",
400 | "value": "Tray_3"
401 | }
402 | ]
403 | },
404 | {
405 | "alias": "Tray 4",
406 | "groupBy": [
407 | {
408 | "params": [
409 | "$__interval"
410 | ],
411 | "type": "time"
412 | },
413 | {
414 | "params": [
415 | "null"
416 | ],
417 | "type": "fill"
418 | }
419 | ],
420 | "orderByTime": "ASC",
421 | "policy": "default",
422 | "query": "SELECT \"value\" FROM \"snmp_printer\" WHERE (\"hostname\" =~ /^$hostname$/ AND \"service\" = 'Tray Status' AND \"metric\" = 'Tray_4') AND $timeFilter",
423 | "rawQuery": true,
424 | "refId": "D",
425 | "resultFormat": "time_series",
426 | "select": [
427 | [
428 | {
429 | "params": [
430 | "value"
431 | ],
432 | "type": "field"
433 | },
434 | {
435 | "params": [],
436 | "type": "mean"
437 | }
438 | ]
439 | ],
440 | "tags": [
441 | {
442 | "key": "hostname",
443 | "operator": "=~",
444 | "value": "/^$hostname$/"
445 | },
446 | {
447 | "condition": "AND",
448 | "key": "service",
449 | "operator": "=",
450 | "value": "Tray Status"
451 | },
452 | {
453 | "condition": "AND",
454 | "key": "metric",
455 | "operator": "=",
456 | "value": "Tray_4"
457 | }
458 | ]
459 | },
460 | {
461 | "alias": "Drawer 1",
462 | "groupBy": [
463 | {
464 | "params": [
465 | "$__interval"
466 | ],
467 | "type": "time"
468 | },
469 | {
470 | "params": [
471 | "null"
472 | ],
473 | "type": "fill"
474 | }
475 | ],
476 | "orderByTime": "ASC",
477 | "policy": "default",
478 | "query": "SELECT \"value\" FROM \"snmp_printer\" WHERE (\"hostname\" =~ /^$hostname$/ AND \"service\" = 'Tray Status' AND \"metric\" = 'Drawer_1') AND $timeFilter",
479 | "rawQuery": true,
480 | "refId": "E",
481 | "resultFormat": "time_series",
482 | "select": [
483 | [
484 | {
485 | "params": [
486 | "value"
487 | ],
488 | "type": "field"
489 | },
490 | {
491 | "params": [],
492 | "type": "mean"
493 | }
494 | ]
495 | ],
496 | "tags": [
497 | {
498 | "key": "hostname",
499 | "operator": "=~",
500 | "value": "/^$hostname$/"
501 | },
502 | {
503 | "condition": "AND",
504 | "key": "service",
505 | "operator": "=",
506 | "value": "Tray Status"
507 | },
508 | {
509 | "condition": "AND",
510 | "key": "metric",
511 | "operator": "=",
512 | "value": "Drawer_1"
513 | }
514 | ]
515 | },
516 | {
517 | "alias": "Drawer 2",
518 | "groupBy": [
519 | {
520 | "params": [
521 | "$__interval"
522 | ],
523 | "type": "time"
524 | },
525 | {
526 | "params": [
527 | "null"
528 | ],
529 | "type": "fill"
530 | }
531 | ],
532 | "orderByTime": "ASC",
533 | "policy": "default",
534 | "query": "SELECT \"value\" FROM \"snmp_printer\" WHERE (\"hostname\" =~ /^$hostname$/ AND \"service\" = 'Tray Status' AND \"metric\" = 'Drawer_2') AND $timeFilter",
535 | "rawQuery": true,
536 | "refId": "F",
537 | "resultFormat": "time_series",
538 | "select": [
539 | [
540 | {
541 | "params": [
542 | "value"
543 | ],
544 | "type": "field"
545 | },
546 | {
547 | "params": [],
548 | "type": "mean"
549 | }
550 | ]
551 | ],
552 | "tags": [
553 | {
554 | "key": "hostname",
555 | "operator": "=~",
556 | "value": "/^$hostname$/"
557 | },
558 | {
559 | "condition": "AND",
560 | "key": "service",
561 | "operator": "=",
562 | "value": "Tray Status"
563 | },
564 | {
565 | "condition": "AND",
566 | "key": "metric",
567 | "operator": "=",
568 | "value": "Drawer_2"
569 | }
570 | ]
571 | },
572 | {
573 | "alias": "Drawer 3",
574 | "groupBy": [
575 | {
576 | "params": [
577 | "$__interval"
578 | ],
579 | "type": "time"
580 | },
581 | {
582 | "params": [
583 | "null"
584 | ],
585 | "type": "fill"
586 | }
587 | ],
588 | "orderByTime": "ASC",
589 | "policy": "default",
590 | "query": "SELECT \"value\" FROM \"snmp_printer\" WHERE (\"hostname\" =~ /^$hostname$/ AND \"service\" = 'Tray Status' AND \"metric\" = 'Drawer_3') AND $timeFilter",
591 | "rawQuery": true,
592 | "refId": "G",
593 | "resultFormat": "time_series",
594 | "select": [
595 | [
596 | {
597 | "params": [
598 | "value"
599 | ],
600 | "type": "field"
601 | },
602 | {
603 | "params": [],
604 | "type": "mean"
605 | }
606 | ]
607 | ],
608 | "tags": [
609 | {
610 | "key": "hostname",
611 | "operator": "=~",
612 | "value": "/^$hostname$/"
613 | },
614 | {
615 | "condition": "AND",
616 | "key": "service",
617 | "operator": "=",
618 | "value": "Tray Status"
619 | },
620 | {
621 | "condition": "AND",
622 | "key": "metric",
623 | "operator": "=",
624 | "value": "Drawer_3"
625 | }
626 | ]
627 | },
628 | {
629 | "alias": "Drawer 4",
630 | "groupBy": [
631 | {
632 | "params": [
633 | "$__interval"
634 | ],
635 | "type": "time"
636 | },
637 | {
638 | "params": [
639 | "null"
640 | ],
641 | "type": "fill"
642 | }
643 | ],
644 | "orderByTime": "ASC",
645 | "policy": "default",
646 | "query": "SELECT \"value\" FROM \"snmp_printer\" WHERE (\"hostname\" =~ /^$hostname$/ AND \"service\" = 'Tray Status' AND \"metric\" = 'Drawer_4') AND $timeFilter",
647 | "rawQuery": true,
648 | "refId": "H",
649 | "resultFormat": "time_series",
650 | "select": [
651 | [
652 | {
653 | "params": [
654 | "value"
655 | ],
656 | "type": "field"
657 | },
658 | {
659 | "params": [],
660 | "type": "mean"
661 | }
662 | ]
663 | ],
664 | "tags": [
665 | {
666 | "key": "hostname",
667 | "operator": "=~",
668 | "value": "/^$hostname$/"
669 | },
670 | {
671 | "condition": "AND",
672 | "key": "service",
673 | "operator": "=",
674 | "value": "Tray Status"
675 | },
676 | {
677 | "condition": "AND",
678 | "key": "metric",
679 | "operator": "=",
680 | "value": "Drawer_4"
681 | }
682 | ]
683 | },
684 | {
685 | "alias": "Stack Bypass",
686 | "groupBy": [
687 | {
688 | "params": [
689 | "$__interval"
690 | ],
691 | "type": "time"
692 | },
693 | {
694 | "params": [
695 | "null"
696 | ],
697 | "type": "fill"
698 | }
699 | ],
700 | "orderByTime": "ASC",
701 | "policy": "default",
702 | "query": "SELECT \"value\" FROM \"snmp_printer\" WHERE (\"hostname\" =~ /^$hostname$/ AND \"service\" = 'Tray Status' AND \"metric\" = 'Stack_Bypass') AND $timeFilter",
703 | "rawQuery": true,
704 | "refId": "I",
705 | "resultFormat": "time_series",
706 | "select": [
707 | [
708 | {
709 | "params": [
710 | "value"
711 | ],
712 | "type": "field"
713 | },
714 | {
715 | "params": [],
716 | "type": "mean"
717 | }
718 | ]
719 | ],
720 | "tags": [
721 | {
722 | "key": "hostname",
723 | "operator": "=~",
724 | "value": "/^$hostname$/"
725 | },
726 | {
727 | "condition": "AND",
728 | "key": "service",
729 | "operator": "=",
730 | "value": "Tray Status"
731 | },
732 | {
733 | "condition": "AND",
734 | "key": "metric",
735 | "operator": "=",
736 | "value": "Stack_Bypass"
737 | }
738 | ]
739 | },
740 | {
741 | "alias": "MP Tray",
742 | "groupBy": [
743 | {
744 | "params": [
745 | "$__interval"
746 | ],
747 | "type": "time"
748 | },
749 | {
750 | "params": [
751 | "null"
752 | ],
753 | "type": "fill"
754 | }
755 | ],
756 | "orderByTime": "ASC",
757 | "policy": "default",
758 | "query": "SELECT \"value\" FROM \"snmp_printer\" WHERE (\"hostname\" =~ /^$hostname$/ AND \"service\" = 'Tray Status' AND \"metric\" = 'MP_Tray') AND $timeFilter",
759 | "rawQuery": true,
760 | "refId": "I",
761 | "resultFormat": "time_series",
762 | "select": [
763 | [
764 | {
765 | "params": [
766 | "value"
767 | ],
768 | "type": "field"
769 | },
770 | {
771 | "params": [],
772 | "type": "mean"
773 | }
774 | ]
775 | ],
776 | "tags": [
777 | {
778 | "key": "hostname",
779 | "operator": "=~",
780 | "value": "/^$hostname$/"
781 | },
782 | {
783 | "condition": "AND",
784 | "key": "service",
785 | "operator": "=",
786 | "value": "Tray Status"
787 | },
788 | {
789 | "condition": "AND",
790 | "key": "metric",
791 | "operator": "=",
792 | "value": "MP_Tray"
793 | }
794 | ]
795 | },
796 | {
797 | "alias": "Mp Tray",
798 | "groupBy": [
799 | {
800 | "params": [
801 | "$__interval"
802 | ],
803 | "type": "time"
804 | },
805 | {
806 | "params": [
807 | "null"
808 | ],
809 | "type": "fill"
810 | }
811 | ],
812 | "orderByTime": "ASC",
813 | "policy": "default",
814 | "query": "SELECT \"value\" FROM \"snmp_printer\" WHERE (\"hostname\" =~ /^$hostname$/ AND \"service\" = 'Tray Status' AND \"metric\" = 'Mp_Tray') AND $timeFilter",
815 | "rawQuery": true,
816 | "refId": "I",
817 | "resultFormat": "time_series",
818 | "select": [
819 | [
820 | {
821 | "params": [
822 | "value"
823 | ],
824 | "type": "field"
825 | },
826 | {
827 | "params": [],
828 | "type": "mean"
829 | }
830 | ]
831 | ],
832 | "tags": [
833 | {
834 | "key": "hostname",
835 | "operator": "=~",
836 | "value": "/^$hostname$/"
837 | },
838 | {
839 | "condition": "AND",
840 | "key": "service",
841 | "operator": "=",
842 | "value": "Tray Status"
843 | },
844 | {
845 | "condition": "AND",
846 | "key": "metric",
847 | "operator": "=",
848 | "value": "Mp_Tray"
849 | }
850 | ]
851 | },
852 | {
853 | "alias": "Multi-purpose_Tray",
854 | "groupBy": [
855 | {
856 | "params": [
857 | "$__interval"
858 | ],
859 | "type": "time"
860 | },
861 | {
862 | "params": [
863 | "null"
864 | ],
865 | "type": "fill"
866 | }
867 | ],
868 | "orderByTime": "ASC",
869 | "policy": "default",
870 | "query": "SELECT \"value\" FROM \"snmp_printer\" WHERE (\"hostname\" =~ /^$hostname$/ AND \"service\" = 'Tray Status' AND \"metric\" = 'Multi-purpose_Tray') AND $timeFilter",
871 | "rawQuery": true,
872 | "refId": "I",
873 | "resultFormat": "time_series",
874 | "select": [
875 | [
876 | {
877 | "params": [
878 | "value"
879 | ],
880 | "type": "field"
881 | },
882 | {
883 | "params": [],
884 | "type": "mean"
885 | }
886 | ]
887 | ],
888 | "tags": [
889 | {
890 | "key": "hostname",
891 | "operator": "=~",
892 | "value": "/^$hostname$/"
893 | },
894 | {
895 | "condition": "AND",
896 | "key": "service",
897 | "operator": "=",
898 | "value": "Tray Status"
899 | },
900 | {
901 | "condition": "AND",
902 | "key": "metric",
903 | "operator": "=",
904 | "value": "Multi-purpose_Tray"
905 | }
906 | ]
907 | },
908 | {
909 | "alias": "Manual Paper",
910 | "groupBy": [
911 | {
912 | "params": [
913 | "$__interval"
914 | ],
915 | "type": "time"
916 | },
917 | {
918 | "params": [
919 | "null"
920 | ],
921 | "type": "fill"
922 | }
923 | ],
924 | "orderByTime": "ASC",
925 | "policy": "default",
926 | "query": "SELECT \"value\" FROM \"snmp_printer\" WHERE (\"hostname\" =~ /^$hostname$/ AND \"service\" = 'Tray Status' AND \"metric\" = 'Manual_Paper') AND $timeFilter",
927 | "rawQuery": true,
928 | "refId": "I",
929 | "resultFormat": "time_series",
930 | "select": [
931 | [
932 | {
933 | "params": [
934 | "value"
935 | ],
936 | "type": "field"
937 | },
938 | {
939 | "params": [],
940 | "type": "mean"
941 | }
942 | ]
943 | ],
944 | "tags": [
945 | {
946 | "key": "hostname",
947 | "operator": "=~",
948 | "value": "/^$hostname$/"
949 | },
950 | {
951 | "condition": "AND",
952 | "key": "service",
953 | "operator": "=",
954 | "value": "Tray Status"
955 | },
956 | {
957 | "condition": "AND",
958 | "key": "metric",
959 | "operator": "=",
960 | "value": "Manual_Paper"
961 | }
962 | ]
963 | },
964 | {
965 | "alias": "Manual Envelope",
966 | "groupBy": [
967 | {
968 | "params": [
969 | "$__interval"
970 | ],
971 | "type": "time"
972 | },
973 | {
974 | "params": [
975 | "null"
976 | ],
977 | "type": "fill"
978 | }
979 | ],
980 | "orderByTime": "ASC",
981 | "policy": "default",
982 | "query": "SELECT \"value\" FROM \"snmp_printer\" WHERE (\"hostname\" =~ /^$hostname$/ AND \"service\" = 'Tray Status' AND \"metric\" = 'Manual_Envelope') AND $timeFilter",
983 | "rawQuery": true,
984 | "refId": "I",
985 | "resultFormat": "time_series",
986 | "select": [
987 | [
988 | {
989 | "params": [
990 | "value"
991 | ],
992 | "type": "field"
993 | },
994 | {
995 | "params": [],
996 | "type": "mean"
997 | }
998 | ]
999 | ],
1000 | "tags": [
1001 | {
1002 | "key": "hostname",
1003 | "operator": "=~",
1004 | "value": "/^$hostname$/"
1005 | },
1006 | {
1007 | "condition": "AND",
1008 | "key": "service",
1009 | "operator": "=",
1010 | "value": "Tray Status"
1011 | },
1012 | {
1013 | "condition": "AND",
1014 | "key": "metric",
1015 | "operator": "=",
1016 | "value": "Manual_Envelope"
1017 | }
1018 | ]
1019 | }
1020 | ],
1021 | "thresholds": [],
1022 | "timeFrom": null,
1023 | "timeRegions": [],
1024 | "timeShift": null,
1025 | "title": "$service",
1026 | "tooltip": {
1027 | "shared": true,
1028 | "sort": 0,
1029 | "value_type": "individual"
1030 | },
1031 | "transparent": true,
1032 | "type": "graph",
1033 | "xaxis": {
1034 | "buckets": null,
1035 | "mode": "time",
1036 | "name": null,
1037 | "show": true,
1038 | "values": []
1039 | },
1040 | "yaxes": [
1041 | {
1042 | "format": "short",
1043 | "label": null,
1044 | "logBase": 1,
1045 | "max": "2.5",
1046 | "min": "0",
1047 | "show": true
1048 | },
1049 | {
1050 | "format": "short",
1051 | "label": null,
1052 | "logBase": 1,
1053 | "max": null,
1054 | "min": null,
1055 | "show": false
1056 | }
1057 | ],
1058 | "yaxis": {
1059 | "align": false,
1060 | "alignLevel": null
1061 | }
1062 | },
1063 | {
1064 | "aliasColors": {
1065 | "Black": "rgb(0, 0, 0)",
1066 | "Black Imaging Unit": "#000000",
1067 | "Clean Rollers": "#2393ba",
1068 | "Color Imaging Kit": "#c76fb6",
1069 | "Cyan": "#00ffff",
1070 | "Document Feeder Kit": "dark-blue",
1071 | "Fuser": "#ba8823",
1072 | "Gelb": "yellow",
1073 | "Magenta": "#ff00ff",
1074 | "Maintenance Kit": "#ba232a",
1075 | "Puncher Waste": "#ff99cc",
1076 | "Saddle Staples": "#999966",
1077 | "Schwarz": "rgb(0, 0, 0)",
1078 | "Stapler": "#996600",
1079 | "Staples": "#996600",
1080 | "Transfer Unit": "#49ba23",
1081 | "Yellow": "yellow"
1082 | },
1083 | "bars": false,
1084 | "cacheTimeout": null,
1085 | "dashLength": 10,
1086 | "dashes": false,
1087 | "datasource": "${DS_INFLUXDB}",
1088 | "fill": 0,
1089 | "fillGradient": 0,
1090 | "gridPos": {
1091 | "h": 9,
1092 | "w": 12,
1093 | "x": 0,
1094 | "y": 16
1095 | },
1096 | "hiddenSeries": false,
1097 | "id": 1,
1098 | "legend": {
1099 | "alignAsTable": false,
1100 | "avg": false,
1101 | "current": false,
1102 | "max": false,
1103 | "min": false,
1104 | "show": true,
1105 | "total": false,
1106 | "values": false
1107 | },
1108 | "lines": true,
1109 | "linewidth": 2,
1110 | "links": [],
1111 | "nullPointMode": "connected",
1112 | "options": {
1113 | "dataLinks": []
1114 | },
1115 | "percentage": false,
1116 | "pluginVersion": "6.5.2",
1117 | "pointradius": 2,
1118 | "points": false,
1119 | "renderer": "flot",
1120 | "seriesOverrides": [],
1121 | "spaceLength": 10,
1122 | "stack": false,
1123 | "steppedLine": false,
1124 | "targets": [
1125 | {
1126 | "alias": "Black",
1127 | "groupBy": [],
1128 | "measurement": "snmp_printer",
1129 | "orderByTime": "ASC",
1130 | "policy": "default",
1131 | "query": "SELECT \"value\" FROM \"snmp_printer\" WHERE (\"hostname\" =~ /^$hostname$/ AND \"service\" = 'Consumables Status' AND \"metric\" = 'Black_Toner' ) AND $timeFilter",
1132 | "rawQuery": false,
1133 | "refId": "A",
1134 | "resultFormat": "time_series",
1135 | "select": [
1136 | [
1137 | {
1138 | "params": [
1139 | "value"
1140 | ],
1141 | "type": "field"
1142 | }
1143 | ]
1144 | ],
1145 | "tags": [
1146 | {
1147 | "key": "hostname",
1148 | "operator": "=~",
1149 | "value": "/^$hostname$/"
1150 | },
1151 | {
1152 | "condition": "AND",
1153 | "key": "service",
1154 | "operator": "=",
1155 | "value": "Consumables Status"
1156 | },
1157 | {
1158 | "condition": "AND",
1159 | "key": "metric",
1160 | "operator": "=",
1161 | "value": "Black_Toner"
1162 | }
1163 | ]
1164 | },
1165 | {
1166 | "alias": "Schwarz",
1167 | "groupBy": [],
1168 | "measurement": "snmp_printer",
1169 | "orderByTime": "ASC",
1170 | "policy": "default",
1171 | "query": "SELECT \"value\" FROM \"snmp_printer\" WHERE (\"hostname\" =~ /^$hostname$/ AND \"service\" = 'Consumables Status' AND \"metric\" = 'Schwarz_Toner' ) AND $timeFilter",
1172 | "rawQuery": false,
1173 | "refId": "A",
1174 | "resultFormat": "time_series",
1175 | "select": [
1176 | [
1177 | {
1178 | "params": [
1179 | "value"
1180 | ],
1181 | "type": "field"
1182 | }
1183 | ]
1184 | ],
1185 | "tags": [
1186 | {
1187 | "key": "hostname",
1188 | "operator": "=~",
1189 | "value": "/^$hostname$/"
1190 | },
1191 | {
1192 | "condition": "AND",
1193 | "key": "service",
1194 | "operator": "=",
1195 | "value": "Consumables Status"
1196 | },
1197 | {
1198 | "condition": "AND",
1199 | "key": "metric",
1200 | "operator": "=",
1201 | "value": "Schwarz_Toner"
1202 | }
1203 | ]
1204 | },
1205 | {
1206 | "alias": "Cyan",
1207 | "groupBy": [],
1208 | "measurement": "snmp_printer",
1209 | "orderByTime": "ASC",
1210 | "policy": "default",
1211 | "refId": "B",
1212 | "resultFormat": "time_series",
1213 | "select": [
1214 | [
1215 | {
1216 | "params": [
1217 | "value"
1218 | ],
1219 | "type": "field"
1220 | }
1221 | ]
1222 | ],
1223 | "tags": [
1224 | {
1225 | "key": "hostname",
1226 | "operator": "=~",
1227 | "value": "/^$hostname$/"
1228 | },
1229 | {
1230 | "condition": "AND",
1231 | "key": "service",
1232 | "operator": "=",
1233 | "value": "Consumables Status"
1234 | },
1235 | {
1236 | "condition": "AND",
1237 | "key": "metric",
1238 | "operator": "=",
1239 | "value": "Cyan_Toner"
1240 | }
1241 | ]
1242 | },
1243 | {
1244 | "alias": "Magenta",
1245 | "groupBy": [],
1246 | "measurement": "snmp_printer",
1247 | "orderByTime": "ASC",
1248 | "policy": "default",
1249 | "refId": "C",
1250 | "resultFormat": "time_series",
1251 | "select": [
1252 | [
1253 | {
1254 | "params": [
1255 | "value"
1256 | ],
1257 | "type": "field"
1258 | }
1259 | ]
1260 | ],
1261 | "tags": [
1262 | {
1263 | "key": "hostname",
1264 | "operator": "=~",
1265 | "value": "/^$hostname$/"
1266 | },
1267 | {
1268 | "condition": "AND",
1269 | "key": "service",
1270 | "operator": "=",
1271 | "value": "Consumables Status"
1272 | },
1273 | {
1274 | "condition": "AND",
1275 | "key": "metric",
1276 | "operator": "=",
1277 | "value": "Magenta_Toner"
1278 | }
1279 | ]
1280 | },
1281 | {
1282 | "alias": "Gelb",
1283 | "groupBy": [],
1284 | "measurement": "snmp_printer",
1285 | "orderByTime": "ASC",
1286 | "policy": "default",
1287 | "refId": "D",
1288 | "resultFormat": "time_series",
1289 | "select": [
1290 | [
1291 | {
1292 | "params": [
1293 | "value"
1294 | ],
1295 | "type": "field"
1296 | }
1297 | ]
1298 | ],
1299 | "tags": [
1300 | {
1301 | "key": "hostname",
1302 | "operator": "=~",
1303 | "value": "/^$hostname$/"
1304 | },
1305 | {
1306 | "condition": "AND",
1307 | "key": "service",
1308 | "operator": "=",
1309 | "value": "Consumables Status"
1310 | },
1311 | {
1312 | "condition": "AND",
1313 | "key": "metric",
1314 | "operator": "=",
1315 | "value": "Gelb_Toner"
1316 | }
1317 | ]
1318 | },
1319 | {
1320 | "alias": "Yellow",
1321 | "groupBy": [],
1322 | "measurement": "snmp_printer",
1323 | "orderByTime": "ASC",
1324 | "policy": "default",
1325 | "refId": "D",
1326 | "resultFormat": "time_series",
1327 | "select": [
1328 | [
1329 | {
1330 | "params": [
1331 | "value"
1332 | ],
1333 | "type": "field"
1334 | }
1335 | ]
1336 | ],
1337 | "tags": [
1338 | {
1339 | "key": "hostname",
1340 | "operator": "=~",
1341 | "value": "/^$hostname$/"
1342 | },
1343 | {
1344 | "condition": "AND",
1345 | "key": "service",
1346 | "operator": "=",
1347 | "value": "Consumables Status"
1348 | },
1349 | {
1350 | "condition": "AND",
1351 | "key": "metric",
1352 | "operator": "=",
1353 | "value": "Yellow_Toner"
1354 | }
1355 | ]
1356 | },
1357 | {
1358 | "alias": "Clean Rollers",
1359 | "groupBy": [],
1360 | "measurement": "snmp_printer",
1361 | "orderByTime": "ASC",
1362 | "policy": "default",
1363 | "refId": "E",
1364 | "resultFormat": "time_series",
1365 | "select": [
1366 | [
1367 | {
1368 | "params": [
1369 | "value"
1370 | ],
1371 | "type": "field"
1372 | }
1373 | ]
1374 | ],
1375 | "tags": [
1376 | {
1377 | "key": "hostname",
1378 | "operator": "=~",
1379 | "value": "/^$hostname$/"
1380 | },
1381 | {
1382 | "condition": "AND",
1383 | "key": "service",
1384 | "operator": "=",
1385 | "value": "Consumables Status"
1386 | },
1387 | {
1388 | "condition": "AND",
1389 | "key": "metric",
1390 | "operator": "=",
1391 | "value": "Clean_Rollers"
1392 | }
1393 | ]
1394 | },
1395 | {
1396 | "alias": "Transfer Unit",
1397 | "groupBy": [],
1398 | "measurement": "snmp_printer",
1399 | "orderByTime": "ASC",
1400 | "policy": "default",
1401 | "refId": "F",
1402 | "resultFormat": "time_series",
1403 | "select": [
1404 | [
1405 | {
1406 | "params": [
1407 | "value"
1408 | ],
1409 | "type": "field"
1410 | }
1411 | ]
1412 | ],
1413 | "tags": [
1414 | {
1415 | "key": "hostname",
1416 | "operator": "=~",
1417 | "value": "/^$hostname$/"
1418 | },
1419 | {
1420 | "condition": "AND",
1421 | "key": "service",
1422 | "operator": "=",
1423 | "value": "Consumables Status"
1424 | },
1425 | {
1426 | "condition": "AND",
1427 | "key": "metric",
1428 | "operator": "=",
1429 | "value": "Transfer_Unit"
1430 | }
1431 | ]
1432 | },
1433 | {
1434 | "alias": "Fuser",
1435 | "groupBy": [],
1436 | "measurement": "snmp_printer",
1437 | "orderByTime": "ASC",
1438 | "policy": "default",
1439 | "refId": "G",
1440 | "resultFormat": "time_series",
1441 | "select": [
1442 | [
1443 | {
1444 | "params": [
1445 | "value"
1446 | ],
1447 | "type": "field"
1448 | }
1449 | ]
1450 | ],
1451 | "tags": [
1452 | {
1453 | "key": "hostname",
1454 | "operator": "=~",
1455 | "value": "/^$hostname$/"
1456 | },
1457 | {
1458 | "condition": "AND",
1459 | "key": "service",
1460 | "operator": "=",
1461 | "value": "Consumables Status"
1462 | },
1463 | {
1464 | "condition": "AND",
1465 | "key": "metric",
1466 | "operator": "=",
1467 | "value": "Fuser"
1468 | }
1469 | ]
1470 | },
1471 | {
1472 | "alias": "Maintenance Kit",
1473 | "groupBy": [],
1474 | "measurement": "snmp_printer",
1475 | "orderByTime": "ASC",
1476 | "policy": "default",
1477 | "refId": "H",
1478 | "resultFormat": "time_series",
1479 | "select": [
1480 | [
1481 | {
1482 | "params": [
1483 | "value"
1484 | ],
1485 | "type": "field"
1486 | }
1487 | ]
1488 | ],
1489 | "tags": [
1490 | {
1491 | "key": "hostname",
1492 | "operator": "=~",
1493 | "value": "/^$hostname$/"
1494 | },
1495 | {
1496 | "condition": "AND",
1497 | "key": "service",
1498 | "operator": "=",
1499 | "value": "Consumables Status"
1500 | },
1501 | {
1502 | "condition": "AND",
1503 | "key": "metric",
1504 | "operator": "=",
1505 | "value": "Maintenance_Kit"
1506 | }
1507 | ]
1508 | },
1509 | {
1510 | "alias": "Document Feeder Kit",
1511 | "groupBy": [],
1512 | "measurement": "snmp_printer",
1513 | "orderByTime": "ASC",
1514 | "policy": "default",
1515 | "query": "SELECT \"value\" FROM \"snmp_printer\" WHERE (\"hostname\" =~ /^$hostname$/ AND \"service\" = 'Consumables Status' AND \"metric\" = 'Document_Feeder_Kit') AND $timeFilter",
1516 | "rawQuery": false,
1517 | "refId": "I",
1518 | "resultFormat": "time_series",
1519 | "select": [
1520 | [
1521 | {
1522 | "params": [
1523 | "value"
1524 | ],
1525 | "type": "field"
1526 | }
1527 | ]
1528 | ],
1529 | "tags": [
1530 | {
1531 | "key": "hostname",
1532 | "operator": "=~",
1533 | "value": "/^$hostname$/"
1534 | },
1535 | {
1536 | "condition": "AND",
1537 | "key": "service",
1538 | "operator": "=",
1539 | "value": "Consumables Status"
1540 | },
1541 | {
1542 | "condition": "AND",
1543 | "key": "metric",
1544 | "operator": "=",
1545 | "value": "Document_Feeder_Kit"
1546 | }
1547 | ]
1548 | },
1549 | {
1550 | "alias": "Stapler",
1551 | "groupBy": [],
1552 | "measurement": "snmp_printer",
1553 | "orderByTime": "ASC",
1554 | "policy": "default",
1555 | "query": "SELECT \"value\" FROM \"snmp_printer\" WHERE (\"hostname\" =~ /^$hostname$/ AND \"service\" = 'Consumables Status' AND \"metric\" = 'Staples') AND $timeFilter",
1556 | "rawQuery": false,
1557 | "refId": "J",
1558 | "resultFormat": "time_series",
1559 | "select": [
1560 | [
1561 | {
1562 | "params": [
1563 | "value"
1564 | ],
1565 | "type": "field"
1566 | }
1567 | ]
1568 | ],
1569 | "tags": [
1570 | {
1571 | "key": "hostname",
1572 | "operator": "=~",
1573 | "value": "/^$hostname$/"
1574 | },
1575 | {
1576 | "condition": "AND",
1577 | "key": "service",
1578 | "operator": "=",
1579 | "value": "Consumables Status"
1580 | },
1581 | {
1582 | "condition": "AND",
1583 | "key": "metric",
1584 | "operator": "=",
1585 | "value": "Stapler"
1586 | }
1587 | ]
1588 | },
1589 | {
1590 | "alias": "Staples",
1591 | "groupBy": [],
1592 | "measurement": "snmp_printer",
1593 | "orderByTime": "ASC",
1594 | "policy": "default",
1595 | "query": "SELECT \"value\" FROM \"snmp_printer\" WHERE (\"hostname\" =~ /^$hostname$/ AND \"service\" = 'Consumables Status' AND \"metric\" = 'Staples') AND $timeFilter",
1596 | "rawQuery": false,
1597 | "refId": "K",
1598 | "resultFormat": "time_series",
1599 | "select": [
1600 | [
1601 | {
1602 | "params": [
1603 | "value"
1604 | ],
1605 | "type": "field"
1606 | }
1607 | ]
1608 | ],
1609 | "tags": [
1610 | {
1611 | "key": "hostname",
1612 | "operator": "=~",
1613 | "value": "/^$hostname$/"
1614 | },
1615 | {
1616 | "condition": "AND",
1617 | "key": "service",
1618 | "operator": "=",
1619 | "value": "Consumables Status"
1620 | },
1621 | {
1622 | "condition": "AND",
1623 | "key": "metric",
1624 | "operator": "=",
1625 | "value": "Staples"
1626 | }
1627 | ]
1628 | },
1629 | {
1630 | "alias": "Saddle Staples",
1631 | "groupBy": [],
1632 | "measurement": "snmp_printer",
1633 | "orderByTime": "ASC",
1634 | "policy": "default",
1635 | "query": "SELECT \"value\" FROM \"snmp_printer\" WHERE (\"hostname\" =~ /^$hostname$/ AND \"service\" = 'Consumables Status' AND \"metric\" = 'Saddle_Staples') AND $timeFilter",
1636 | "rawQuery": false,
1637 | "refId": "L",
1638 | "resultFormat": "time_series",
1639 | "select": [
1640 | [
1641 | {
1642 | "params": [
1643 | "value"
1644 | ],
1645 | "type": "field"
1646 | }
1647 | ]
1648 | ],
1649 | "tags": [
1650 | {
1651 | "key": "hostname",
1652 | "operator": "=~",
1653 | "value": "/^$hostname$/"
1654 | },
1655 | {
1656 | "condition": "AND",
1657 | "key": "service",
1658 | "operator": "=",
1659 | "value": "Consumables Status"
1660 | },
1661 | {
1662 | "condition": "AND",
1663 | "key": "metric",
1664 | "operator": "=",
1665 | "value": "Saddle_Staples"
1666 | }
1667 | ]
1668 | },
1669 | {
1670 | "alias": "Puncher Waste",
1671 | "groupBy": [],
1672 | "measurement": "snmp_printer",
1673 | "orderByTime": "ASC",
1674 | "policy": "default",
1675 | "query": "SELECT \"value\" FROM \"snmp_printer\" WHERE (\"hostname\" =~ /^$hostname$/ AND \"service\" = 'Consumables Status' AND \"metric\" = 'Puncher_Waste') AND $timeFilter",
1676 | "rawQuery": false,
1677 | "refId": "M",
1678 | "resultFormat": "time_series",
1679 | "select": [
1680 | [
1681 | {
1682 | "params": [
1683 | "value"
1684 | ],
1685 | "type": "field"
1686 | }
1687 | ]
1688 | ],
1689 | "tags": [
1690 | {
1691 | "key": "hostname",
1692 | "operator": "=~",
1693 | "value": "/^$hostname$/"
1694 | },
1695 | {
1696 | "condition": "AND",
1697 | "key": "service",
1698 | "operator": "=",
1699 | "value": "Consumables Status"
1700 | },
1701 | {
1702 | "condition": "AND",
1703 | "key": "metric",
1704 | "operator": "=",
1705 | "value": "Puncher_Waste"
1706 | }
1707 | ]
1708 | },
1709 | {
1710 | "alias": "Color Imaging Kit",
1711 | "groupBy": [],
1712 | "measurement": "snmp_printer",
1713 | "orderByTime": "ASC",
1714 | "policy": "default",
1715 | "query": "SELECT \"value\" FROM \"snmp_printer\" WHERE (\"hostname\" =~ /^$hostname$/ AND \"service\" = 'Consumables Status' AND \"metric\" = 'Color_Imaging_Kit') AND $timeFilter",
1716 | "rawQuery": false,
1717 | "refId": "M",
1718 | "resultFormat": "time_series",
1719 | "select": [
1720 | [
1721 | {
1722 | "params": [
1723 | "value"
1724 | ],
1725 | "type": "field"
1726 | }
1727 | ]
1728 | ],
1729 | "tags": [
1730 | {
1731 | "key": "hostname",
1732 | "operator": "=~",
1733 | "value": "/^$hostname$/"
1734 | },
1735 | {
1736 | "condition": "AND",
1737 | "key": "service",
1738 | "operator": "=",
1739 | "value": "Consumables Status"
1740 | },
1741 | {
1742 | "condition": "AND",
1743 | "key": "metric",
1744 | "operator": "=",
1745 | "value": "Color_Imaging_Kit"
1746 | }
1747 | ]
1748 | },
1749 | {
1750 | "alias": "Black Imaging Unit",
1751 | "groupBy": [],
1752 | "measurement": "snmp_printer",
1753 | "orderByTime": "ASC",
1754 | "policy": "default",
1755 | "query": "SELECT \"value\" FROM \"snmp_printer\" WHERE (\"hostname\" =~ /^$hostname$/ AND \"service\" = 'Consumables Status' AND \"metric\" = 'Black_Imaging_Unit') AND $timeFilter",
1756 | "rawQuery": false,
1757 | "refId": "M",
1758 | "resultFormat": "time_series",
1759 | "select": [
1760 | [
1761 | {
1762 | "params": [
1763 | "value"
1764 | ],
1765 | "type": "field"
1766 | }
1767 | ]
1768 | ],
1769 | "tags": [
1770 | {
1771 | "key": "hostname",
1772 | "operator": "=~",
1773 | "value": "/^$hostname$/"
1774 | },
1775 | {
1776 | "condition": "AND",
1777 | "key": "service",
1778 | "operator": "=",
1779 | "value": "Consumables Status"
1780 | },
1781 | {
1782 | "condition": "AND",
1783 | "key": "metric",
1784 | "operator": "=",
1785 | "value": "Black_Imaging_Unit"
1786 | }
1787 | ]
1788 | }
1789 | ],
1790 | "thresholds": [],
1791 | "timeFrom": null,
1792 | "timeRegions": [],
1793 | "timeShift": null,
1794 | "title": "$service",
1795 | "tooltip": {
1796 | "shared": true,
1797 | "sort": 0,
1798 | "value_type": "individual"
1799 | },
1800 | "transparent": true,
1801 | "type": "graph",
1802 | "xaxis": {
1803 | "buckets": null,
1804 | "mode": "time",
1805 | "name": null,
1806 | "show": true,
1807 | "values": []
1808 | },
1809 | "yaxes": [
1810 | {
1811 | "format": "short",
1812 | "label": null,
1813 | "logBase": 1,
1814 | "max": "100",
1815 | "min": "0",
1816 | "show": true
1817 | },
1818 | {
1819 | "format": "short",
1820 | "label": null,
1821 | "logBase": 1,
1822 | "max": null,
1823 | "min": null,
1824 | "show": false
1825 | }
1826 | ],
1827 | "yaxis": {
1828 | "align": false,
1829 | "alignLevel": null
1830 | }
1831 | }
1832 | ],
1833 | "refresh": false,
1834 | "schemaVersion": 22,
1835 | "style": "dark",
1836 | "tags": [],
1837 | "templating": {
1838 | "list": [
1839 | {
1840 | "allValue": null,
1841 | "current": {},
1842 | "datasource": "${DS_INFLUXDB}",
1843 | "definition": "SHOW TAG VALUES WITH KEY = \"hostname\"",
1844 | "hide": 0,
1845 | "includeAll": false,
1846 | "index": -1,
1847 | "label": null,
1848 | "multi": false,
1849 | "name": "hostname",
1850 | "options": [],
1851 | "query": "SHOW TAG VALUES WITH KEY = \"hostname\"",
1852 | "refresh": 1,
1853 | "regex": "",
1854 | "skipUrlSync": false,
1855 | "sort": 0,
1856 | "tagValuesQuery": "",
1857 | "tags": [],
1858 | "tagsQuery": "",
1859 | "type": "query",
1860 | "useTags": false
1861 | },
1862 | {
1863 | "allValue": null,
1864 | "current": {},
1865 | "datasource": "${DS_INFLUXDB}",
1866 | "definition": "SHOW TAG VALUES WITH KEY = \"service\" where hostname =~ /^$hostname$/",
1867 | "hide": 0,
1868 | "includeAll": false,
1869 | "index": -1,
1870 | "label": null,
1871 | "multi": false,
1872 | "name": "service",
1873 | "options": [],
1874 | "query": "SHOW TAG VALUES WITH KEY = \"service\" where hostname =~ /^$hostname$/",
1875 | "refresh": 1,
1876 | "regex": "",
1877 | "skipUrlSync": false,
1878 | "sort": 0,
1879 | "tagValuesQuery": "",
1880 | "tags": [],
1881 | "tagsQuery": "",
1882 | "type": "query",
1883 | "useTags": false
1884 | },
1885 | {
1886 | "allValue": null,
1887 | "current": {},
1888 | "datasource": "${DS_INFLUXDB}",
1889 | "definition": "SHOW MEASUREMENTS where hostname =~ /^$hostname$/",
1890 | "hide": 0,
1891 | "includeAll": false,
1892 | "index": -1,
1893 | "label": null,
1894 | "multi": false,
1895 | "name": "command",
1896 | "options": [],
1897 | "query": "SHOW MEASUREMENTS where hostname =~ /^$hostname$/",
1898 | "refresh": 1,
1899 | "regex": "",
1900 | "skipUrlSync": false,
1901 | "sort": 0,
1902 | "tagValuesQuery": "",
1903 | "tags": [],
1904 | "tagsQuery": "",
1905 | "type": "query",
1906 | "useTags": false
1907 | }
1908 | ]
1909 | },
1910 | "time": {
1911 | "from": "now-3h",
1912 | "to": "now"
1913 | },
1914 | "timepicker": {
1915 | "refresh_intervals": [
1916 | "5s",
1917 | "10s",
1918 | "30s",
1919 | "1m",
1920 | "5m",
1921 | "15m",
1922 | "30m",
1923 | "1h",
1924 | "2h",
1925 | "1d"
1926 | ]
1927 | },
1928 | "timezone": "",
1929 | "title": "printer-metrics",
1930 | "uid": "NPbC04YZk",
1931 | "variables": {
1932 | "list": []
1933 | },
1934 | "version": 50
1935 | }
1936 |
--------------------------------------------------------------------------------