您好,登錄后才能下訂單哦!
nagios 監控自身
定義監控命令 commands.cfg
vim /usr/local/nagios/etc/objects/commands.cfg
#local_server check-host-alive command definition
define command{
command_name xxx #定義監控的名字(自定義)
command_line xxx #定義命令具體實現的功能 $USER1$ = /usr/local/nagios/libexec/ 變量在/usr/local/nagios/etc/resource.cfg中定義
}
#local_server check-host-alive command definition
define command{
command_name check-host-alive
command_line $USER1$/ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5
}
定義監控對象 localhost.cfg
Localhost.cfg相當于是一個監控LINUX主機的模板,如果需要監控其他LINUX主機,可以把這個文件復制一份進行修改。
cp localhost.cfg linux.cfg
vim linux.cfg
define host {
use 監控使用的模板
host_name 被監控主機的主機名
alias 被監控主機別名
address 被監控主機IP地址
}
define host{
use linux-server
host_name localhost
alias localhost
address 127.0.0.1
}
use linux-server:加載linux-server的配置(linux-server已在templates.cfg中定義)
use local-service:加載local-service的配置(已在templates.cfg中定義)
查看templates.cfg:
define host{
name linux-server ; The name of this host template
use generic-host ; This template inherits other values from the generic-host template
check_period 24x7 ; By default, Linux hosts are checked round the clock
check_interval 5 ; Actively check the host every 5 minutes
retry_interval 1 ; Schedule host check retries at 1 minute intervals
max_check_attempts 10 ; Check each Linux host 10 times (max)
check_command check-host-alive ; Default command to check Linux hosts
notification_period workhours ; Linux admins hate to be woken up, so we only notify during the day
; Note that the notification_period variable is being overridden from
; the value that is inherited from the generic-host template!
notification_interval 120 ; Resend notifications every 2 hours
notification_options d,u,r ; Only send notifications for specific host states
contact_groups admins ; Notifications get sent to the admins by default
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
}
check_periaod 24X7: 檢測的時間段為24X7,24X7在timeperiod.cfg
contact_groups admins:發通知給admins組,admins組在contacts.cfg中定義
加載監控對戲那個配置文件 nagios.cfg
vim /usr/local/nagios/etc/nagios.cfg
cfg_file=/usr/local/nagios/etc/objects/commands.cfg
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
cfg_file=/usr/local/nagios/etc/objects/timperiods.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
檢查配置語法是否有誤
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
啟動nagios和httpd服務
service httpd restart
service nagios restart
chkconfig httpd on
chkconfig nagios restart
配置登錄頁面認證用戶
進入WEB頁面查看
http://ip/nagios
自定義監控項目
自定義監控對象
監控/boot分區
首先查看commands.cfg
定義監控的分區
vim localhost.cfg
define service{
use local-service
host_name localhost
service_description Boot Partition 在nagios Services 中顯示的名稱
check_command check_local_disk!50%!40%!/boot
notifications_enabled 1 是否開啟提醒功能。1為開啟,0為禁用
}
重啟nagios
service nagios restart
notifications_enabled
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。