參考文章:http://nagios-cn.sourceforge.net/nagios-cn/beginning.html#quickstart-ubuntu
目前累計(jì)服務(wù)客戶上1000+,積累了豐富的產(chǎn)品開發(fā)及服務(wù)經(jīng)驗(yàn)。以網(wǎng)站設(shè)計(jì)水平和技術(shù)實(shí)力,樹立企業(yè)形象,為客戶提供網(wǎng)站設(shè)計(jì)制作、成都網(wǎng)站建設(shè)、網(wǎng)站策劃、網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)絡(luò)營(yíng)銷、VI設(shè)計(jì)、網(wǎng)站改版、漏洞修補(bǔ)等服務(wù)。成都創(chuàng)新互聯(lián)始終以務(wù)實(shí)、誠(chéng)信為根本,不斷創(chuàng)新和提高建站品質(zhì),通過(guò)對(duì)領(lǐng)先技術(shù)的掌握、對(duì)創(chuàng)意設(shè)計(jì)的研究、對(duì)客戶形象的視覺(jué)傳遞、對(duì)應(yīng)用系統(tǒng)的結(jié)合,為客戶提供更好的一站式互聯(lián)網(wǎng)解決方案,攜手廣大客戶,共同發(fā)展進(jìn)步。
--快速安裝nagios
查看 nagios3的版本號(hào)
apt-cache showpkg nagios3
安裝nagios
apt-get install nagios3
會(huì)提示安裝sendmail,然后提示你輸入nagios的密碼
安裝好后
http://ip/nagios3/
賬戶nagiosadmin
密碼安裝時(shí)候輸入的
#配置文件位置
/etc/nagios3
################常用命令#################
php網(wǎng)頁(yè)位置
/usr/share/nagios3/htdocs
圖標(biāo)位置
/usr/share/nagios/htdocs/p_w_picpaths/logos/logos
配置文件位置
/etc/nagios3/
創(chuàng)建一個(gè)nagiosadmin的用戶用于Nagios的WEB接口登錄。記下你所設(shè)置的登錄口令,一會(huì)兒你會(huì)用到它。
htpasswd -c /etc/nagios3/htpasswd.users nagiosadmin
重啟Apache服務(wù)以使設(shè)置生效。
/etc/init.d/apache2 reload
驗(yàn)證Nagios的樣例配置文件
/usr/sbin/nagios3 -v /etc/nagios3/nagios.cfg
如果沒(méi)有報(bào)錯(cuò),可以啟動(dòng)Nagios服務(wù)
/etc/init.d/nagios3 restart
#######################################
## Nagios配置 ##
#######################################
#目錄在/etc/nagios3/
#/etc/nagios3/conf.d
首先要修改的就是模版文件否則就會(huì)有問(wèn)題
/etc/nagios3/conf.d 目錄中
generic-host_nagios2.cfg 是主機(jī)模版
generic-service_nagios2.cfg 服務(wù)模版
hostgroups_nagios2.cfg 主機(jī)分組文件
timeperiods_nagios2.cfg 執(zhí)行計(jì)劃的時(shí)間
contacts_nagios2.cfg 聯(lián)絡(luò)方法
#--------------------------------------------------------------------------
#參考手冊(cè): http://nagios-cn.sourceforge.net/nagios-cn/beginning.html#quickstart-ubuntu
#然后我們加入自己的配置文件到里面 例如 switch.cfg 交換機(jī)的
#1.首先修改主機(jī)模版文件generic-host_nagios2.cfg
#2.修改 服務(wù)模版generic-service_nagios2.cfg
#3.修改switch.cfg文件
加入
#1. Define a template for switches that we can reuse(交換機(jī)的模版文件)
define host{
name generic-switch ; The name of this host template
use generic-host ; Inherit default values from the generic-host template
check_period 24x7 ; By default, switches are monitored round the clock
check_interval 5 ; Switches are checked every 5 minutes
retry_interval 1 ; Schedule host check retries at 1 minute intervals
max_check_attempts 10 ; Check each switch 10 times (max)
check_command check-host-alive ; Default command to check if routers are "alive"
notification_period 24x7 ; Send notifications at any time
notification_interval 30 ; Resend notifications every 30 minutes
notification_options d,r ; Only send notifications for specific host states
contact_groups admins ; Notifications get sent to the admins by default
register 0 ; DONT REGISTER THIS - ITS JUST A TEMPLATE
}
#2.在 Create a service to PING to switch
define service{
use generic-service ; Inherit values from a template
hostgroup_name switches ; The name of the hostgroup the service is associated with
service_description PING ; The service description
check_command check_ping!200.0,20%!600.0,60% ; The command used to monitor the service
normal_check_interval 5 ; Check the service every 5 minutes under normal conditions
retry_check_interval 1 ; Re-check the service every minute until its final/hard state is determined
}
#在 3. switch.cfg 交換機(jī)的配置加入交換機(jī)
define host{
use generic-switch ; Inherit default values from a template(使用模版并且使用默認(rèn)值)
host_name 4F-cisco-3560G ; The name we're giving to this switch (交換機(jī)名稱)
# parents 4f-FortiGate200B ;定義上級(jí)節(jié)點(diǎn)
alias cisco 3560G Switch ; A longer name associated with the switch (全名,別名)
address 192.168.1.254 ; IP address of the switch (IP 地址)
icon_p_w_picpath switch50.jpg ;圖標(biāo)
statusmap_p_w_picpath cat2900.gd2 ;地圖顯示圖標(biāo)
hostgroups switches ; Host groups this switch is associated with (主機(jī)加入的編組)
}
#高級(jí)的大家自己玩,就是帶大家入門,下一期入門一下cacti安裝
#------------------------------windows主機(jī)監(jiān)控
#1.
define host{
use windows-server ; Inherit default values from a template
host_name erp; The name we're giving to this host
alias HERP; A longer name associated with the host
parents 4F-cisco-3560G ;定義上級(jí)節(jié)點(diǎn) 影響顯示地圖
address 192.168.1.8; IP address of the host
icon_p_w_picpath windows_server.jpg
statusmap_p_w_picpath win40.gd2
}
#2.加入檢測(cè)服務(wù)
define service{
use generic-service
hostgroup_name erp
service_description NSClient++ Version
check_command check_nt!CLIENTVERSION
}
# Create a service for monitoring the uptime of the server
# Change the host_name to match the name of the host you defined above
#檢查開機(jī)時(shí)間
define service{
use generic-service
hostgroup_name erp
service_description Uptime
check_command check_nt!UPTIME
}
# Create a service for monitoring CPU load
# Change the host_name to match the name of the host you defined above
#檢查cpu平均5分鐘負(fù)載,超過(guò)90%報(bào)警
define service{
use generic-service
hostgroup_name erp
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90
}
# Create a service for monitoring memory usage
# Change the host_name to match the name of the host you defined above
#檢查內(nèi)存使用
define service{
use generic-service
hostgroup_name erp
service_description Memory Usage
check_command check_nt!MEMUSE!-w 80 -c 90
}
# Create a service for monitoring C:\ disk usage
# Change the host_name to match the name of the host you defined above
#檢查磁盤空間
define service{
use generic-service
hostgroup_name erp
service_description C:\ Drive Space
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}
define service{
use generic-service
host_name mail
service_description D:\ Drive Space
check_command check_nt!USEDDISKSPACE!-l d -w 80 -c 90
}