PROBLEM
I need the ability to monitor my Atmail installation.
ENVIRONMENT
- On-Premise Server + WebMail Installations: Version 6.0 > Current Version
- Webmail Only Installations: Version 6.0 > Current Version
CAUSE
- No monitoring of my Atmail installation
RESOLUTION
One of the many challenges with having a mailserver is keeping everything running. Problems can occur unexpectedly, and this may affect your service continuity for your end-users.
In Atmail, we use many monitoring and maintenance tools so that we may keep an eye on everything. One of these tools is Nagios.
Nagios is a powerful monitoring system that enables organizations to identify and resolve IT infrastructure problems before they affect critical business processes. It provides you with instant awareness of your organization's mission-critical IT infrastructure. Nagios allows you to detect and repair problems and mitigate future issues before they affect end-users and customers.
At the base level, Nagios can send you reports of any issues with your services as they occur. This document aims to provide a basic example of how to install, setup, and use Nagios for your own Atmail (or third-party) systems.
Installing Nagios
This installation documentation focuses on installing Nagios on a CentOS/Fedora operating system, or a close derivative. RPM or binary packages may exist for your own system. This document details a source installation, from the raw tar files.
Prerequisites
Before installing Nagios, make sure you have the following packages:
- Apache
- PHP
- GCC compiler
- GD development libraries
Downloading and Installing Nagios
Create the nagios user:
useradd -m nagios |
Create a directory for storing the downloads.
mkdir /home/atmail/downloads cd /home/atmail/downloads |
Download the source code tarballs of both Nagios and the Nagios plugins (visit http://www.nagios.org/download/ for links to the latest versions). These directions were tested with Nagios 3.1.1 and Nagios Plugins 2.0.3.
wget http: //prdownloads .sourceforge.net /sourceforge/nagios/nagios-3 .2.3. tar .gz
wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz |
Unpack the Nagios package:
tar xzf nagios-3.2.3. tar .gz cd nagios-3.2.3 |
Run the Nagios configure script, passing the name of the group you created earlier like so:
. /configure --with- command -group=nagios |
Compile the Nagios source code.
make all |
Install binaries, init script, sample config files and set permissions on the external command directory.
make install make install -init make install -config make install -commandmode |
Install the Nagios web config file in the Apache conf.d directory.
make install -webconf |
Create a nagiosadmin account for logging into the Nagios web interface. This command will prompt you for a password that you can use to login to Nagios from the web.
htpasswd -c /usr/local/nagios/etc/htpasswd . users nagiosadmin |
Restart Apache to make the new settings take effect.
service httpd restart |
Unpack the Nagios plugins:
cd /home/atmail/downloads tar xzf
cd nagios-plugins-2.0.3.tar.gz |
Compile and install the plugins.
. /configure --with-nagios-user=nagios --with-nagios-group=nagios make make install |
Add Nagios to the list of system services and have it automatically start when the system boots.
chkconfig --add nagios chkconfig nagios on |
Verify the sample Nagios configuration files.
/usr/local/nagios/bin/nagios - v /usr/local/nagios/etc/nagios .cfg |
If there are no errors, start Nagios.
/etc/init .d /nagios start |
Configuring Nagios
You can now open your main Nagios configuration file. This is in /usr/local/nagios/etc/nagios.cfg. At the top, append your local configuration file. For the purposes of this document, we will put it in /usr/local/nagios/etc/objects/atmail.cfg.
cfg_file = /usr/local/nagios/etc/objects/atmail.cfg |
You can copy a template that comes by default called localhost.cfg:
cp - pr /usr/local/nagios/etc/objects/localhost .cfg /usr/local/nagios/etc/objects/atmail .cfg |
In the file, you can now put your hostnames. Let's assume that your server is in 192.168.0.6 , with the hostname atmail.local:
define host{ use linux-server host_name atmail.local alias atmail.local address 192.168.0.6 } |
This will be the template that will be used during service checks. host_name points to your server's hostname. alias is what it will be referred to in the logs and in the web interface. address will contain the IP of your server.
You can now define the services that you want to monitor. The service definition part of the configuration file is marked as such:
############################################################################### ############################################################################### # # SERVICE DEFINITIONS # ############################################################################### ############################################################################### |
Below this, you can set the services to monitor. The service checks rely on Nagios' plugins that are executed via another template called commands.cfg. For example, a service check that verifies that your HTTP server is running would look like:
define service{ use l ocal-service ; Name of service template to use host_name atmail.local service_description Atmail.local HTTP check_command check_http } |
The use flag sets the template. The host_name flag sets which host you want to check. The service_description flag sets what it shows up as in the logs and web interface. Finally, the check_command flag defines the check used to verify the service. In this case, we're checking atmail.local if the HTTP (Port 80) service is still active.
Conversely, an IMAP check would look like:
define service{ use l ocal-service host_name atmail.local check_command check_imap service_description Atmail.local IMAP } |
A complete service check block for IMAP, SMTP, POP, and HTTP would look like:
define service{ use local -service ; Name of service template to use host_name atmail. local service_description Atmail. local HTTP check_command check_http } define service{ use local -service ; Name of service template to use host_name atmail. local service_description Atmail. local SSH check_command check_ssh } define service{ use local -service host_name atmail. local service_description Atmail. local SMTP check_command check_smtp } define service{ use l ocal -service host_name atmail. local check_command check_imap service_description Atmail. local IMAP } define service{ use local -service host_name atmail. local check_command check_mysql service_description Atmail. local MYSQL } |
Now, you can define the contacts where emails will be sent to, in case something goes wrong. Open up /usr/local/nagios/etc/objects/contacts.cfg, and define your first contact. It will look like:
define contact{ contact_name nagiosadmin ; Short name of user use g eneric-contact ; Inherit default values ; from generic-contact ; template (defined above) alias John Wayne ; Full name of user email nagios@atmail.com } |
contact_name refers to the name it will be referenced to in the configure file. use defines the template to use. alias refers to what the contact will be referred to in the configuration files. email refers to the email where service notifications will be set.
Now you're ready! Restart Nagios to apply changes:
/etc/init .d /nagios restart |
Example Configuration Files
To get you started, your Nagios configuration can look like this:
atmail.cfg
############################################################################### ############################################################################### # # HOST DEFINITION # ############################################################################### ############################################################################### define host{ use l inux-server host_name atmail.local alias atmail.local address 192.168.0.6 } ############################################################################### ############################################################################### # # SERVICE DEFINITIONS # ############################################################################### ############################################################################### define service{ use l ocal-service host_name atmail.local service_description atmail.local HTTP check_command check_http } define service{ use l ocal-service host_name atmail.local service_description atmail.local SSH check_command check_ssh } define service{ use l ocal-service host_name atmail.local service_description atmail.local SMTP check_command check_smtp } define service{ use l ocal-service host_name atmail.local check_command check_imap service_description atmail.local IMAP } define service{ use l ocal-service host_name atmail.local check_command check_mysql service_description atmail.local MYSQL } |
contacts.cfg
define contact{ contact_name nagiosadmin ; Short name of user use g eneric-contact ; Inherit default values ; from generic-contact ; template (defined above) alias John Wayne ; Full name of user email nagios@atmail.com } |
Comments