下载地址
http://sourceforge.net/projects/nagios/
https://www.nagios-plugins.org/download/
http://sourceforge.net/projects/nscplus/files/nscplus/
监控服务器安装配置
安装依赖的软件
yum install gcc gd gd-devel libpng libpng-devel libjpeglibjpeg-devel zlib zlib-devel openssl openssl-devel mail
tar zxvf nagios-4.0.2.tar.gz
cd nagios-4.0.2
添加用户
useradd -s /sbin/nologin nagios
配置
./configure --prefix=/usr/local/nagios
编译
make all
make install
make install-init
make install-commandmode
make install-config
make install-webconf
chkconfig --add nagios
chkconfig --level 35 nagios on
chkconfig --list nagios
cd nagios-plugins-1.5
./configure --prefix=/usr/local/nagios
make
make install
启动nagios
/etc/init.d/nagios start
创建用户
/usr/bin/htpasswd
-c/usr/local/nagios/etc/htpasswd.users admin
修改httpd的配置文件
vim /etc/httpd/conf/httpd.conf
在最下面添加
Listen 82
VirtualHost *:82
DocumentRoot/usr/local/nagios/share
ServerNamenagios.5lejob.com
ErrorLoglogs/error_log-nagios.5lejob.com
CustomLoglogs/access_log-nagios.5lejob.com common
Directory"/usr/local/nagios/share
AuthType Basic
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
/Directory
/VirtualHost
重启httpd
/etc/init.d/httpd start
访问页面
http://localhost:82
如果页面出现 It appears as though you do not have permission to view information for any of the hosts you requested...
vim /usr/local/nagios/etc/cgi.cfg
修改use_authentication=1为use_authentication=0
/etc/init.d/nagios restart
被监控服务器配置
yum install gcc openssl openssl-devel
添加用户
useradd -s /sbin/nologin nagios
编译安装
tar zxvf nagios-plugins-1.5.tar.gz
cd nagios-plugins-1.5
./configure --prefix=/usr/local/nagios
make
make install
tar zxvf nrpe-2.15
cd nrpe-2.15
./configure --prefix=/usr/local/nagios
make all
make install-plugin
make install-daemon
make install-daemon-config
修改配置文件
vim /usr/local/nagios/etc/nrpe.cfg
在allowed_hosts增加监控主机ip
allowed_hosts=127.0.0.1,10.10.10.10
启动nrpe
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg-d
增加开机启动
vim /etc/rc.local
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg-d
修改iptables配置文件增加允许5666端口
vim /etc/sysconfig/iptables
添加一行
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5666 -jACCEPT
/etc/init.d/iptables restart
在监控主机上执行命令测试一下
/usr/local/nagios/libexec/check_nrpe -H 10.10.10.11
相关配置文件
vim /usr/local/nagios/etc/servers/commands.cfg
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
vim /usr/local/nagios/etc/servers/hosts.cfg
define host{
use
linux-server
host_name
10
alias
10
address
10.10.10.10
}
# LINUX HOST GROUP
define hostgroup{
hostgroup_name
all host
alias
all host
members
10,11,12,13,14,15,16,17,18,19,20,21,22,23,50
}
# WINDOWS HOST
define host{
use
windows-server
host_name
51
alias
51
address
10.10.10.51
}
# WINDOWS HOST GROUP
define hostgroup{
hostgroup_name
windows-servers
alias
Windows Servers
}
vim /usr/local/nagios/etc/servers/services.cfg
define service{
use
local-service
hostgroup_name
all host
service_description
PING
check_command
check_ping!100.0,20%!500.0,60%
notifications_enabled
1
}
define service{
use
local-service
hostgroup_name
all host
service_description
CURRENT USERS
check_command
check_nrpe!check_users
notifications_enabled
1
}
define service{
use
local-service
hostgroup_name
all host
service_description
CURRENT LOAD
check_command
check_nrpe!check_load
notifications_enabled
1
}
define service{
use
local-service
hostgroup_name
all host
service_description
ZOMBIE PROCS
check_command
check_nrpe!check_zombie_procs
notifications_enabled
1
}
define service{
use
local-service
hostgroup_name
all host
service_description
TOTAL_PROCS
check_command
check_nrpe!check_total_procs
notifications_enabled
1
}
define service{
use
local-service
hostgroup_name
all host
service_description
DISK_/
check_command
check_nrpe!check_/
notifications_enabled
1
}
define service{
use
local-service
hostgroup_name
all host
service_description
SWAP
check_command
check_nrpe!check_swap
notifications_enabled
1
}
define service{
use
local-service
host_name
11,12,13,14
service_description
NGINX_80
check_command
check_http
notifications_enabled
1
}
# TOMCAT
define service{
use
local-service
host_name
15,17,19
service_description
TOMCAT_1080
check_command
check_http!-p 1080 -u /test/test.jsp
notifications_enabled
1
}
# REDIS
define service{
use
local-service
host_name
22
service_description
REDIS_6381
check_command
check_tcp!6381
notifications_enabled
1
}
define service{
use
local-service
host_name
22
service_description
REDIS_6382
check_command
check_tcp!6382
notifications_enabled
1
}
define service{
use
local-service
host_name
22
service_description
REDIS_6383
check_command
check_tcp!6383
notifications_enabled
1
}
# MAIL
define service{
use
local-service
host_name
21
service_description
MAIL
check_command
check_tcp!25
notifications_enabled
1
}
# WINDOWS
define service{
use
local-service
host_name
51
service_description
PING
check_command
check_ping!100.0,20%!500.0,60%
notifications_enabled
1
}
vim /usr/local/nagios/etc/nrpe.cfg
command[check_users]=/usr/local/nagios/libexec/check_users -w 10 -c20
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5-c 30,25,20
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c10% -p /dev/hda1
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 -w200 -c 300
command[check_/]=/usr/local/nagios/libexec/check_disk -w 80% -c 90%-p /dev/mapper/VolGroup-lv_root
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 60% -c40%
参考地址
http://www.cnblogs.com/mchina/archive/2013/02/20/2883404.html
http://sourceforge.net/projects/nagios/
https://www.nagios-plugins.org/download/
http://sourceforge.net/projects/nscplus/files/nscplus/
监控服务器安装配置
安装依赖的软件
yum install gcc gd gd-devel libpng libpng-devel libjpeglibjpeg-devel zlib zlib-devel openssl openssl-devel mail
tar zxvf nagios-4.0.2.tar.gz
cd nagios-4.0.2
添加用户
useradd -s /sbin/nologin nagios
配置
./configure --prefix=/usr/local/nagios
编译
make all
make install
make install-init
make install-commandmode
make install-config
make install-webconf
chkconfig --add nagios
chkconfig --level 35 nagios on
chkconfig --list nagios
cd nagios-plugins-1.5
./configure --prefix=/usr/local/nagios
make
make install
启动nagios
/etc/init.d/nagios start
创建用户
/usr/bin/htpasswd
修改httpd的配置文件
vim /etc/httpd/conf/httpd.conf
在最下面添加
Listen 82
VirtualHost *:82
/VirtualHost
重启httpd
/etc/init.d/httpd start
访问页面
http://localhost:82
如果页面出现 It
vim /usr/local/nagios/etc/cgi.cfg
修改use_authentication=1为use_authentication=0
/etc/init.d/nagios restart
被监控服务器配置
yum install gcc openssl openssl-devel
添加用户
useradd -s /sbin/nologin nagios
编译安装
tar zxvf nagios-plugins-1.5.tar.gz
cd nagios-plugins-1.5
./configure --prefix=/usr/local/nagios
make
make install
tar zxvf
cd nrpe-2.15
./configure --prefix=/usr/local/nagios
make all
make install-plugin
make install-daemon
make install-daemon-config
修改配置文件
vim /usr/local/nagios/etc/nrpe.cfg
在allowed_hosts增加监控主机ip
allowed_hosts=127.0.0.1,10.10.10.10
启动nrpe
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg-d
增加开机启动
vim /etc/rc.local
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg-d
修改iptables配置文件增加允许5666端口
vim /etc/sysconfig/iptables
添加一行
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5666 -jACCEPT
/etc/init.d/iptables restart
在监控主机上执行命令测试一下
/usr/local/nagios/libexec/check_nrpe -H 10.10.10.11
相关配置文件
vim /usr/local/nagios/etc/servers/commands.cfg
define command{
}
vim /usr/local/nagios/etc/servers/hosts.cfg
define host{
}
# LINUX HOST GROUP
define hostgroup{
}
# WINDOWS HOST
define host{
}
# WINDOWS HOST GROUP
define hostgroup{
}
vim /usr/local/nagios/etc/servers/services.cfg
define service{
}
define service{
}
define service{
}
define service{
}
define service{
}
define service{
}
define service{
}
define service{
}
# TOMCAT
define service{
}
# REDIS
define service{
}
define service{
}
define service{
}
define service{
}
# WINDOWS
define service{
}
vim /usr/local/nagios/etc/nrpe.cfg
command[check_users]=/usr/local/nagios/libexec/check_users -w 10 -c20
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5-c 30,25,20
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c10% -p /dev/hda1
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 -w200 -c 300
command[check_/]=/usr/local/nagios/libexec/check_disk -w 80% -c 90%-p /dev/mapper/VolGroup-lv_root
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 60% -c40%
参考地址
http://www.cnblogs.com/mchina/archive/2013/02/20/2883404.html