13.07.2015 Views

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 3 ■ MONITORING AND UPDATING3-6. Defining Nagios CommandsIf the existing Nagios commands don’t meet your needs, it’s possible to define new ones. For example,say you are running more than one domain on a single web server. If you just want to check that a webserver is responding to HTTP requests, the existing check_http command is fine. However, this won’tcheck that all your web sites are actually responding OK. To do this, first edit commands.cfg and add thefollowing lines:define command{command_namecommand_line}check_http-website1/usr/lib/nagios/plugins/check_http -H website1.example.comCreate similar commands for as many web sites as you have. Then edit the web server’s host configfile (for example, conf.d/host-webserver.cfg) to include service for each command:define service{host_namewebserverservice_description website1check_commandcheck_http-website1usegeneric-servicenotification_interval 1440}This can go in any file; I find it neatest to keep it with the web server configuration. Restart Nagios,and you’re done.3-7. Writing a Nagios Plug-InNagios has a plug-in system to make it easily extensible in a variety of ways. Check out http://nagiosplugins.org/ for a repository of plug-ins that are user-supplied and available for you todownload.■ Note Running /usr/lib/nagios/plugins/plugin_name -h will get you help output for a particular plug-in.It’s also pretty straightforward to write your own plug-in. Plug-ins live in /usr/lib/nagios/plugins/,and the file /usr/lib/nagios/plugins/utils.sh provides a few useful functions and fixed variables foryou to use. This is a generalized plug-in that takes a single argument (see the next recipe for one way ofusing plug-ins like this) and checks to see whether the process named by the argument is running:01 #! /bin/sh0203 PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin0471Download at WoweBook.Com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!