Nagios is an open-source monitoring solution. It can be used to monitor the status of linux, windows, and unix hosts and send alarms to users through text messages and emails. Another advantage is that it is an open-source solution that allows you to write monitoring scripts that you need in comparison. There are also a lot of off-the-shelf scripts available for reference on the Internet. In short, open source is free.
The installation process is as follows:
Version: rhel6.3 + nagios 4.0.2
ServerYou must install nagioscore, nagios nrpe, and nagios plugin software. The IP address is 10.4.1.11.
Windows ClientNSClient ++ needs to be installed
Linux ClientYou need to install nrpe and nagiosplugin.
Install and configure the nagios Monitoring Server
1. Configure the yum source and install related software packages.
Mount 10.1.1.11: // RHEL-INSTALL-REPO // nfsshare
[Root @ Stylog3 software] # mount 10.1.1.11:/RHEL-INSTALL-REPO // nfsshare
Vi/etc/yum. repos. d/rhel5.repo
[Server]
Name = rhel5server
Baseurl = file: // nfsshare/rhel-5.9-repo/install
Enable = 1
Gpcheck = 1
Gpgkey = file: // nfsshare/rhel-5.9-repo/install/RPM-GPG-KEY-redhat-release
Mkdir/nfsshare
Mount 10.1.1.11:/RHEL-INSTALL-REPO // nfsshare/
For convenience, you can directly use the httpd service provided by linux.
Yum install-y httpd php gcc glibcglibc-common gd-devel make net-snmp
2. Create a user
Useradd nagios
Passwd nagios
3. Compile and install nagios core
Tar-zxvf nagios-4.0.2
Cd nagios-4.0.2
./Configure
Make all
Make install
Make install-init
Make install-commandmode
Make install-config
4. Configure the web interface
Cd nagios-4.0.2
Make install-webconf
Create users for security purposes
Htpasswd-s-c/usr/local/nagios/etc/htpasswd. users nagiosadmin
Start http service
Service httpd start
5. Install nagios plugin
Tar-zxvf nagios-plugins-1.5.tar.gz
Cd nagios-plugins-1.5
./Configure
Make
Make install
6. Modify and verify the configuration file.
The configuration files are in the/usr/local/nagios/etc/directory.
/Usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios. cfg
7. log on to the website for verification. Is the installation correct?
Http: // Your-server-IP-address/nagios
8. For details about how to install the clinet client, see the following section.
You only need to add the relevant commands in the nrpe. cfg file. A corresponding command must be added for each service.
Cat/usr/local/nagios/etc/nrpe. cfg
Add the following similar content
Command [check_disk] =/usr/local/nagios/libexec/check_disk-w 15%-c 10%-p/home
Added a windows monitoring client.
1. install the software nscp
Installed in C: \ Program Files \ NSClient ++ by default. The configuration file is nsclient. ini, and the default monitoring port is 12489.
Install the windows monitoring plug-in on the server (check_nt is already installed by default)
2. Define commands
Vi/usr/local/nagios/etc/objects/commands. cfg
# 'Check _ nt 'command definition
Define command {
Command_name check_nt
Command_line $ USER1 $/check_nt-H $ HOSTADDRESS $-p 12489-v $ ARG1 $ ARG2 $
}
3. Define the Project services to be monitored
Vi/usr/local/nagios/etc/objects/windows_stysql1.cfg
Vi/usr/local/nagios/etc/nagios. cfg
Export _file =/usr/local/nagios/etc/objects/windows_stysql1.cfg
Add a linux Server monitoring Client
1. Upload and install the nagios plugin installation software
Scp/monitor/software/nrpe-2.12.tar.gz hadoop @ stylog2:/monitor/software
Scp hadoop@10.1.1.5:/monitor/software/nagios-plugins-1.5.tar.gz/monitor/software/
Scp hadoop@10.1.1.5:/monitor/software/nrpe-2.12.tar.gz/monitor/software/
Tar-zxvf nagios-plugins-1.5.tar.gz
2. Configure the yum source and install related software packages.
Vi/etc/yum. repos. d/rhel6.repo
[Server]
Name = rhel6server
Baseurl = file: // nfsshare/rhel-6.3-repo/RHEL63/Server
Enable = 1
Gpcheck = 1
Gpgkey = file: // nfsshare/rhel-6.3-repo/RHEL63/RPM-GPG-KEY-redhat-release
Mkdir/nfsshare
Mount 10.1.1.11:/RHEL-INSTALL-REPO // nfsshare/
3. Create a user
Useradd nagios
Passwd nagios
4. Compile nagios plugin
[Root @ tydb nagios] # cd nagios-plugins-1.5
[Root @ tydb nagios] #./configure
[Root @ tydb nagios] # make
[Root @ tydb nagios] # make install
5. Modify permissions
Chown nagios: nagios/usr/local/nagios
Chown-R nagios: nagios/usr/local/nagios/libexec
6. Install xinetd.
Yum install xinetd
7. Install nrpe
Note:Checkingfor SSL headers... configure: error: Cannot find ssl headers
Yum-y install openssl-devel
Scphadoop @ stylog1:/monitor/software/nrpe-2.12.tar.gz/monitor/software/
Tar-xvf nrpe-2.12.tar.gz
Cd nrpe-2.12
[Root @ tydb] #./configure
[Root @ tydb] # make all
[Root @ tydb] # make install-plugin
[Root @ tydb] # make install-daemon
[Root @ tydb] # make install-daemon-config
Make install-xinetd
8. modify the configuration
Vi/etc/xinetd. d/nrpe
Only_from = 127.0.0.1 localhost <nagios_ip_address>
Vi/etc/services
Nrpe 5666/tcp NRPE
Restart service
Service xinetd restart
9. verify whether the installation is successful.
[Root @ stylog2 nrpe-2.12] # netstat-at | grep nrpe
Tcp 0 0 *: nrpe *: * LISTEN
[Root @ stylog2 nrpe-2.12] #/usr/local/nagios/libexec/check_nrpe-H localhost
NRPE v2.12
10. Add monitoring configurations.
Vi/usr/local/nagios/etc/nrpe. cfg
Added by default
Command [check_users] =/usr/local/nagios/libexec/check_users-w 5-c 10
Command [check_load] =/usr/local/nagios/libexec/check_load-w 15, 10, 5-c 30, 25, 20
Command [check_zombie_procs] =/usr/local/nagios/libexec/check_procs-w 5-c 10-s Z
Command [check_total_procs] =/usr/local/nagios/libexec/check_procs-w 1000-c 1500
# Command [check_ftp] =/usr/local/nagios/libexec/check_ftp-w 150-c 200
Command [check_ssh] =/usr/local/nagios/libexec/check_ssh10.1.1.5
Command [check_disk] =/usr/local/nagios/libexec/check_disk-w 15%-c 10%-p/
You can test whether the related commands can be executed normally.
/Usr/local/nagios/libexec/check_nrpe-Hlocalhost-c check_users
You can also add the command as needed.
11. The monitoring server also needs simple configuration
A. Make sure that nrpe and nrpe client are installed.
B. Check the connection to the newly added monitored server.
[Root @ stadmin ~] #/Usr/local/nagios/libexec/check_nrpe-H 10.1.1.6
NRPE v2.12
C. Add the hosts
Vi/usr/local/nagios/etc/hosts. cfg
Definehost {
Use linux-tydb2; Inherit default values from atemplate
Host_name stylog1; The name we're re giving tothis server
Alias stylog1; A longer name for the server
Address 10.1.1.5; IP address of Remote Linux host
}
Define host {
Use linux-tydb2; Inherit default values from atemplate
Host_name stylog2; The name we're re giving tothis server
Alias stylog2; A longer name for the server
Address 10.1.1.6; IP address of Remote Linux host
}
D. Create a service configuration file.
Vi service_linux.cfg
In this example, only one service is added. In fact, more metric item definitions may be required.
Define service {
Use generic-service
Host_name stylog2
Service_description FileSystem Usage
Check_command check_nrpe! Check_disk
}
E. Restart nagios.
Service nagios restart
Add a Metric
Added linux File System Monitoring
The default configuration file is in the/usr/local/nagios/etc directory.
A. Add the configuration file in nagios. cfg.
Export _file =/usr/local/nagios/etc/servicesi_linux.cfg
B. Add servicecheck_disk TO THE service_linux.cfg configuration file.
Define service {
Use generic-service
Host_name stylog1
Service_description File System Usage
Check_command check_nrpe! Check_disk
}
C. Add commands to the commands. cfg file of the client server.
Cat/usr/local/nagios/etc/objects/commands. cfg
# 'Check _ disk' command definition
Define command {
Command_name check_disk
Command_line $ USER1 $/check_disk-w $ ARG1 $-c $ ARG2 $-p $ ARG3 $
}
References
Http://www.tecmint.com/install-nagios-in-linux/
Http://www.tecmint.com/how-to-add-linux-host-to-nagios-monitoring-server/
Http://www.tecmint.com/how-to-add-windows-host-to-nagios-monitoring-server/