Up To: Contents
See Also: Monitoring Publicly Available Services
Introduction
This document describes how you can monitor the status of networked printers. Specifically, HP printers that have internal/external JetDirect cards/devices, or other print servers (like the Troy PocketPro 100S or the Netgear PS101) that support the JetDirect protocol.
The check_hpjd plugin (which is part of the standard Nagios plugins distribution) allows you to monitor the status of JetDirect-capable printers which have SNMP enabled. The plugin is capable of detecting the following printer states:
Notes:
Creating Required Definitions
You'll need to create some object definitions in order to monitor a new printer. These definitions can be placed in their own file or added to an already exiting object configuration file.
First, its best practice to create a new template for each different type of host you'll be monitoring. Let's create a new template for printers.
define host{ name generic-printer ; The name of this host template use generic-host ; Inherit default values from the generic-host template check_period 24x7 ; By default, printers are monitored round the clock check_interval 5 ; Actively check the printer every 5 minutes retry_interval 1 ; Schedule host check retries at 1 minute intervals max_check_attempts 10 ; Check each printer 10 times (max) check_command check-host-alive ; Default command to check if printers are "alive" notification_period workhours ; Printers are only used during the workday notification_interval 30 ; Resend notifications every 30 minutes notification_options d,r ; Only send notifications for specific host states contact_groups admins ; Notifications get sent to the admins by default register 0 ; DONT REGISTER THIS - ITS JUST A TEMPLATE }
Notice that the printer template definition is inheriting default values from the generic-host template, which is defined in the sample localhost.cfg file.
Next, define a new host for the printer that references the newly created generic-printer host template.
define host{ use generic-printer ; Inherit default values from a template host_name hplj2605dn ; The name we're giving to this printer alias HP LaserJet 2605dn ; A longer name associated with the printer address 192.168.1.30 ; IP address of the printer hostgroups allhosts ; Host groups this printer is associated with }
Add an optional hostgroup for printers. This is useful if you create additional printers in the future and want to view them together in the CGIs. It can also be useful for object definition tricks that you can use to manage larger configurations later on.
define hostgroup{ hostgroup_name laserjet-printers ; The name of the hostgroup alias HP LaserJet Printers ; Long name of the group members hplj2605dn ; Comma separated list of hosts that belong to this group }
The hplj2605dn host will be a member of two hostgroups - allhosts (which is referenced in the host definition and defined in localhost.cfg) and laserjet-printers (which is defined above).
Monitoring Printer Status
Now its time to define some services that should be associated with the printer. As mentioned earlier, the check_hpjd plugin allows you to monitor the current state of the printer. Let's use that plugin to define a service. Before we do that, it should be noted that there is already a command definition for using the check_hpjd plugin in service checks that has been defined in the commands.cfg file. That command definition looks like this...
define command{ command_name check_hpjd command_line $USER1$/check_hpjd -H $HOSTADDRESS$ $ARG1$ }
Let's create a service called Printer Status as follows...
define service{ use generic-service ; Inherit values from a template host_name hplj2605dn ; The name of the host the service is associated with service_description Printer Status ; The service description check_command check_hpjd!-C public ; The command used to monitor the service normal_check_interval 10 ; Check the service every 10 minutes under normal conditions retry_check_interval 1 ; Re-check the service every minute until its final/hard state is determined }
Notice that the check_command directive is passing "-C public" to the check_hpjd command. That argument gets put into the $ARG1$ macro in the command definition and tells the plugin that it should use an SNMP community string of "public" when checking the status of the printer.
That's it! You've just configured a new printer that should be monitored by Nagios. If you modify your configuration files to monitor a new printer, make sure you verify your configuration and restart Nagios.