nagios-3种报警方式–声音–email/邮件—短信
應用nagios3的原因就是因為它的強大性和易擴張性,首先我們來研究nagios3的3種報警配額
1. nagios3聲音報警
2. nagios3郵件報警
3. nagios3短信報警
###########Nagios3 聲音報警##########
1.Nagios3 聲音報警的配置,初始安裝完nagios以后我們會發現nagios3的聲音報警是不能用的,
首先呢我們應該去查看它的三個目錄
/etc/nagios3這個目錄下的cgi.cfg這個文件里面的,這個配置是如何配置的
physical_html_path=/usr/share/nagios3/htdocs
它定義了我們聲音文件的存放位置
再次呢我們看/etc/nagios3這個目錄下的cgi.cfg這個文件里面的這些文件
host_unreachable_sound=hostdown.wav
host_down_sound=hostdown.wav
service_critical_sound=critical.wav
service_warning_sound=warning.wav
service_unknown_sound=warning.wav
前面的注釋是否已經取消掉了。把前面的#去掉
最后我們看/usr/share/nagios3/htdocs/media這個目錄下是否有聲音文件,
以及在host.cfg配置文件里面是否定義了以及generic-service配置文件是否開啟了聲音報警。
###############nagios3郵件報警###################
2. nagios3郵件報警
安裝apt-get install sendmail
首先配置contacts_nagios2.cfg這個文件啟用郵件報警
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
配置commands.cfg這個文件里面的
# ‘notify-service-by-email’ command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf “%b” “***** Nagios*****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost:$HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time:$LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$” | /usr/bin/mail -s “**$NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$**” $CONTACTEMAIL$
}
添加以上信息。
添加收件人的信息。
############################nagios3短信報警##################
3. nagios3短信報警
Apt-get install kannel短信網關軟件
/etc/kannel/kannel.conf
group = core
admin-port = 13000
admin-password = user
status-password = pass
admin-deny-ip = “*.*.*.*”
admin-allow-ip = “127.0.0.1;192.168.1.*”
smsbox-port = 13003
#wapbox-port = 13004
box-deny-ip = “*.*.*.*”
box-allow-ip = “127.0.0.1;192.168.1.*”
wdp-interface-name = “*”
log-file = “/var/log/kannel/kannel.log”
log-level = 1
access-log = “/var/log/kannel/kannel.access”
unified-prefix = “+86,0086″ #有這一行,發送信息時就不需要寫手機號碼前的0086或+86
group = smsbox
bearerbox-host = localhost
sendsms-port = 13013
# 轉載請注明出處:http://www.51lop.com
group = smsc
smsc = at
modemtype = wavecom
device = /dev/ttyUSB1
speed = 9600
group = modems
id = wavecom
name = CMCC3G
speed = 9600
group = sendsms-user
username = sms
password = gxroot
啟動kannel,/etc/init.d/kannel start ; smsbox /etc/kannel/kannel.conf啟動短信網關程序。
#轉載請注明出處:http://www.51lop.com
ps -ef|grep box
root 6540 1 0 15:59 ? 00:00:04 bearerbox/etc/kannel/kannel.conf
root 6785 1 0 16:00 ? 00:00:00 smsbox/etc/kannel/kannel.conf
成功啟動以后在nagios上面執行
curl -s –max-time 20 –connect-timeout 5 -d “username=sms” -d“password=gxroot” –data-urlencode “text=Notification: $HOSTNAME$/$HOSTADDRESS$$SERVICEDESC$ is $SERVICESTATE$, $LONGDATETIME$. Add info: $SERVICEOUTPUT$” -d“to=15000000000″ -d “from=gx_root” “http://192.168.1.1:13013/cgi-bin/sendsms”-G
text:后面跟的是我們發送的內容
下面為nagios3服務器commands.cfg的配置文件
# ‘notify-host-by-SMS’ command definition
define command{
command_name notify-host-by-SMS
command_line curl -s –max-time 20 –connect-timeout 5 -d“username=sms” -d “password=gx_root” -d “coding=2″ -d “charset=utf-8″ –data-urlencode “text=??: $HOSTNAME$/$HOSTADDRESS$ ?? $HOSTSTATE$,$LONGDATETIME$” -d “to=13888888888+13666666666″ -d “from=gx_root” “http://192.168.10.96:13013/cgi-bin/sendsms”-G
}
# ‘notify-service-by-SMS’ command definition
define command{
command_name notify-service-by-SMS
command_line curl -s –max-time 20 –connect-timeout 5 -d“username=sms” -d “password=gx_root” -d “coding=2″ -d “charset=utf-8″ –data-urlencode “text=??: $HOSTNAME$/$HOSTADDRESS$ $SERVICEDESC$ ??$SERVICESTATE$, $LONGDATETIME$. ??: $SERVICEOUTPUT$” -d“to=13888888888+13666666666″ -d “from=gx_root” “http://192.168.10.95:13013/cgi-b
in/sendsms” -G
}
摘自http://www.51lop.com/?p=193
轉載于:https://blog.51cto.com/mcmvp/1305734
總結
以上是生活随笔為你收集整理的nagios-3种报警方式–声音–email/邮件—短信的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 运用网络管理工具主动纠错
- 下一篇: 【cocos2d-x 手游研发----目