
How to Use Nagios for IT Infrastructure Monitoring
Nagios has been a cornerstone of IT infrastructure monitoring for over two decades, helping organizations maintain uptime and prevent costly outages. This powerful open-source monitoring solution enables IT teams to track the health and performance of servers, network devices, applications, and services across complex infrastructures. In this comprehensive guide, you’ll learn how to implement Nagios effectively for your monitoring needs.
Table of Contents
- What is Nagios?
- Why Use Nagios for Infrastructure Monitoring
- Installing Nagios Core
- Basic Configuration Setup
- Adding Hosts and Services
- Configuring Notifications
- Working with Nagios Plugins
- Best Practices for Nagios Monitoring
What is Nagios?
Nagios is an open-source monitoring system that enables organizations to identify and resolve IT infrastructure problems before they affect critical business processes. It monitors entire IT infrastructure including servers, switches, applications, and services, providing administrators with real-time status information and alerting them to potential issues.
The Nagios ecosystem consists of Nagios Core, the basic engine that schedules checks and handles alerts, and various plugins that perform the actual monitoring tasks. This modular architecture makes Nagios incredibly flexible and extensible, capable of monitoring virtually any aspect of your infrastructure.
Why Use Nagios for Infrastructure Monitoring
Organizations choose Nagios for several compelling reasons. First, its open-source nature means zero licensing costs for the core software, making it accessible to businesses of all sizes. Second, its extensive plugin ecosystem supports monitoring of diverse systems and applications without requiring custom development.
Nagios excels at proactive monitoring, detecting problems before they escalate into major outages. The system can monitor network protocols like HTTP, SMTP, POP3, and ICMP, as well as server resources including processor load, disk usage, and system logs. For businesses running cloud infrastructure with providers like Kamatera, Nagios provides the visibility needed to ensure optimal performance across distributed environments.
Installing Nagios Core
Installing Nagios Core requires a Linux server with Apache web server, PHP, and required development libraries. Here’s how to install Nagios on Ubuntu or Debian-based systems:
Prerequisites Installation
First, update your system and install necessary packages:
sudo apt update
sudo apt install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.4 libgd-dev
Download and Install Nagios Core
Download the latest Nagios Core source code:
cd /tmp
wget https://github.com/NagiosEnterprises/nagioscore/releases/download/nagios-4.4.6/nagios-4.4.6.tar.gz
tar xzf nagios-4.4.6.tar.gz
cd nagios-4.4.6
Compile and install Nagios:
./configure --with-httpd-conf=/etc/apache2/sites-enabled
make all
sudo make install
sudo make install-init
sudo make install-commandmode
sudo make install-config
sudo make install-webconf
Create Nagios Admin User
Create an administrative user for the web interface:
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Basic Configuration Setup
Nagios configuration files are located in /usr/local/nagios/etc/. The main configuration file is nagios.cfg, which references other configuration files for hosts, services, contacts, and commands.
Understanding Configuration Structure
Nagios uses object-oriented configuration with several object types:
- Hosts: Physical or virtual machines to monitor
- Services: Specific aspects of hosts (HTTP, disk space, CPU load)
- Contacts: People who receive notifications
- Commands: Scripts or programs that perform checks
- Time Periods: Define when monitoring and notifications occur
Adding Hosts and Services
To monitor a host, create a configuration file in /usr/local/nagios/etc/objects/. Here’s an example host definition:
define host {
use linux-server
host_name webserver01
alias Web Server 01
address 192.168.1.100
max_check_attempts 5
check_period 24x7
notification_interval 30
notification_period 24x7
}
Defining Services
After defining hosts, add services to monitor specific aspects:
define service {
use generic-service
host_name webserver01
service_description HTTP
check_command check_http
max_check_attempts 3
check_interval 5
retry_interval 1
}
For organizations using employee monitoring tools like SentryPC, Nagios can monitor the availability and performance of such critical business applications to ensure continuous operation.
Configuring Notifications
Notifications alert administrators when issues arise. Configure contacts to receive alerts:
define contact {
contact_name admin
alias System Administrator
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
email admin@example.com
}
Email Notification Setup
Configure email notifications by setting up the mail command in commands.cfg and ensuring your server can send emails through a mail transfer agent like Postfix or Sendmail.
Working with Nagios Plugins
Nagios Plugins extend monitoring capabilities. Install the official plugin package:
cd /tmp
wget https://github.com/nagios-plugins/nagios-plugins/releases/download/release-2.3.3/nagios-plugins-2.3.3.tar.gz
tar xzf nagios-plugins-2.3.3.tar.gz
cd nagios-plugins-2.3.3
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
sudo make install
Common Plugin Examples
Plugins are executable scripts located in /usr/local/nagios/libexec/. Popular plugins include:
- check_ping: Tests host reachability
- check_http: Monitors web servers
- check_disk: Checks disk space usage
- check_load: Monitors system load
- check_ssh: Verifies SSH service availability
Best Practices for Nagios Monitoring
Organize Configuration Files
Separate configuration files by function or location. Create dedicated files for different server groups, departments, or geographic locations to maintain clarity as your infrastructure grows.
Set Appropriate Check Intervals
Balance monitoring frequency with system resources. Critical services might need checks every minute, while less critical resources can be checked every five or ten minutes.
Use Service Dependencies
Configure service dependencies to prevent alert storms. If a router fails, there’s no need to alert about all servers behind it being unreachable.
Implement Escalation Policies
Create escalation chains ensuring issues reach the right people. Start with first-level support and escalate to senior staff if problems aren’t resolved within specified timeframes.
Regular Configuration Testing
Before restarting Nagios, always verify configuration syntax:
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Monitor Nagios Itself
Set up monitoring for the Nagios server itself. Ensure adequate disk space, system resources, and service availability for your monitoring platform.
Document Your Setup
Maintain documentation of your monitoring configuration, including what’s being monitored, threshold values, notification procedures, and escalation paths. This documentation proves invaluable during emergencies and staff transitions.
Regular Updates and Maintenance
Keep Nagios Core, plugins, and the underlying operating system updated. Security patches and feature improvements ensure reliable monitoring performance.
Conclusion
Nagios remains a powerful, flexible solution for IT infrastructure monitoring. While the initial setup requires time and attention to detail, the result is a robust monitoring platform that provides visibility into your entire infrastructure. By following the steps outlined in this guide and implementing best practices, you’ll create a monitoring system that proactively identifies issues, reduces downtime, and helps maintain optimal performance across your IT environment. Whether you’re managing a handful of servers or a complex multi-site infrastructure, Nagios provides the tools needed to maintain reliable, high-performing systems.
Follow Networkyy
Join 125,000+ IT professionals:



