In Linux, there are two major monitoring tools: cacti + nagios. Next I will record the steps for building my own nagios so that you can view it later.
First install the dependency package
# Yum install-y httpd mysql-devel mysql-server php-mysql gcc-c ++ gblic-devel gd-devel openssl-devel
Add nagios users and user groups
# Groupadd nagcmd
# Useradd nagios
# Usermod-a-G nagcmd nagios
# Usermod-a-G nagcmd daemon (http user)
Download the nagios installation package and decompress it.
Start Compilation
#./Configure -- prefix =/etc/nagios \
> -- With-nagios-user = nagios \
> -- With-nagios-group = nagios \
> -- Enable-event-broker
# Make all
# Make install
# Make install-init
# Make install-commandmode
# Make install-config
# Make install-webconf (httpd compilation and installation may encounter errors)
Install nagios-plugins
#./Configure -- with-nagios-user = nagios \
> -- With-nagios-group = nagios \
> -- With-mysql =/path/to/mysql (this option must be added for monitoring mysql)
# Make & make install
Install nrpe
Determine the development environment
# Yum grouplist
Are you sure you have the Development tools and Development Libraries?
If not, install
# Yum groupinstall-y "Development tools" "Development Libraries"
Start nrpe Installation
#./Configure -- with-nagios-user = nagios \
> -- With-nagios-group = nagios \
> -- With-nrpe-user = nagios \
> -- With-nrpe-group = nagios \
> -- Enable-command-args \
> -- Enable-ssl
# Make all
# Make install-plugin
The server does not need to start the nrpe service.
Configure the client
Nrpe depends on nagios-plugins. First install nagios-plugins
#./Configure -- with-nagios-user = nagios \
> -- With-nagios-group = nagios \
> -- With-mysql =/path/to/mysql (this option must be added for monitoring mysql)
# Make & make instal
Install nrpe
#./Configure -- with-nagios-user = nagios \
> -- With-nagios-group = nagios \
> -- With-nrpe-user = nagios \
> -- With-nrpe-group = nagios \
> -- Enable-command-args \
> -- Enable-ssl
# Make all
# Make install-plugin
# Make install-daemon (install daemon)
# Make install-daemon-config (install the daemon configuration file)
Modify the nrpe. cfg file
Find allowed_hosts to add the IP address of your server
Start nrpe
/Usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe. cfg-d
Next, you can define the host on the server and define the command to start monitoring.
Define commands
Define command {
Command_name check_nrpe
Command_line $ USER1 $/check_nrpe-H $ HOSTADDRESS $-c $ ARG1 $ (-c indicates that commands are executed remotely)
}
Define host
Define host {
Use linux-server
Host_name webserver
Alias web-server
Address 192.168.0.4
}
Define Service
Define service {
Use linux-service
Host_name webserver
Service_description PING
Check_command check_nrpe! Check_ping
}
Define commands on the client to monitor what you want, and enter the detection content on the server.
The STARTUP script for nrpe is attached below
#! /Bin/sh
#
# Source function library
If [-f/etc/rc. d/init. d/functions]; then
./Etc/rc. d/init. d/functions
Elif [-f/etc/init. d/functions]; then
./Etc/init. d/functions
Elif [-f/etc/rc. d/functions]; then
./Etc/rc. d/functions
Fi
# Source networking configuration.
./Etc/sysconfig/network
# Check that networking is up.
[$ {NETWORKING} = "no"] & exit 0
NrpeBin =/usr/local/nagios/bin/nrpe
NrpeCfg =/usr/local/nagios/etc/nrpe. cfg
LockFile =/var/lock/subsys/nrpe
# See how we were called.
Case "$1" in
Start)
# Start daemons.
Echo-n "Starting nrpe :"
Daemon $ NrpeBin-c $ NrpeCfg-d
Echo
Touch $ LockFile
;;
Stop)
# Stop daemons.
Echo-n "Shutting down nrpe :"
Killproc nrpe
Echo
Rm-f $ LockFile
;;
Restart)
$0 stop
$0 start
;;
Status)
Status nrpe
;;
*)
Echo "Usage: nrpe {start | stop | restart | status }"
Exit 1
Esac
Exit 0
Nagios details: click here
Nagios: click here
Network Monitor Nagios Overview
Nagios construction and Configuration
Build a Nagios monitoring platform in the Nginx Environment
Configure the basic Nagios System on RHEL5.3 (using Nagios-3.1.2)
CentOS 5.5 + Nginx + Nagios monitoring and control terminal installation and Configuration Guide
Install Nagios Core for Ubuntu 13.10 Server