一,用sendmail發(fā)送郵件
10年積累的成都網(wǎng)站制作、成都做網(wǎng)站經(jīng)驗,可以快速應(yīng)對客戶對網(wǎng)站的新想法和需求。提供各種問題對應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識你,你也不認(rèn)識我。但先建設(shè)網(wǎng)站后付款的網(wǎng)站建設(shè)流程,更有長安免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。1、下載安裝sendEmail
wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz
tar zxvf sendEmail-v1.56.tar.gz
cd sendEmail-v1.56
cp sendEmail /usr/local/bin/
chmod 775 /usr/local/bin/sendEmail
chown nagios:nagios /usr/local/bin/sendEmail #因為我要讓nagios發(fā)郵件所以用的是nagios用戶
2、測試一下
/usr/local/bin/sendEmail -f skykws@163.com -t 872260085@qq.com -s smtp.163.com -u "郵件標(biāo)題" -xu skykws -xp 000000 -m "郵件內(nèi)容"
3、郵件參數(shù):
-f 發(fā)送者地址 -t 接收者地址 -s SMTP服務(wù)器地址(可以是域名或IP)
-u 郵件主題 -xu SMTP驗證用戶名
-xp SMTP驗證密碼(注意,這個密碼有限制,有一些特殊符號或者超長度密碼不能被正確識別)
-m郵件具體內(nèi)容 如不帶-m參數(shù)的話,就會提示你自行輸入,輸入完成后CTRL-D來結(jié)束
Nagios通過sendEmail報警需要修改commands.cfg
#'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/local/bin/sendEmail -f skykws@163.com -t $CONTACEMAIL$ -s SMTP.163.COM "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -xu skykws -xp 0000000 $CONTACTEMAIL$
}
# '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:0$HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/local/bin/sendEmail -f skykws@163.com -t $CONTACEMAIL$ -s SMTP.163.COM"** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -xu skykws -xp 000000 $CONTACTEMAIL$
}
[root@localhost objects]# vi contacts.cfg
email skykws@163.com 修改添加郵件地址
pager 15800000000 添加這行
(例子:command_line
/usr/local/bin/sendEmail -f 發(fā)送賬戶 -t $CONTACTEMAIL$ -s smtp服務(wù)器地址 -u "** $NOTIFICATIONTYPE$ 主機(jī)警報: $HOSTNAME$ is $HOSTSTATE$ **" -m "主機(jī)
警報*\n\n通知類型: $NOTIFICATIONTYPE$\n主機(jī): $HOSTNAME$\n狀態(tài): $HOSTSTATE$\nip地址: $HOSTADDRESS$\n信息: $HOSTOUTPUT$\n\n北京時間: $LONGDATETIME$\n-by 信息技術(shù)部\n" -xu 用戶 -xp 密碼 -o message-charset=utf-8
然后是服務(wù)報警的command_line
/usr/local/bin/sendEmail -f 發(fā)送賬戶 -t $CONTACTEMAIL$ -s smtp服務(wù)器地址 -u "** $NOTIFICATIONTYPE$ 服務(wù)警報: $HOSTNAME$ is $HOSTSTATE$ **" -m "*服>務(wù)報警*\n\n警報類型: $NOTIFICATIONTYPE$\n\n服務(wù): $SERVICEDESC$\n主機(jī): $HOSTALIAS$\nip地址: $HOSTADDRESS$\n狀態(tài): $SERVICESTATE$\n\n北京時間: $LONGDATETIME$\n\n信息:\n\n$SERVICEOUTPUT$\n-by 信息技術(shù)部\n" -xu 用戶 -xp 密碼 -o message-charset=utf-8)
二,用本地mail發(fā)送郵件
[root@localhost]#vi /etc/mail.rc
set from=skykws@163.com smtp=smtp.163.com set smtp-auth-user=skykws smtp-auth-password=000000 smtp-auth=login
[root@localhost]#cd /bin/
[root@localhost]#mail -s "skykws" skykws@163.com <123.txt
Nagios通過mail報警需要修改commands.cfg
# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
# '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$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
三,fetion
1.安裝飛信
[root@localhost ~]#unzip fetion.zip
[root@localhost ~]#mv fx fetion
[root@localhost ~]#cp -R fetion /usr/local/
[root@localhost ~]#cp libACE-5.7.2.so libcrypto.so.4 libssl.so.4 libACE_ssl-5.7.2.so libeay32.dll /usr/lib/
[root@localhost ~]#chown -R nagios:nagios /usr/local/fetion/fetion
[root@localhost ~]#chmod -R 775 /usr/local/fetion/fetion
[root@localhost ~]#vi /etc/ld.so.conf
添加“/usr/local/fetion/fetion/”
[root@localhost ~]#ldconfig
[root@localhost ~]#cd /usr/local/fetion/fetion
[root@localhost fx]# ./fetion --mobile=15889971794 --pwd=000000 --to=15889971794 --msg-type=1 --msg-utf8="測試"
2、修改commands.cfg
#"notify-host-by-fetion"
define command{
command_name notify-host-by-fetion
command_line LD_LIBRARY_PATH=/usr/local/fetion /usr/local/fetion/fetion --mobile=15889971794 --pwd=000000 --to=15889971794 --msg-utf8="HOST$HOSTSTATE$ alert for $HOSTNAME$!on'$LONGDATETIME$'"$CONTACTPAGER$
}
#"notify-service-by-fetion"
define command{
command_name notify-service-by-fetion
command_line LD_LIBRARY_PATH=/usr/local/fetion /usr/local/fetion/fetion --mobile=15889971794 --pwd=000000 --to=15889971794 --msg-utf8="$HOSTADDRESS$ $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ on $LONGDATETIME$" $CONTACTRAGER$
}
3、使用飛信報警命令
[root@localhost objects]# vi templates.cfg //對應(yīng)添加:notify-service-by-fetion notify-host-by-fetion;
service_notification_commands notify-service-by-email,notify-service-by-fetion;
host_notification_commands notify-host-by-email,notify-host-by-fetion;
四,nagios的頁面聲音報警
1. 準(zhǔn)備音頻文件,后綴要求.wav
2. 修改配置文件:/usr/local/nagios/etc/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
#normal_sound=noproblem.wav(這是設(shè)置正常情況下聲音,一般注釋)
3. 將音頻文件上傳的文件夾/usr/local/nagios/share/media/
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
文章名稱:sendmail,mail,fetion,頁面聲音實(shí)現(xiàn)nagios報警-創(chuàng)新互聯(lián)
文章鏈接:http://aaarwkj.com/article20/dgdojo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供用戶體驗、App設(shè)計、App開發(fā)、做網(wǎng)站、外貿(mào)建站、動態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容