Adding Hosts to Nagios

Source: Internet
Author: User

In my first Nagios tutorial I talked your through the instillation process required for Nagios if you had not yet install Ed Nagios follow my tutorial, installing Nagios on Ubuntu.

In this tutorial we is going to go through adding hosts to Nagios, sounds simple rite, well there's a bit more to it then You are think, but it is not too difficult and its great to the see Nagios in action after all this time setting it up.

So where to start, well that's look at the structure of the Nagios config files, this diagram outlines how all the Config Files link together.





Unless you changed it your config files should is in THE/USR/LOCAL/NAGIOS/ETC:

Notes on Config Files

    1. Lines that start with # is ignored buy Nagios so is used as human readable comments
    2. Variables is case-sensitive
    3. Variables must start at the beginning for a line, no white space before them.

Main Configuration File
This file is the read first buy the Nagios Daemon, basically it job is-to-point to the rest of the configuration files, if we Make a new config file "We need to add" to the "before" Nagios can read it.

Resource File
This is where user created macros was stored, however the main purpose of these files is to hide sensitive information, su Ch as password, from the CGI ' s

Object Definition Files
This is the where we define hosts, services, host groups, contacts, contact groups, commands, etc... Basically this is were your define anything you want Nagios to monitor and choose what you want it to monitor them.

CGI Config File
This is where you outline the CGI's configuration, this also have a reference to the main config file so the cig's know how You configured Nagios.

Ok, so now that's actually add some settings, first make a new object definition file buy typing:

and adding the following lines to it:

# Define A host for the local machinedefine host{use Linux-server; Name of the host template to use; This host definition would inherit all variables is defined;        In (or inherited by) the Linux-server host template definition.         Host_name google.com alias google.com address www.google.com }############################################################################################################## ################################################## SERVICE definitions########################################## ###############################################################################################################          ####### Define A service to ' ping ' the local machinedefine service{use Generic-service ; Name of service TEmplate to use host_name google.com service_description PING check_ Command check_ping!100.0,20%!500.0,60%}# Define a service to check HTTP on the local machine.# D                             Isable notifications for the This service by default, as is not all users could have an HTTP enabled.define service{use Generic-service; Name of service template to use host_name google.com service_description H TTP Check_command check_http notifications_enabled 0}

Now edit your main config file to tell it the location of the new config file:

sudo nano/usr/local/nagios/etc/nagios.cfg

Add the folowwing line to the file

Cfg_file=/usr/local/nagios/etc/objects/newhost.cfg

Now restart your Nagios daemon:

and hay presto your Nagios server is now monitoring Google. Ok So how do all this work, well first lets go through the newhosts.cfg file:

Define Host
Here we define a new host:
Use linux-server: We use linux-server because it the easiest template to use and more on this later

host_name google.com: This is the host name, the "How do you reference your hosts settings, it doesn ' t has to be it address just something mea Ningful related to the host

alias google.com: This was the long name for the host, and this was only used for display purposes

address www.google.com: This is important, it the actual address for the host, either a DNS name or IP address would work here.



Define Service
Were we define the services on each host, for Google we be only going to check if it alive (ping) and check to SE e if its Web server is running (HTTP). We need to both services for this, however the settings is the same for each:

Use The. The service template, use Generic-serivce are the standard template.

host_name This is where we reference what host we want the service connected to and use the name of the host defined earlier.

service_description This is the name of the user would see on the Nagios Web page

Check_command This is the command we have going to run to test if the service is running, and more on commands later.

So what is about the nagios.cfg, why do we add that line to it, well as we created a new CFG file we need to tell Nagios ABO UT it, you can either has one massive file for each host or make a new file for each one, however if do a new file For each one that has to add it to the nagios.cfg.

Rite, hopefully that have explained the hosts file to your, now would is a good idea to add your own Hosts, start with Somet Hing another website, try "yahoo.com", if you encounter problems check my config file for Google and Yahoo! E. Remember to restart Nagios after changing all config files with:

If you get any errors when restarting run the following command to check for problems with your config files

Sudo/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg

Leave any comments for feeback.

Adding Hosts to Nagios

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.