×

微信扫一扫,快捷登录!

nagios与飞信能牵手吗

标签: 暂无标签
来自:网络

Nagios整合飞信
从服务端下载fection
root@server20 ~]#cp fection /usr/local/nagios/libexec/
root@server20 ~]#chmod +x /usr/local/nagios/libexec/fection
root@server20 ~]#chown nagios.nagios /usr/local/nagios/libexec/fection          nagios安装
root@server20 ~]#tar zxf linuxso_20101113.tar.gz -C /usr/lib
[root@server20 ~]# yum install -y /lib/ld-linux.so.2 libstdc++ libgssapi_krb5.so.2 libz.so.1 libstdc++.so.6
[root@server20 ~]#useradd nagios

[root@server20 ~]# su - nagios
-bash-4.1$ /usr/local/nagios/libexec/fection
************************ IMPORTANT STATEMENT ************************
**                                                               **
**   PLEASE DON'T USE THIS SOFTWARE TO SEND JUNK SHORT MESSAGES. **
**   OTHERWISE PLEASE BEAR YOUR OWN CONSEQUENCES.                 **
**                                                               **
**                                Version:[20101205002-linux]     **
*********************************************************************
This program is the console version of China Fetion!
It's free for personal user.
This project website:

AUTHOR:KelvinH MSN/EMAIL:shichangguo@msn.com             开源监控软件

Usage:
--mobile=[mobile]
--sid=[sid]
--pwd=[pwd]
--config=[config file] *format:index mobile password
--index=[index no in config file,refer to sample.conf]

--debug  *debug mode on
--hide  *login fetion in hidden state
--to=[mobile/sid]
--command-path=[command file path]                  nagios配置
--robotmode
--daemon(linux only)
--proxy-ip(http proxy ip)
--proxy-port(http proxy port)
--msg-gb=[gb2312/gbk message]
--msg-utf8=[utf8 message]
--msg-type=[0/1/2 sms longsms smartmsg]
--file-gb=[gb2312/gbk file]
--file-utf8=[utf8 file]
--query-cmcc-no
--auto-retry
--exit-on-verifycode
--t3key=[page/smssend/]
-bash-4.1$ /usr/local/nagios/libexec/fection --mobile=1599177xxxx --pwd=xxx --to 1599177xxxx --msg-utf8="hello world"
HTTP/1.0 200 OK
Date: Sat, 19 Jul 2014 08:35:16 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
Content-Location:  
X-AspNet-Version: 4.0.30319
Cache-Control: private
Content-Type: text/html; charset=utf-8                     监控软件
Content-Length: 2641
X-Cache: MISS from 192.168.2.251
X-Cache-Lookup: MISS from 192.168.2.251:3128
Via: 1.0 192.168.2.251 (squid/3.1.10)
Connection: close

<?xml version="1.0" encoding="UTF-8"?><results><pic-certificate id="94e989ad-3b55-487d-b6e2-fee214f1b2dc" pic="/9j/4AAQSkZJRgABAQEAYAB~~~~~~KKKACiiigAooooAKKKKAP//Z" /></results>
图形验证码已经生成,文件名为:1599177xxxx.jpg请识别后输入图形验证码:
vrue (该验证码生成在主机的/usr/local/nagios/libexec下,文件名为1599177xxxx.jpg,将此验证码图片拷贝到桌面打开)
您输入的识别码是:vrue
SIP-C/4.0 280 Send SMS OK
T: sip:272963077@ ;p=6818
I: 2
Q: 1 M
RQ: 49437349055
L: 112
XI: 599cd11d573345459b2da1dd4c1dd4d6 (提示已经发送成功,这时候在手机上就可以收到飞信)
-bash-4.1$ cd /usr/local/nagios/libexec创建脚本fection.sh
-bash-4.1$ cat fection.sh
/usr/local/nagios/libexec/fection --mobile=1599177xxxx --pwd=fanhairong --to="$1" --msg-utf8="$2"
-bash-4.1$ chmod +x fection.sh
-bash-4.1$ ll fection
-rwxr-xr-x 1 nagios nagios 503425 Jul 18 23:41 fection
-bash-4.1$ /usr/local/nagios/libexec/fection.sh 1599177xxxx "good luck"
SIP-C/4.0 280 Send SMS OK
T: sip:272963077@ ;p=6818
I: 2
Q: 1 M
RQ: 49439097020
L: 112
XI: 67efc70021514bbbbdc9001385535872 (脚本运行成功,飞信发送成功)          nagios实施
[root@server20 ~]# cd /usr/local/nagios/etc/objects/
1.增加 fetion 报警选项: templates.cfg
修改/usr/local/nagios/etc/objects/templates.cfg
在 define contact{...}部分,将以下两行(33,34):
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
改为:
service_notification_commands notify-service-by-email,service-notify-by-fetion
host_notification_commands notify-host-by-email,host-notify-by-fetion
2.增加调用脚本: commands.cfg
修改/usr/local/nagios/etc/objects/commands.cfg
在该文件的最后增加以下部分:
##### 'host-notify-by-fetion' command definition
define command{
command_name host-notify-by-fetion
command_line $USER1$/fetion.sh $CONTACTPAGER$ "$NOTIFICATIONTYPE$ alert -Host $HOSTNAME$ is $HOSTSTATE$"
}
##### service-notify-by-fetion command definition
define command{
command_name service-notify-by-fetion
command_line $USER1$/fetion.sh $CONTACTPAGER$ "$NOTIFICATIONTYPE$: $HOSTalias$/$SERVICEDESC$ is $SERVICESTATE$"
3.修改联系人选项: contact.cfg
修改/usr/local/nagios/etc/objects/contact.cfg
在 define contact{...} 部分增加如下一行
define contact{
contact_name              nagiosadmin
use                             generic-contact
alias                           Nagios Admin
email                          xxx@qq.com        ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
pager                         159xxxxxxxx ; #接收飞信信息的手机号码
  }
[root@server20 objects]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 检查语法错误
[root@server20 objects]# service httpd  restart
Stopping httpd:                                            [  OK ]
Starting httpd:                                            [  OK ]
[root@server20 objects]# service nagios restart                  nagios培训
Running configuration check...
Stopping nagios: .done.
Starting nagios: done.
假如某主机出现问题,192.168.2.20/nagios里会显示问题,并且通过飞信和邮件通知。需要禁用抖动检测才会收到邮件或者飞信。
[  /uploads/space/2014/0721/175319_ooCv_1867979.png][/url]




想做Nagios Zabbix,Cacti,iTop各种交流的,可以进入开源监控工具Nagios交流  QQ群号 476809427




上一篇:如何部署nagios
下一篇:nagios监控linux的途径
monicazhang

写了 2297 篇文章,拥有财富 12859,被 21 人关注

您需要登录后才可以回帖 登录 | 立即注册
B Color Link Quote Code Smilies

成为第一个吐槽的人

Powered by IT 运维管理
返回顶部