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 UPDATINGdefine hostgroup {hostgroup_name debian-serversaliasDebian GNU/<strong>Linux</strong> Serversmembers localhost,webserver,ldapserver}Since all you’re really doing with a hostgroup is collecting machines together, there aren’t manyoptions to set: you should use the templates (see recipe 3-3 for template information) to set your defaultor standard options. What hostgroups do mean is that you can create as many basic host config files asyou like; I prefer to keep them in separate files, named by the machine name, but it’s not obligatory.Then you add them easily to hostgroups and use the hostgroups to define your service monitoring. Thisenables you to split machines up by their usage, operating system, or any other criteria you like.Machines can belong to more than one hostgroup.So, you have your client host, and you’ve added it to a webgroup; let’s call the group debianservers,as per the previous code snippet. Now, edit the conf.d/services_nagios2.cfg file to set up acouple of service checks for that hostgroup. Let’s set up checks to establish whether these hosts willreturn a ping and whether they’re accessible via SSH:define service {hostgroup_namedebian-serversservice_descriptionSSHcheck_commandcheck_sshusegeneric-servicenotification_interval 0}define service {hostgroup_namedebian-serversservice_descriptionPINGcheck_commandcheck_ping!100.0,20%!500.0,60%usegeneric-servicenotification_interval 0}In fact, what you will probably want is to define a group of machines that you expect to be SSHaccessibleand a group that you expect to be ping-accessible, and these two don’t have to be the same.For example, the default setup expects the gateway to be pingable, but you don’t necessarily expect it tobe accessible via SSH. But here I’ll just use the single group, because I currently have only one nonservermachine.Nagios will now check the machines in those groups for the services in the check_command statementwith the generic-service settings, and it will complain if it finds a problem.3-5. Setting Up Nagios AlertsThe Nagios web page is useful to have, but it’s not ideal to have to check the web page constantly forproblems. Instead, you can set up an alert, such as to your e-mail, to let you know about any problems.In recipe 3-1, you set up your contacts_nagios2.cfg file. This file also defines an admin contactgroup—using contact groups rather than individual users increases maintainability. If there’s apersonnel change, you need to change only the group membership, not any other references.69Download at WoweBook.Com

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

Saved successfully!

Ooh no, something went wrong!