Sie sind auf Seite 1von 4

Frank4DD, @2009

Introduction
Entering host system data into Nagios can be cumbersome if we have hundreds of devices. An auto-discovery
feature would be nice. something that could find systems on the network and automatically generates host
configuration items for Nagios.
When I took the task to add 500 printers to Nagios, doing so by hand was out of the question. Luckily, our IP
assignments for network printers fall into a certain IP range per network and, lucky for me while unlucky for
security, all printers have an unchanged default SNMP community string "public". As a result, I could write a
small script that checks if a IP responds to a SNMP query returning the device type, then using this device type
to identify printer types and finally writing it out to a Nagios configuration file. To help with naming the
printer, I generated a network list source file containing a network name and network base IP which is read by
the script.
About an hour later, I had my first configuration file containing the details of 382 printers located in 120
networks, ready to load into Nagios. I run a slightly modified script again for a second set of networks, since I
wanted to separate them into a different nagios configuration file. In less then 90 minutes, I had the full 528
printers ready for monitoring, using the printer plugin from monitoring exchange. This search method could be
applied to auto-discover other SNMP-enabled systems, our biggest device group in monitoring are network
devices such as switches and routers (Currently, I have 700+).
printerconf-gen-so.sh, the example Nagios auto-discovery script <download here>
Here is a example output, generated with the printerconf-gen-so.sh script above.
. . . header s above omi t t ed . . .
###############################################################################
# PRI NTER DEFI NI TI ONS bel ow
###############################################################################
def i ne host {
use xer ox- pr i nt er - so
host _name t okyochuo- pr i nt er - 3
al i as t okyochuo- pr i nt er - 3 ( FUJ I XEROX DocuCent r e- I I I C440 3)
addr ess 192. 49. 64. 10
}
def i ne host {
use xer ox- pr i nt er - so
host _name t okyochuo- pr i nt er - 4
Printer Monitoring
Device discovery, auto-generating monitoring configurations for Nagios
About
Nagios Live
Nagios Graphs
Documentation
Nagios Plugins
Nagios HowTo
Home
Device Auto-Discovery and Printer Monitoring Configuration for Nagios http://nagios.frank4dd.com/howto/nagios-device-discovery.htm
1 of 4 4/4/2013 12:45 PM
al i as t okyochuo- pr i nt er - 4 ( FUJ I XEROX DocuPr i nt 3050 4)
addr ess 192. 49. 64. 11
}
def i ne host {
use kyocer a- pr i nt er - so
host _name yokohama- pr i nt er - 1
al i as yokohama- pr i nt er - 1 ( KYOCERA LS- C5016N 1)
addr ess 192. 49. 67. 4
}
. . . and so on . . .
After finishing the "discovery" and loading the configuration into nagios.cfg, the main printer hostgroup is
showing all 528 printers.
After we got the printer hosts defined, we only need to add a health check service to monitor their status.
Picking out one printer close by as a test object, I decided to try the check_printer-0.13.tar.gz plugin, available
from monitoring exchange (local copy).
l i bexec/ check_pr i nt er - H 192. 168. 103. 61 - C publ i c
CRI TI CAL - "004- 416 The Second Bi as Tr ansf er Rol l assembl y must be r epl aced.
Cal l your Syst emAdmi ni st r at or . Pr i nt i ng can cont i nue. "
Depending on the point of view: We got lucky, our printer responds, and already reports an error. Before we
continue, lets verify directly on the printers web management interface if the reported error is correct.
Indeed, we have an issue with the second Bias transfer roll on this printer, so the plugin works. Now we can
create the plugin command and service definition. I am adding all printers to the new service, using their
respective groups.
vi / sr v/ app/ nagi os/ et c/ obj ect s/ commands. cf g
# ' def i ne check_pr i nt er ' t est wi t h . / check_pr i nt er - H 192. 168. 103. 61 - C publ i c
def i ne command{
command_name check_pr i nt er
command_l i ne $USER1$/ check_pr i nt er - H $HOSTADDRESS$ - C $ARG1$
}
vi / sr v/ app/ nagi os/ et c/ obj ect s/ pr i nt er - ser vi ces. cf g
###############################################################################
# pr i nt er - ser vi ces. cf g - Fi r st def i ne a ser vi cegr oup f or pr i nt er ser vi ces
###############################################################################
Device Auto-Discovery and Printer Monitoring Configuration for Nagios http://nagios.frank4dd.com/howto/nagios-device-discovery.htm
2 of 4 4/4/2013 12:45 PM
def i ne ser vi cegr oup{
ser vi cegr oup_name pr i nt er - checks ; The name of t he host gr oup
al i as Pr i nt er Heal t h Checks ; Long name of t he gr oup
}
###############################################################################
# Def i ne t he memor y check t empl at e ser vi ce
###############################################################################
def i ne ser vi ce{
name gener i c- pr i nt er - ser vi ce
act i ve_checks_enabl ed 1
passi ve_checks_enabl ed 1
par al l el i ze_check 1
obsess_over _ser vi ce 1
check_f r eshness 0
not i f i cat i ons_enabl ed 1
event _handl er _enabl ed 1
f l ap_det ect i on_enabl ed 1
f ai l ur e_pr edi ct i on_enabl ed 1
pr ocess_per f _dat a 1
r et ai n_st at us_i nf or mat i on 1
r et ai n_nonst at us_i nf or mat i on 1
i s_vol at i l e 0
check_per i od 12x5_weekdays ; nobody car es about ni ght t i me
max_check_at t empt s 3
nor mal _check_i nt er val 30
r et r y_check_i nt er val 2
cont act _gr oups pr i nt er - admi ns
not i f i cat i on_opt i ons u, c, r
not i f i cat i on_i nt er val 1440 ; not i f y onl y once a day
not i f i cat i on_per i od 12x5_weekdays ; don' t wake anybody up
r egi st er 0
ser vi cegr oups pr i nt er - checks
}
###############################################################################
# Check Pr i nt er St at us usi ng t he gener i c check_pr i nt er pl ugi n
###############################################################################
def i ne ser vi ce {
use gener i c- pr i nt er - ser vi ce
host gr oup pr i nt er s- headof f i ce
ser vi ce_descr i pt i on pr i nt er - check
check_command check_pr i nt er ! publ i c
}
def i ne ser vi ce {
use gener i c- pr i nt er - ser vi ce
host gr oup pr i nt er s- sal esof f i ce
ser vi ce_descr i pt i on pr i nt er - check
check_command check_pr i nt er ! publ i c
}
After enabling the service in nagios.cfg, the printer health monitoring was complete. And just by sheer
numbers, some printers have issues. They might be simply switched off, have a hardware issue, the toner gets
low... Enough work to follow up for the printer admins. With email notification and online monitoring our
printer management is now pro-active, identifying HW issues and ordering toner before printing stops.
Credits, Links and additonal information
Nagios and the Nagios community can be found at http://www.nagios.org/
Further Nagios documentation is available here http://nagios.frank4dd.com/docs/en/
Device Auto-Discovery and Printer Monitoring Configuration for Nagios http://nagios.frank4dd.com/howto/nagios-device-discovery.htm
3 of 4 4/4/2013 12:45 PM
Example images from Nagios, showing the printer monitoring

1 comment
Best Community

Share
Reply
printer cartridge 8 days ago
I am very much overwhelmed by your thoughts for this particular story.

0
0
Share
Device Auto-Discovery and Printer Monitoring Configuration for Nagios http://nagios.frank4dd.com/howto/nagios-device-discovery.htm
4 of 4 4/4/2013 12:45 PM

Das könnte Ihnen auch gefallen