Every organization wants to stay on top of the health and performance of its devices, applications, services, and overall infrastructure. Given today's complex networks and remote working culture, it's impossible to manually track the performance of your infrastructure, and this is where monitoring tools and platforms become critical.
Nagios is one such popular monitoring platform and in this article, we'll talk in detail about Nagios, its benefits and downsides, use cases, integrations, pricing, and more.
What's Nagios?
Nagios is an open-source monitoring platform for tracking the different aspects of your devices and networks. Originally, it was designed to work only on Linux systems, but today, it works well on Windows, UNIX, and all variations of Linux.
Nagios was built by Ethan Galstad and was first released in 1999 under the name “NetSaint”. Since then, many developers and experts have contributed to Nagios, and today, it continues to be the core platform on which many products have been built. The Nagios Enterprise has built many products on this core platform, with Nagios XI being the flagship product. Nagios XI is the enterprise version of Nagios Core and comes with many advanced features. Other popular products from the Nagios stable include the Nagios log server, network analyzer, and the Nagios Fusion.
In this article though, we will be talking only about the Nagios core and its capabilities.
So, what can Nagios Core do for your business? Let's find out.
Features of Nagios Core
At the heart of it all, the Nagios Core monitors the devices you want and sends alerts when there are changes or abnormalities in any of the monitored aspects. Here are some of the salient features of Nagios.
Extensible
One of the biggest draws of the Nagios core is its extendability. Being open-source, you can always take the code and customize it to meet your specific requirements. The entire source code is available and licensed under the GPL license.
Also, you have hundreds of add-ons developed by the Nagios community, and this means, you can extend the Nagios Core and its functionality without having to write extensive codes. Furthermore, it comes with hundreds of APIs to integrate with most of the popular dev tools available today.
All these aspects make Nagios Core a good choice if you want to have custom metrics, workflows, or just about any new implementation.
User Access
Users can easily access the status of your infrastructure at any time through an intuitive web interface. At the same time, you can also streamline access based on roles or departments to ensure that only authorized users can view the relevant data. Moreover, you can even ensure that some users see only the performance of those infrastructure components that are relevant to them. Such fine granular control enhances the overall security of your monitoring data.
In-depth Visibility
Another important feature of Nagios Core is the in-depth visibility it provides into your infrastructure through an intuitive dashboard that displays all relevant information in a central location. As you navigate through the dashboard, you can get detailed information about the status of different devices and components.
All this information can provide contextual information about issues and gaps, so you can fix them quickly. Moreover, you can configure Nagios to send alerts through email or SMS when some values cross the predetermined threshold levels. This platform comes with escalation capabilities as well to notify people who are higher up in the organizational hierarchy. The best part is that all this information can be accessed through a web interface.
From this feature, it's clear that Nagios core acts as a centralized platform to display information and help you take actions based on what's displayed. You can even automate event handlers to restart devices when certain events occur.
Comprehensive
Nagios core works well across a wide range of devices such as servers, desktops, applications, network protocols, services, operating systems, and any other infrastructure components. Needless to say, Nagios saves costs and effort as you don't need to install and maintain separate monitoring platforms for different devices.
You can also customize Nagios' capabilities for your infrastructure through its APIs and custom scripts and community-developed apps.
Advanced Reporting
Reports are an essential way to assess the current state of your infrastructure, and this is why Nagios Core offers an advanced reporting feature. With Nagios, you can view historical reports to understand a pattern. Likewise, availability reports help to meet Service Level Agreements (SLAs) with your vendors. You can also generate reports for strategy and decision-making, capacity planning, and more.
More importantly, you can add third-party components to generate just the reports you want.
Overall, Nagios Core comes with many handy features that provide all the information you need to understand the current state of your infrastructure and take the necessary steps to align the infrastructure performance with your business goals. In many ways, Nagios core plays a key role in bringing together the business and IT aspects of your business.
Now that you have a good idea of Nagios' features and the impact it can have on your business, let's get down to the technical areas, such as how to install and use this monitoring platform. But first, let's see what systems can run Nagios.
System Requirements
The system requirements are fairly basic to run Nagios. The only important requirement is a system that runs on Linux and has access to the network. It will also help if the system has a C compiler installed in it. Note that the C compiler is a requirement only if you are installing the source code.
Similarly, if you plan to use the CGIs that come with Nagios core, you need an Apache web server and Thomas Boutell's gd library v1.6.3 or higher.
Once you have the requirements in place, download Nagios Core. Click here to download.
Configuring Nagios
After you download and install Nagios, the next step is to configure it. Before we head into this process, note that the configuration process is elaborate and has multiple steps involved, so make sure to allocate some time and effort to it.
Nagios has four different configuration files:
- Main Config file
- Resource file – Can be more than one.
- CGI Config file
- Object Definition file – Can be more than one.
Let's see the role of each of these config files.
Main Config File
The main config file is where you control the Nagios core daemon. In this file, you'll include all the directives that your Nagios core daemon must follow to reach your monitoring objectives. Also, this file will be read by CGIs, in addition to the Nagios core daemon, so this is your starting point. This file is called nagios.cfg and is located in “/usr/local/nagios/etc/”.
The main config file has the following parameters:
- Log file The location where Nagios must create your main log file.
- Object configuration file Contains a list of object definitions that the daemon can use for monitoring.
- Object configuration directory The directory that contains all the object config files.
- Object cache file The cached copy where object definitions are stored.
- Status file The file name where the daemon stores the current state of operations.
- Nagios user The UID credentials that Nagios must use.
- Query socket Path to the query handler interface.
- Notifications option Determines if Nagios must send notifications.
- External command file The file that Nagios checks for executing external commands.
The above list is not exhaustive and is meant to give you an idea of what you can find in the main config file. Once you have all the parameters and their respective files, move to the resource files.
Resource File
Resource files are used for storing user-defined macros, including sensitive information such as passwords. These files are not available for CGIs and are read only by the main config file, based on the mapping you specify in the main config file. You can have more than one resource file, based on your needs.
Object Definition File
Like resource files, object definition files can also be more than one, and they are mapped to the main config file. These files contain definitions of different objects such as hosts, applications, services, contact groups, and more.
CGI Configuration File
This file contains information that impacts the working of CGIs. These are mapped to the main config file, so they know where to access the object definitions. Nagios expects this file to be named cgi.cgi and it must be located in the same directory as the main config file.
Some important configuration variables in these CGI files are:
- Main configuration file location This is the most important information that connects a CGI file to the main config file.
- Authentication usage Determines if the CGI can use the authentication of Nagios UID.
- Default user name Reduces the need for authentication.
- CGI refresh rate The time interval between page refreshes.
With this, your Nagios is configured and all set for use. Next, we'll talk about how you can start and stop this platform.
Starting Nagios
Before starting Nagios, make sure to do a sanity check of your configuration, as this will spot misconfigurations. Nagios will throw an error when some critical parameters are not mentioned in the config file.
Here's the code to run this sanity check.
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
After correcting the errors, you can start Nagios in either of the two below-mentioned ways.
Using the Init Script
The easiest way to start Nagios is through the init script. The code for this is:
/etc/rc.d/init.d/nagios start
Manual Start
If you don't have an init script, you can also start Nagios manually using the -d command, like this:
/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
Restarting Nagios
If you've made any changes to the config files, you must restart Nagios for the changes to take effect. You can restart using the init script,
/etc/rc.d/init.d/nagios reload
To do a manual restart, send a HUP signal, like this:
kill -HUP <nagios_pid>
Alternatively, you can also restart using the web interface.
Stopping Nagios
Stopping Nagios is similar to the restart process. On the web interface, navigate to Process Info > Shutdown the Nagios process or send a SIGTERM signal.
kill <nagios_pid>
If you're using the init script, your code to stop is,
/etc/rc.d/init.d/nagios stop
The above commands can get you started on Nagios. Next, let's look at some basic components to help you to use Nagios effectively.
Basic Components
Nagios core works around many internal and external components to efficiently monitor your infrastructure. In this section, let's look at some of these components.
Plugins
Plugins are scripts such as Perl, Python, Ruby, Shell scripts, etc. that check the status of a host or service. Nagios doesn't have an internal or automated mechanism for checking the status, and hence, relies only on these plugins.
At the time of writing this piece, plugins are available for UNIX, Linux, Windows, and Netware servers only. If you're looking for a specific plugin, you can search for it in the Nagios community or create one yourself.
When Nagios wants to check the status of a device, it activates the appropriate plugin. In turn, the plugin gathers information and sends it to Nagios core for further processing such as activating handlers, sending notifications, etc.
Macros
Macros are user-defined blocks of code that can be referenced with a single name. All that you have to do is call the macro in your Nagios code and the corresponding code present inside the macro will be substituted during execution. You can also pass inputs to a macro and get the output.
Some macros can also contain other macros. Nagios also supports some standard macros that are pre-written and execute a specific function.
Checks
Nagios carries out certain checks at regular intervals as defined in the object definition file. On-demand checks are also made when required. Note that Nagios will always perform an on-demand check when a service associated with a host changes state, as this has the potential to change the state of the host as well. For example, if the HTTP service associated with a device changed from FAILURE to OK, it indicates that the host is also up and running. This is why Nagios performs checks when certain events or changes occur.
There are four types of checks that Nagios handles:
- Host checks Works on a host
- Service checks Works on a service
- Active checks Initiated by Nagios and are often pre-scheduled
- Passive checks Ιnitiated by external processes that are submitted to Nagios
State Types
State types are the current state of a host or service, and Nagios supports two-state types – SOFT and HARD. Using these states, Nagios determines the monitoring logic and accordingly, executes event handlers, sends notifications, etc.
Time Periods
Time periods are definitions that determine when monitoring and its corresponding actions such as sending notifications must operate. These definitions contain many directives, such as the days and times of the week when notifications can be sent. Nagios will monitor and execute commands based on this definition.
Notifications
Nagios processes the host and service check logic to decide if it should send notifications. It makes this decision while processing the host or service status, and accordingly sends notifications to the contact details in the configuration file. Nagios also accepts filters for notifications. For example, you can ask
Nagios to send notifications to only those individuals in the contact list that belong to a certain department.
CGIs
Many CGIs are included with Nagios, with some of the prominent ones being:
- Status CGI Views the current state of all the hosts and services and is considered to be the most important.
- StatusMap CGI Creates a map of all the hosts.
- Config CGI This allows you to view all objects defined in config files.
- Event Log CGI Displays the log file
- History CGI Displays the history of problems for one or more hosts.
In all, these are the important components that can help to effectively use Nagios. You can leverage one or more of these components and create a workflow or logic to suit your business requirements.
Final Words
To conclude, monitoring is essential for today's complex network and Nagios Core is one of the popular monitoring platforms available today. It is open-source and free and can be customized to meet individual requirements for monitoring. In this article, we looked into the prominent features of Nagios to help understand if this tool is a good fit for your organization. Next, we went into the technical aspects and talked about how to configure, start, and stop Nagios. Lastly, we discussed the components that can help you make the most of what Nagios offers.
With this information, you're all set to install an =d configure Nagios for your infrastructure. Browse through www.ittsystems.com for more such informative guides.