Posts Tagged ‘sysadmin’

Installing Mail Server on Nagios

Postfix Server Installation
First you need to install postfix;

 

When prompted, choose internet site, then enter the @ part where you wish the mail to be sent from, e.g nagios.notify. This will mean that emails received from nagios will be @nagios.notify.

 

 

Mailx Server Installation

 

Now install Nagios’s part of the mail server;

 

 

Configuring Nagios Mail Command

 

You need to edit the commands.cfg folder to take into account the new paths;

 

Replace;

 

With;

 

Note that the change is ‘/bin/mail’ to ‘/usr/bin/mailx’.

 

Now restart Nagios;

 

You should now receive email notifications of services/host states.

 

 

Enabling and Disabling Notifications for a Service

 

To disable notifications follows the steps below.

 

  1. Access the web interface;

  1. Choose Hosts or Services from the side menu (depending on which you wish to change).
  1. Select a service or host you wish to disable notifications for (note that HTTP and SSH notifications are disabled by default on localhost).
  1. On the page which opens, from the right hand section select the option ‘Disable Notifications’.
  1. This should open a page asking to confirm the host or host and service you wish to disable notifications for. Select ‘Commit’ to continue;
  1. From this page it will now show a page verifying that it has been complete. Make sure to select the option ‘Done';

 

This will return you to the homepage. Navigate back to the host/service (from 4.) and you will see at the bottom it shows Notifications in red and as ‘DISABLED’. Also the right hand menu has changed to give the option to ‘Enable’ notifications as they are currently disabled.

 

Configure Nagios

This will guide you through a basic setup of a host and some services for Nagios.

 

First thing to note is that Nagios Core has no web based UI for configuring hosts, services or commands.

 

 

Adding a Host

 

To start the configuration, add a host. You can choose the default location to create a hosts file;

 

Any new files/directories created must be added to nagios.cfg;

 

New files are added as follows;

 

Once you have created the new file, open it with your text editor;

 

A simple linux host is defined as follows;

 

The “use” part of this host definition is taken from;

 

Here you can choose the default settings for a host, e.g. contact groups, notifications enabled, retry attempts.

 

A full list of possible host definitions can be found here;

 

http://nagios.sourceforge.net/docs/3_0/objectdefinitions.html#host

 

If you wish to set a specific setting for just a few hosts, adding it to the hosts.cfg folder overrides the template.

 

 

Plugin Usage and Adding Commands

 

Commands are added through the commands.cfg file located here;

 

Adding a command requires a plugin for the command you wish to add, as well as knowledge on how to use the plugin.

 

The default locations for plugins you wish to add can be found here;

 

To know what command is required for a plugin to work, you can request help on the plugins usage;

 

Note that some plugins may require pre-requisites, which will be prompted when you attempt to use the plugin in the command line.

 

An example would be the plugin check_ping which has the following output when you use the “-h” argument;

 

This helps you understand how to define a command.

 

Now edit the commands.cfg file and look for the check_ping command definition;

 

– This is the name you use to define this command. This is used in the service definition to reference this command.

– This is defined in /usr/local/nagios/etc/objects/resources.cfg. In this case it defines the plugin directory being used (/usr/local/nagios/libexec).
“check_ping” requires the arguments -H, -w and -c.

 

– This defines the host which needs to be checked, and is common in nearly all plugins. The $HOSTADDRESS$ part is an inbuilt Nagios macro which uses the hostname defined in the service command. This won’t need to be defined in each service which uses this commands, as you will see below.

– This sets the warning value which is required for the plugin to work. The $ARG1$ is defined in the service command.

 

– This sets the critical value which is required for the plugin to work. The $ARG2$ is defined in the service command.

 

– This argument is an optional addition to the command definition. By not using $ARG3$ we are saying that every time this command is used, set “-p” to “5”.

Adding Services

 

Now you have a host and a command, you need a service!

 

This services config file can be created/found in the same place as the host file;

 

Remember to add this location to nagios.cfg if it isn’t already there.

 

Now you need to add some services to the config file for your host.

 

The service for ping is defined as follows;

 

With regards to the “check_command”, this is where you define the command to be used for this service by entering the “command_name” defined in commands.cfg.

 

– This is the “command_name”. This is always entered first.

 

After the command_name, you must enter the details for $ARG1$, $ARG2$, etc. These are separated by an exclamation mark, “!”.

 

– This the response time of the ping request. If it’s sufficient for this argument, you will receive a WARNING status.

 

– This the response time of the ping request. If it’s sufficient for this argument, you will receive a CRITICAL status.

As before, the “use” part is defined in templates.cfg.

 

A full list of service definitions can be found here;

http://nagios.sourceforge.net/docs/3_0/objectdefinitions.html#service

 

Adding a definition to services.cfg overrides the template.

You now have a new host configured with the ping service.

 

 

Hostgroups

 

If you will have, say, 10 linux servers, all requiring the “ping” command, it would be best to define a hostgroup in the host and service definitions instead of the host name.

 

A hostgroup is created as follows;

 

 

Note that when adding hostgroups/hostgroup_name to the host/service definitions, respectively, they are seperated by commas.

e.g.

These basic steps can be repeated for most plugins – the only differences come when using NRPE, NSCA, or a custom plugin, but even then the basics are essential, or when you are missing pre-requisites for the plugin to work.

When you are finished with your customization, run the command below to confirm that there are no issues with the configuration files;

Any problems are made apparent to you after running this command, telling you both the file and line where the error occurs.

 

This makes debugging errors very easy.

 

If there are no problems, you can restart nagios and head to the web page;

 

On a web browser;

http://<nagios server ip>/nagios

 

The following will be how the ping service is displayed;

 

Install Nagios on Ubuntu

The following is a guide to install Nagios Core on an Ubuntu machine.

 

Preparing for the Installation

 

First you will need to be root;

 

For convenience it is best to install ssh and vim;

 

Now you need to install some pre-requisites required for Nagios to correctly install/run;

 

Now add the user ‘nagios’ to the system;

 

Create nagcmd group to allow commands through the web;

 

 

Installing Nagios and the Plugins

 

First, make a directory to download the plugins to

 

Now you need to download Nagios and Nagios plugins;

 

Extracting Nagios so it can be compiled/installed;

 

Now you must run the install script and compile the source code;

 

Run the following command to install the web server

 

The next step is to create a password for the nagios web server login account, ‘nagiosadmin’

 

Remember this password as it is required to log on to the web interface.

 

Restart apache to apply the changes

 

Now you must extract the plugins;

 

Use the commands below to compile and install the plugins

 

Now configure Nagios to start on system start

 

Check the nagios configuration with the following command

 

Make note of this command, it is very important later on for debugging issues with config files.

 

If there are no errors, you are ready to start Nagios;

 

Now access the web interface from a web browser, navigating to
http://localhost/nagios/
or from within the network;
http://<hostname/ip>/nagios/
Congratulations, you are now done with the installation!

Please refer to our blog for a post on configuring your first host.

 

OUR BLOG

on July 5, 2018

We have started using medium for our blogging. Please click here to see our latest posts.

on February 9, 2015

BaseX Blog Introduction This 'Blurt/Blog' details my experiences of a recent

on December 4, 2013

iCosts - The Legal Costs Calculator - Demo http://youtu.be/P5pSAZzKi08

on December 4, 2013

Lync XMPP + Video - Demo http://youtu.be/aWpaxFGDwXY

Contact Us

9th Floor Capital House
40-42 Weston Street
London
SE1 3QD

sales@gltd.net 0207 100 1499 Follow us Like us

Specialists in integrated and flexible communications

Copyright © 2013 Globility Limited. All rights reserved.