Nagios遠(yuǎn)程監(jiān)控安裝與配置詳解圖文第3/3頁
2、增加新的配置文件
先創(chuàng)建簡單的配置文件timeperiods.cfg,其內(nèi)容如下:
define timeperiod{ timeperiod_name 24x7 alias 24 Hours A Day, 7 Days A Week sunday 00:00-24:00 monday 00:00-24:00 tuesday 00:00-24:00 wednesday 00:00-24:00 thursday 00:00-24:00 friday 00:00-24:00 saturday 00:00-24:00 } |
第二個手動創(chuàng)建的配置文件是 contacts.cfg,其格式如下:
define contact { contact_name sa //不要有空格 alias system administrator service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,u,c,r host_notification_options d,u,r service_notification_commands service-notify-by-sms,service- notify-by-email //這個命令讀配置文件miscommands.cfg host_notification_commands host-notify-by-email,host-noti fy-by-sms //這個命令讀配置文件miscommands.cfg email sery@163.com pager 13333333333 //手機(jī)號,收報警短信 } //不要把這個符號寫掉了 define contact { contact_name sery alias system administrator service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,u,c,r host_notification_options d,u,r service_notification_commands service-notify-by-sms,service- notify-by-email host_notification_commands host-notify-by-email,host-noti fy-by-sms email sery@sohu.com pager 13312345678 } |
緊接著的第三個手動創(chuàng)建的配置文件是contactgroups.cfg文件,這個文件是依照上一個文件contacts.cfg來的,contactgroups文件相對簡單一些,其格式如下:
define contactgroup { contactgroup_name sagroup //不要用空格 alias system administrator group members sa,sery //本例有2個成員 } |
關(guān)鍵的角色終于登場,這就是配置文件hosts.cfg。下面是我定義的兩個主機(jī)的基本樣式:
#define monitor host ################################################################# # Wangjing IDC servers # ################################################################# define host { host_name nagios-server alias nagios server address 61.x..x.49 contact_groups sagroup //多個聯(lián)系組用逗號分隔, |
再一個重量級的配置文件是services.cfg,沒有這個文件,什么監(jiān)控也沒用。下面給出一個樣式文件:
#service definition ############################################################## # Wangjing IDC servers service for host-live # ############################################################## define service { host_name nagios-server //來源:hosts.cfg service_description check-host-alive check_period 24x7 max_check_attempts 4 normal_check_interval 3 retry_check_interval 2 contact_groups sagroup //來源:contactgroups.cfg notification_interval 10 notification_period 24x7 notification_options w,u,c,r check_command check-host-alive //檢查主機(jī)是否存活 } define service { host_name 74-210 service_description check_tcp 80 check_period 24x7 max_check_attempts 4 normal_check_interval 3 retry_check_interval 2 contact_groups sagroup notification_interval 10 notification_period 24x7 notification_options w,u,c,r check_command check_tcp!80 //檢查tcp 80端口服務(wù)是否正常 } |
主機(jī)組配置文件hostgroups.cfg,這是一個可選的項(xiàng)目,它建立在文件hosts之上,其格式如下:
define hostgroup { hostgroup_name sa-servers alias sa servers members nagios-server,24-25,24-26 //用逗號間隔多個主機(jī) } |
千辛萬苦,終于把這些配置給做好保存,現(xiàn)在幾乎有點(diǎn)迫不及待了,運(yùn)行程序/usr/local/nagios –v /usr/local/nagios/etc/nagios.cfg來檢查所有配置文件的正確性。如果十分幸運(yùn)的話,運(yùn)行完畢將在輸出尾部出現(xiàn):
Total Warnings: 0 Total Errors: 0 Things look okay - No serious problems were detected during the pre-flight check |
[root@netmonitor nagios]# bin/nagios -v etc/nagios.cfg Nagios 2.5 Copyright (c) 1999-2006 Ethan Galstad (http://www.nagios.org) Last Modified: 07-13-2006 License: GPL Reading configuration data... Error: Could not find any host matching 'nagios-server' Error: Could not expand member hosts specified in hostgroup |
驗(yàn)收
用瀏覽器輸入nagios所在服務(wù)器的ip及目錄,如http://61.135.X..X/nagios,再輸驗(yàn)證所需的用戶名和密碼,就可點(diǎn)擊頁面右邊的相關(guān)連接來查看各種狀態(tài)。關(guān)掉某個被nagios監(jiān)控主機(jī)的服務(wù)或者拔掉某個服務(wù)器的網(wǎng)線,等幾分鐘,點(diǎn)擊超連接“Service Detail”觀察頁面狀態(tài)看是否有紅色的醒目的報警出現(xiàn)。
一會兒,就會收到報警短信和報警郵件,然后在把測試所有的服務(wù)開啟或把拔下來的網(wǎng)線查上去,片刻后,網(wǎng)頁里的紅色報警表格消失,手機(jī)短信或郵件通知故障恢復(fù)。如果你的情況也這樣,那么真正大功告成。
Nagios的功能十分強(qiáng)大,在我的項(xiàng)目里,因?yàn)槲业男枨蟛煌M可能的簡化了nagios而沒有使用代理、多更多插件等功能,在一個不超過1000個服務(wù)器的網(wǎng)絡(luò)規(guī)模里,它工作得很好。如果有更多的服務(wù)器,建議使用mysql數(shù)據(jù)來管理監(jiān)控對象。在部署nagios的過程中,我多很多選項(xiàng)作了取舍,更詳細(xì)的情況請參照官方的文檔。
- iOS10 適配遠(yuǎn)程推送功能實(shí)現(xiàn)代碼
- iOS實(shí)現(xiàn)遠(yuǎn)程推送原理及過程
- iOS實(shí)現(xiàn)播放遠(yuǎn)程網(wǎng)絡(luò)音樂的核心技術(shù)點(diǎn)總結(jié)
- iOS10最新實(shí)現(xiàn)遠(yuǎn)程通知的開發(fā)教程詳解
- iOS開發(fā)之運(yùn)動事件和遠(yuǎn)程控制
- 詳解iOS本地推送與遠(yuǎn)程推送
- iOS消息遠(yuǎn)程推送通知
- iOS實(shí)時監(jiān)控網(wǎng)絡(luò)狀態(tài)的改變
- iOS實(shí)現(xiàn)實(shí)時檢測網(wǎng)絡(luò)狀態(tài)的示例代碼
- iOS中的實(shí)時遠(yuǎn)程配置全紀(jì)錄
相關(guān)文章
突破網(wǎng)絡(luò)尖兵共享上網(wǎng) 附相關(guān)軟件下載
突破網(wǎng)絡(luò)尖兵共享上網(wǎng) 附相關(guān)軟件下載...2007-06-06Nagios遠(yuǎn)程監(jiān)控安裝與配置詳解圖文
作為系統(tǒng)管理員,我最擔(dān)心那些重要的在線系統(tǒng)在我不知情的情況下停機(jī)或者停止網(wǎng)絡(luò)服務(wù),要改變這種被動局面,這里作者推薦一款網(wǎng)絡(luò)監(jiān)控軟件Nagios,文中講述作者使用Nagios的過程以及心得,希望對初學(xué)者有所幫助。2008-07-07Linux系統(tǒng)下雙網(wǎng)卡配置實(shí)踐總結(jié)
Linux下雙網(wǎng)卡配置方法2008-04-04圖文分析詳解計算機(jī)網(wǎng)絡(luò)TCP與UDP兩者區(qū)別及原理
TCP和UDP都位于計算機(jī)網(wǎng)絡(luò)模型中的運(yùn)輸層,它們負(fù)責(zé)傳輸應(yīng)用層產(chǎn)生的數(shù)據(jù)。在面試中也經(jīng)常會問TCP和UDP的區(qū)別,下面我們將從幾個方面來聊一聊TCP和UDP兩者的區(qū)別2021-11-11Windows XP網(wǎng)絡(luò)故障修復(fù)的步驟
Windows XP網(wǎng)絡(luò)故障修復(fù)的步驟...2007-08-08