Home | 簡體中文 | 繁體中文 | 雜文 | 打賞(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎專欄 | Search | Email

第 93 章 Nagios

目錄

93.1. Install
93.1.1. Nagios core
93.1.2. Monitor Client nrpe
93.1.3. Monitoring Windows Machines
93.1.4. PNP4Nagios 圖表插件
93.2. nagios
93.3. nrpe node
93.4. 配置 Nagios
93.4.1. authorized
93.4.2. contacts
93.4.3. hostgroups
93.4.4. generic-service
93.4.5. SOUND OPTIONS
93.4.6. SMS 短信
93.4.7. nrpe plugins
93.5. 配置監控設備
93.5.1. routers
93.5.2. host
93.5.3. service
93.5.3.1. http
93.5.3.2. mysql hosts
93.5.3.3. check_tcp
93.6. Nagios Plugins
93.6.1. check_ping
93.6.2. check_procs
93.6.3. check_users
93.6.4. check_http
93.6.5. check_mysql
93.6.5.1. check_mysql
93.6.5.2. mysql.cfg check_mysql_replication
93.6.5.3. nrpe.cfg check_mysql_replication
93.6.6. Disk
93.6.6.1. disk.cfg
93.6.6.2. check_disk
93.6.6.3. disk-smb.cfg
93.6.7. check_tcp
93.6.7.1. 連接埠檢查
93.6.7.2. Memcache
93.6.7.3. Redis
93.6.8. check_log
93.6.9. check_traffic
93.6.10. Nagios nrpe plugins
93.6.11. check_nt
93.6.12. nsca - Nagios Service Check Acceptor
93.6.13. jmx
93.7. FAQ
93.7.1. Macro Name
93.7.2. 插件開發手冊

homepage: http://www.nagios.org/

93.1. Install

93.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 ]
		

93.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
		

93.1.3. Monitoring Windows Machines

Nagios 可以監控windows伺服器,需要安裝下面軟件。

NSClient++

http://sourceforge.net/projects/nscplus

93.1.4. PNP4Nagios 圖表插件

http://www.pnp4nagios.org/