97.1. Install
97.1.1. Nagios core
Nagios 是一种开放源代码监视软件,它可以扫描主机、服务、网络方面存在的问题。Nagios 与其他类似的包之间的主要区别在于,Nagios 将所有的信息简化为“工作(working)”、“可疑的(questionable)”和“故障(failure)”状态,并且 Nagios 支持由插件组成的非常丰富的“生态系统”。这些特性使得用户能够进行有效安装,在此过程中无需过多地关心细节内容,只提供他们所需的信息即可。
install
$ sudo apt-get install nagios3 nagios-nrpe-plugin
add user nagiosadmin for nagios
$ sudo htpasswd -c /etc/nagios2/htpasswd.users nagiosadmin New password: Re-type new password: Adding password for user nagiosadmin
Create a new nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user to the group.
$ groupadd nagcmd $ sudo usermod -a -G nagcmd nagios $ sudo usermod -a -G nagcmd www-data $ cat /etc/group nagcmd:x:1003:nagios,www-data
reload apache
$ sudo /etc/init.d/apache2 reload * Reloading web server config apache2 [ OK ]
97.1.2. Monitor Client nrpe
nagios-nrpe-server --------> nagios core (nagios-nrpe-plugin)
nagios-nrpe-server 的功能是向服务器发送监控数据, 而服务器端通过nagios-nrpe-plugin接收监控数据。
sudo apt-get install nagios-nrpe-server nagios-plugins
/etc/nagios/nrpe.cfg
/etc/nagios/nrpe_local.cfg
$ sudo vim /etc/nagios/nrpe_local.cfg allowed_hosts=172.16.1.2 command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10 command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20 command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200 command[check_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200 command[check_swap]=/usr/lib/nagios/plugins/check_swap -w 20% -c 10% command[check_all_disks]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -e command[check_disk_root]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p / command[check_disk_home]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /home command[check_sda_iostat]=/usr/lib/nagios/plugins/check_iostat -d sda -w 100 -c 200 command[check_sdb_iostat]=/usr/lib/nagios/plugins/check_iostat -d sdb -w 100 -c 200 # command[check_uri_user]=/usr/lib/nagios/plugins/check_http -I 127.0.0.1 -p 80 -u http://example.com/test/ok.php # command[check_mysql]=/usr/lib/nagios/plugins/check_mysql -H localhost -u root -ppassword test -P 3306
重启后生效
/etc/init.d/nagios-nrpe-server restart
97.1.3. Monitoring Windows Machines
Nagios 可以监控windows服务器,需要安装下面软件。
NSClient++
http://sourceforge.net/projects/nscplus
97.1.4. PNP4Nagios 图表插件
http://www.pnp4nagios.org/
原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。
时间: 2024-10-11 05:41:21