新聞中心
Nagios 對主機的監(jiān)控分為2種,像服務,端口,ping之類的監(jiān)控屬于外部信息監(jiān)控;像內存,磁盤,swap這些信息的監(jiān)控屬于內部信息監(jiān)控。外部信息監(jiān)控可以通過安裝Nagios 插件補丁來實現例如check_ping ;內部信息監(jiān)控則需要通過NRPE 插件來實現,其原理為:客戶機NRPE插件收集相關信息,服務端通過check_nrpe 來采集相關信息,并做相關處理。
創(chuàng)新互聯長期為上千余家客戶提供的網站建設服務,團隊從業(yè)經驗10年,關注不同地域、不同群體,并針對不同對象提供差異化的產品和服務;打造開放共贏平臺,與合作伙伴共同營造健康的互聯網生態(tài)環(huán)境。為襄汾企業(yè)提供專業(yè)的網站制作、成都網站制作,襄汾網站改版等技術服務。擁有10年豐富建站經驗和眾多成功案例,為您定制開發(fā)。一、監(jiān)控外部信息
監(jiān)控外部信息,只需要參照Nagios(二) 將Nagios 服務搭建起來,并且配置好欲監(jiān)控的主機和服務即可。
1. 配置hosts.cfg
[root@server ~]# vim /usr/local/nagios/etc/hosts.cfg
define host{
use linux-server
host_name node-1
alias lamp
address 192.168.30.110
}
2. 配置services.cfg
[root@server etc]# vim services.cfg
define service{
use generic-service
host_name node-1
service_description ping
check_command check_ping!100.0,20%!500.0,60%
max_check_attempts 5
normal_check_interval 1
}
define service{
use generic-service
host_name node-1
service_description tcp
check_command check_tcp!22
max_check_attempts 5
normal_check_interval 1
}
define service{
use generic-service
host_name node-1
service_description http
check_command check_http
max_check_attempts 5
normal_check_interval 1
}
3.將services.cfg和hosts.cfg 引用進nagios
[root@server ~]# vim /usr/local/nagios/etc/nagios.cfg
cfg_file=/usr/local/nagios/etc/hosts.cfg
cfg_file=/usr/local/nagios/etc/services.cfg
4.用nagios自帶的檢查命令檢查其配置是否正確
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
注意:由于這條命令較長而且使用的頻率也較高,所以可以通過以下的方法快捷的運用
[root@server ~]# vim .bashrc
alias check='/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg'
[root@server ~]# source .bashrc
這樣使用check命令即可直接調用-v 的命令,但只是當前登錄有效。
命令運行結果如下:
[root@server ~]# check
Nagios Core 3.2.0
Copyright (c) 2009 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-12-2009
License: GPL
Website: http://www.nagios.org
Reading configuration data...
Read main config file okay...
Processing object config file '/usr/local/nagios/etc/objects/commands.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/contacts.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/timeperiods.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/templates.cfg'...
Processing object config file '/usr/local/nagios/etc/hosts.cfg'...
Processing object config file '/usr/local/nagios/etc/services.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/localhost.cfg'...
Read object config files okay...
Running pre-flight check on configuration data...
Checking services...
Checked 11 services.
Checking hosts...
Checked 2 hosts.
Checking host groups...
Checked 1 host groups.
Checking service groups...
Checked 0 service groups.
Checking contacts...
Checked 1 contacts.
Checking contact groups...
Checked 1 contact groups.
Checking service escalations...
Checked 0 service escalations.
Checking service dependencies...
Checked 0 service dependencies.
Checking host escalations...
Checked 0 host escalations.
Checking host dependencies...
Checked 0 host dependencies.
Checking commands...
Checked 24 commands.
Checking time periods...
Checked 5 time periods.
Checking for circular paths between hosts...
Checking for circular host and service dependencies...
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...
Total Warnings: 0
Total Errors: 0 # 這里顯示沒有錯誤和警告說明啟動沒問題了
Things look okay - No serious problems were detected during the pre-flight check
5. 重啟nagios
[root@server ~]# service nagios restart
Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.
6. 測試
監(jiān)控服務:
監(jiān)控主機:
至此,nagios 監(jiān)控外部信息完成!
相關軟件包下載:http://down.51cto.com/data/699395
另外有需要云服務器可以了解下創(chuàng)新互聯scvps.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。
本文名稱:Nagios(三)——監(jiān)控外部信息(主機、服務)-創(chuàng)新互聯
網頁網址:http://ef60e0e.cn/article/cecchs.html