Nagios is a monitoring system that monitors system running status and network information. Nagios can monitor specified local or remote hosts and services, and provide exception notification functions. Nagios can run on Linux/Unix platforms, at the same time, an optional browser-based WEB interface is provided to facilitate system administrators to view the network status, various system problems, and logs. Main features of Nagios:-monitoring network service (SMTP, POP3, HTTP, and NN Nagios) is a monitoring system that monitors system running status and network information. Nagios can monitor specified local or remote hosts and services, and provide exception notifications.
Nagios can run on Linux/Unix platforms and provides an optional browser-based WEB interface for system administrators to view network status, various system problems, and logs.
Main features of Nagios:
-Monitoring Network Services (SMTP, POP3, HTTP, NNTP, PING, etc)
-Monitor host resources (processes, disks, etc)
-The monitoring function of Nagios can be easily expanded with a simple plug-in design.
-Concurrent processing of services and other monitoring
-Error Notification function (via email, pager, or other user-defined methods)
-You can specify a Custom Event processing controller.
-An optional browser-based WEB interface allows system administrators to view network status, various system problems, and logs.
-You can view the system monitoring information on your mobile phone.
I. Preparations before installation
The installed machine must have a WEB service. This article is installed in the Apache environment.
Download the main nagios program and related plug-in packages
123 |
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.3.tar.gzwget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gzwget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz |
Install the GD library (required for statusmap and trends modules in Nagios)
1 |
apt-get install libgd2-noxpm libgd2-noxpm-dev |
2. Install Nagios monitoring
1. Create Nagios users and groups
Create a Nagios account
1 |
/usr/sbin/useradd -m -s /sbin/nologin nagios |
2. Create a user group named nagcmd to execute External commands from the web interface. Add Nagios users and Apache users to the group.
123 |
groupadd nagcmdusermod -a -G nagcmd nagiosusermod -a -G nagcmd www-data |
Note: The above www-data is the group to which the Apache user belongs. If there are different www-data groups, adjust them by yourself.
3. Compile and install Nagios
1234567891011 |
tar zxvf nagios-3.2.3.tar.gzcd nagios-3.2.3./configure --with-command-group=nagcmdmakemake allmake installmake install-initmake install-configmake install-commandmodemake install-webconfcd .. |
Note: make install is used to install main programs, CGI and HTML files.
Make install-init is used to generate the init Startup Script
Make install-config is used to install the sample configuration file
Make install-commandmode is used to set the corresponding directory permissions.
Make install-webconf is used to install the Apache configuration file
4. Check whether the verification program is correctly installed
Switch the directory to the installation path, which is/usr/local/nagios. Check whether the five directories including etc, bin, sbin, share, and var exist, if yes, it indicates that the program has been correctly installed to the system.
12 |
ls /usr/local/nagios/bin/ etc/ sbin/ share/ var/ |
Note: The directory where the bin-Nagios executable program is located. The nagios file is the main program.
Etc-Nagios configuration file location
The directory where the sbin-Nagios cgi file is located, that is, the directory where the file needed to execute the external command is located.
Share-Nagios webpage file directory
Directory where var-Nagios log files and spid files are located
Var/archives-log archiving directory
Var/rw-used to store external command files
5. Configure the Logon account and password on the Nagios Web Interface
1 |
htpasswd -c /usr/local/nagios/etc/htpasswd.users mike |
Modify the Nagios configuration file to grant new users access permissions.
12345678910 |
Vi /Usr/Local/Nagios/Etc/Cgi. cfg# Add new users to the following items. Multiple users are separated by commas.Authorized_for_system_information= Nagiosadmin, mikeAuthorized_for_configuration_information= Nagiosadmin, mikeAuthorized_for_system_commands= Nagiosadmin, mikeAuthorized_for_all_services= Nagiosadmin, mikeAuthorized_for_all_hosts= Nagiosadmin, mikeAuthorized_for_all_service_commands= Nagiosadmin, mikeAuthorized_for_all_host_commands= Nagiosadmin, mike |
6. Compile and install the Nagios plugin
Because the main program of Nagios only provides a runtime framework, its specific monitoring is completed by the plug-ins running under it, so the Nagios plug-in must be installed.
12345 |
tar zxvf nagios-plugins-1.4.15.tar.gzcd nagios-plugins-1.4.15./configure --with-nagios-user=nagios --with-nagios-group=nagiosmakemake install |
Verify that the Nagios plug-in is correctly installed
1 |
ls /usr/local//nagios/libexec |
The installed plug-in file is displayed, that is, all plug-ins are installed in the libexec directory.
7. Start the service
Check whether the configuration file is correct before starting.
1 |
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg |
If no error is reported, you can start the Nagios service.
1 |
/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg |
View Nagios running status
1 |
/usr/local/nagios/bin/nagiostats |