Monitor Printers with Nagios 3

by Mike on January 18, 2009 · 2 comments

in Nagios, Server Security, Uncategorized

Nagios allows you to monitor network printers so that you will easily be able to verify basic information about your network printers. This will allow you to check if the printer is up and basic toner states.  It will not provide a whole lot of information but if you want more you can always log into the network printer and get more info if you want.  Why use Nagios for printers if you can log into a network printer?  Well it provides one central location for checking on servers, printers, routers, etc.  And it will notify according to your settings.

Create a directory for printer information.
mkdir /etc/nagios3/printers

Edit the /etc/nagios3/nagios.cfg to point to the new directory.  Uncomment the printer line.

#cfg_dir=/etc/nagios3/servers
cfg_dir=/etc/nagios3/printers
#cfg_dir=/etc/nagios3/switches
#cfg_dir=/etc/nagios3/routers

Create the file for printers
Now, you will need to create all of this information in the file.  So you will need to create a generic-printer, set up a host, create a group and define your services.  The information here is for an HP 4300dn printer.

###############################################################################
#
# HOST DEFINITIONS
#
##############################################################################

define host{
name                    generic-printer
use                     generic-host
check_period            24×7
check_interval          5
retry_interval          1
max_check_attempts      10
check_command           check-host-alive
notification_period     workhours
notification_interval   30
notification_options    d,r
contact_groups          admins
register                0               ; JUST A TEMPLATE
}

# Define a host for the printer we’ll be monitoring
# Change the host_name, alias, and address to fit your situation

define host{
use             generic-printer         ; Inherit default values from a template
host_name       hp4300                  ; The name we’re giving to this printer
alias           HP LaserJet 4300dn      ; A longer name associated with the printer
address         192.168.5.11            ; IP address of the printer
hostgroups      network-printers        ; Host groups this printer is associated with
}

###############################################################################
#
# HOST GROUP DEFINITIONS
#
##############################################################################

# A hostgroup for network printers

define hostgroup{
hostgroup_name  network-printers        ; The name of the hostgroup
alias           Network Printers        ; Long name of the group
}

###############################################################################
#
# SERVICE DEFINITIONS
#
##############################################################################

# Create a service for monitoring the status of the printer
# Change the host_name to match the name of the host you defined above
# If the printer has an SNMP community string other than “public”, change the # check_command directive to reflect that

define service{
use                     generic-service         ; from a template
host_name               hp4300                  ; host
service_description     Printer Status          ; service description
check_command           check_hpjd!-C public    ; command
normal_check_interval   10                  ; Check  10 minutes
retry_check_interval    1                   ; Re-check
}

# Create a service for “pinging” the printer occasionally.  Useful for
# monitoring RTA, packet loss, etc.

define service{
use                     generic-service
host_name               hp4300
service_description     PING
check_command           check_ping!3000.0,80%!5000.0,100%
normal_check_interval   10
retry_check_interval    1
}

Once you have created the printer.cfg file be sure to restart nagios3.

sudo /etc/init.d/nagios3 restart

If you get errors you will need to fix them.

The services for the printer are to check the printer status and toner using the  check_hpjd.  This is a very common program that is easy to use.  There are other printer checking programs that you can find at http://www.nagiosexchange.org.

Here you can see the Ping status and the printer status for the HP 4300.

If you select the Printer Status in the web interface you will see additional information about the printer.

{ 1 comment }

Joe June 12, 2009 at 2:29 pm

I have used this hpjd before and it seems to work very well for “most” but there are a few newer printers and old printers that do not work even though they are HP, for example an hp4350 will look like this Hex-STRING: 42 6C 61 63 6B 20 43 61 72 74 72 69 64 67 65 20 48 50 20 43 43 33 36 34 58 00 = 54.00% and some printers just say nothing.

{ 1 trackback }

Previous post:

Next post: