首页 > Linux操作系统 > Linux操作系统 > Nagios监控软件安装(转)


1.安装nagios
./configure --prefix=/opt/nagios --with-command-group=nagcmd --with-gd-lib=/usr/lib --with-gd-inc=/usr/include
make all
make install
make install-init
make install-config
make install-commandmode
(make install-webconf #可以自动配置httpd.conf)
cp sample-config/httpd.conf /opt/apache/conf/extra/nagios.conf
/opt/apache/bin/htpasswd -c /opt/nagios/etc/htpasswd.users nagiosadmin
(nagiosadmin 要与 /opt/nagios/etc/objects/contacts.cfg 里的 contact_name 相同)
groupadd nagios
useradd -g nagios nagios
passwd nagios
2.安装nagios-plugins
cd nagios-plugins-1.4.12
./configure --prefix=/opt/nagios --with-nagios-user=nagios --with-nagios-group=nagios --enable-redhat-pthread-workaround
make
make install
3.安装NRPE
cd nagios-nrpe_2.12
./configure #默认自动添加了openssl
./configure --prefix=/opt/nagios --enable-ssl --with-ssl-lib=/lib/(当然前提要有openssl)
make all
make install-plugin
make install-daemon
make install-daemon-config
4.commands.cfg定义外部构件nrpe
vi /opt/nagios/etc/objects/commands.cfg
#添加
#check nrpe
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
.配置要监控的linux主机
vi /opt/nagios/etc/nagios.cfg
#中间添加
cfg_file=/opt/nagios/etc/objects/mylinux.cfg
6.新建mylinux.cfg 设置监控内容
vi /usr/local/nagios/etc/objects/mylinux.cfg
define host{
use linux-server
host_name mylinux
alias mylinux
# 客户端IP
address 192.168.1.212
}
define service{
use generic-service
host_name mylinux
service_description check-swap
check_command check_nrpe!check_swap
}
define service{
use generic-service
host_name mylinux
service_description check-load
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name mylinux
service_description check-disk
check_command check_nrpe!check_hda1 }
define service{
use generic-service
host_name mylinux
service_description check-users
check_command check_nrpe!check_users
}
define service{
use generic-service
host_name mylinux
service_description otal_procs
check_command check_nrpe!check_total_procs
}
6.其它设置
chkconfig --add nagios #配置机器启动时自动启动Nagios
chkconfig nagios on
/opt/nagios/bin/nagios -v /opt/nagios/etc/nagios.cfg #检查Nagios配置文件
vi /etc/selinux/config #关闭SELinux
SELINUX=disabled
service iptables stop #关闭SELinux,或打开80,5666端口
service nagios start
3.配置被监控端
1.安装nagios-plugin
useradd nagios
tar -zxvf nagios-plugins-1.4.12.tar.gz
cd nagios-plugins-1.4.12
./configure --prefix=/opt/nagios-plugins/ --with-nagios-user=nagios --with-nagios-group=nagios --enable-redhat-pthread-workaround
make
make install
2.改变主目录权限
chown –R nagios:nagios /opt/nagios-plugins
[root@client nagios]# ll
drwxr-xr-x 2 nagios nagios 4096 Jun 1 00:07 libexec
drwxr-xr-x 3 nagios nagios 4096 Jun 1 00:07 share
3.安装客户端的nrpe
tar -zxvf nrpe_2.12.tar.gz
cd nrpe_2.12
./configure --prefix=/opt/nagios-plugins --enable-ssl --with-ssl-lib=/usr/lib/(当然前提要有openssl)
make all
make install-plugin
make install-daemon
make install-daemon-config
4.配置nrpe信息
vi /opt/nagios-plugins/etc/nrpe.cfg
allowed_hosts=127.0.0.1,192.168.1.211
5.启动nrpe
/opt/nagios-plugins/bin/nrpe -c /opt/nagios-plugins/etc/nrpe.cfg –d
#或
vi /etc/rc.d/rc.local
/opt/nagios-plugins/bin/nrpe -c /opt/nagios-plugins/etc/nrpe.cfg –d
6.验证nrpe
netstat -an | grep 5666
tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN
/opt/nagios-plugins/libexec/check_nrpe -H 127.0.0.1
NRPE v2.8.12
#服务端测试
/opt/nagios-plugins/libexec/check_nrpe -H l92.168.1.212 -p 5666 -c check_load
NRPE v2.8.12
7.配置监控对像(关键)
由监控原理可知被监控端做监控然后传给监控服务器绘总,设置监控详细参数主要是设置被监控端的nrpe.cfg文件
可以看到里面监控对象
vi /opt/nagios-plugins/etc/nrpe.cfg
command[check_users]=/opt/nagios-plugins/libexec/check_users -w 5 -c 10
command[check_load]=/opt/nagios-plugins/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/opt/nagios/libexec-plugins/check_disk -w 20 -c 10 -p /dev/hda1
command[check_zombie_procs]=/opt/nagios-plugins/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/opt/nagios-plugins/libexec/check_procs -w 150 -c 200
command[check_swap]=/opt/nagios-plugins/libexec/check_swap -w 20% -c 10%


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26442672/viewspace-717892/ ,如需转载,请注明出处,否则将追究法律责任。