device auto-discovery and printer monitoring configuration for nagios

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. ... headers above omitted ... ############################################################################### # PRINTER DEFINITIONS below ############################################################################### define host{ use xerox-printer-so host_name tokyochuo-printer-3 alias tokyochuo-printer-3 (FUJI XEROX DocuCentre-III C440 3) address 192.49.64.10 } define host{ use xerox-printer-so host_name tokyochuo-printer-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

Upload: martoncs

Post on 28-Dec-2015

25 views

Category:

Documents


0 download

DESCRIPTION

Device Auto-Discovery and Printer Monitoring Configuration for Nagios.pdf

TRANSCRIPT

Page 1: Device Auto-Discovery and Printer Monitoring Configuration for Nagios

Frank4DD, @2009

Introduction

Entering host system data into Nagios can be cumbersome if we have hundreds of devices. An auto-discoveryfeature would be nice. something that could find systems on the network and automatically generates hostconfiguration 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 IPassignments for network printers fall into a certain IP range per network and, lucky for me while unlucky forsecurity, all printers have an unchanged default SNMP community string "public". As a result, I could write asmall script that checks if a IP responds to a SNMP query returning the device type, then using this device typeto identify printer types and finally writing it out to a Nagios configuration file. To help with naming theprinter, I generated a network list source file containing a network name and network base IP which is read bythe script.

About an hour later, I had my first configuration file containing the details of 382 printers located in 120networks, ready to load into Nagios. I run a slightly modified script again for a second set of networks, since Iwanted to separate them into a different nagios configuration file. In less then 90 minutes, I had the full 528printers ready for monitoring, using the printer plugin from monitoring exchange. This search method could beapplied to auto-discover other SNMP-enabled systems, our biggest device group in monitoring are networkdevices 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.

... headers above omitted ...################################################################################ PRINTER DEFINITIONS below###############################################################################define host{ use xerox-printer-so host_name tokyochuo-printer-3 alias tokyochuo-printer-3 (FUJI XEROX DocuCentre-III C440 3) address 192.49.64.10}define host{ use xerox-printer-so host_name tokyochuo-printer-4

Printer MonitoringDevice discovery, auto-generating monitoring configurations for Nagios

AboutNagios LiveNagios GraphsDocumentationNagios PluginsNagios HowToHome

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

Page 2: Device Auto-Discovery and Printer Monitoring Configuration for Nagios

alias tokyochuo-printer-4 (FUJI XEROX DocuPrint 3050 4) address 192.49.64.11}define host{ use kyocera-printer-so host_name yokohama-printer-1 alias yokohama-printer-1 (KYOCERA LS-C5016N 1) address 192.49.67.4}... and so on ...

After finishing the "discovery" and loading the configuration into nagios.cfg, the main printer hostgroup isshowing 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, availablefrom monitoring exchange (local copy).

libexec/check_printer -H 192.168.103.61 -C publicCRITICAL - "004-416 The Second Bias Transfer Roll assembly must be replaced.Call your System Administrator. Printing can continue."

Depending on the point of view: We got lucky, our printer responds, and already reports an error. Before wecontinue, 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 cancreate the plugin command and service definition. I am adding all printers to the new service, using theirrespective groups.

vi /srv/app/nagios/etc/objects/commands.cfg# 'define check_printer' test with ./check_printer -H 192.168.103.61 -C publicdefine command{ command_name check_printer command_line $USER1$/check_printer -H $HOSTADDRESS$ -C $ARG1$}

vi /srv/app/nagios/etc/objects/printer-services.cfg################################################################################ printer-services.cfg - First define a servicegroup for printer services###############################################################################

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

Page 3: Device Auto-Discovery and Printer Monitoring Configuration for Nagios

define servicegroup{ servicegroup_name printer-checks ; The name of the hostgroup alias Printer Health Checks ; Long name of the group}################################################################################ Define the memory check template service###############################################################################define service{ name generic-printer-service active_checks_enabled 1 passive_checks_enabled 1 parallelize_check 1 obsess_over_service 1 check_freshness 0 notifications_enabled 1 event_handler_enabled 1 flap_detection_enabled 1 failure_prediction_enabled 1 process_perf_data 1 retain_status_information 1 retain_nonstatus_information 1 is_volatile 0 check_period 12x5_weekdays ; nobody cares about nighttime max_check_attempts 3 normal_check_interval 30 retry_check_interval 2 contact_groups printer-admins notification_options u,c,r notification_interval 1440 ; notify only once a day notification_period 12x5_weekdays ; don't wake anybody up register 0 servicegroups printer-checks}################################################################################ Check Printer Status using the generic check_printer plugin###############################################################################define service { use generic-printer-service hostgroup printers-headoffice service_description printer-check check_command check_printer!public}define service { use generic-printer-service hostgroup printers-salesoffice service_description printer-check check_command check_printer!public}

After enabling the service in nagios.cfg, the printer health monitoring was complete. And just by sheernumbers, some printers have issues. They might be simply switched off, have a hardware issue, the toner getslow... Enough work to follow up for the printer admins. With email notification and online monitoring ourprinter 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

Page 4: Device Auto-Discovery and Printer Monitoring Configuration for Nagios

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