服务器技术

 首页 > 服务器技术 > Linux > nagios 使用MSN 发报警消息 - Linux操作系统:Ubuntu

nagios 使用MSN 发报警消息 - Linux操作系统:Ubuntu

分享到:
【字体:
导读:
          公司管理的服务器太多了!在年前部属了cacti,但cacti只能做事后分析的工作,而实时报警功能不强,在部属cacti前就在监控PC上安装了nagios,只是一直没有时间详细研究!目前在我们的几...

公司管理的服务器太多了!在年前部属了cacti,但cacti只能做事后分析的工作,而实时报警功能不强,在部属cacti前就在监控PC上安装了nagios,只是一直没有时间详细研究!目前在我们的几百台服务器上都使用脚本自动化管理!然后发报警邮件!
这段时间有点时间下来研究nagios,从今天开始就将我近段时间研究的结果记录下来!为以后再部属好查寻,做一下资料!
今天主要记录下昨天研究成功的基础nagios上报警使用MSN消息的方式!

1、准备MSN 机器人登陆使用的MSN帐号、接收报警消息的MSN帐号,两个一定要相互加为好友的关系;

2、MSN 机器人使用PHP 类:sendMsg
下载sendMsg安装,只需要将sendMsg目录放在web 根目录下就可以,配置好MSN注册使用的MSN帐号、密码;配置接收人的MSN帐号:

    $senderUser=MSN帐号;
    $senderPass=密码;
    $sendToList = array(接受消息人1,接受消息人2);


配置好上面消息后可以测试:
在IE中打开以面的链接,那么在MSN报警接收MSN帐户就可以接收到下面的中文消息:

http://noc.chinarenservice.com/msn/index.php?SendMess=我打死你


 

3、 commands.cfg 配置

[root@TS263 servers]# less /usr/local/nagios/etc/servers/commands.cfg
###################################### Msn Alert #########################################################
# notify-by-msn command definition
define command{
        command_name    notify-host-by-msn
        command_line    /usr/bin/printf "%b" "***** Nagios 1.0 ***** Notification Type: $NOTIFICATIONTYPE$ Service: $SERVICEDESC$ Host: $HOSTALIAS$ Address: $HOSTADDRESS$ State: $SERVICESTATE$ Date/Time: $DATETIME$ Additional Info: $OUTPUT$" > /usr/local/nagios/msnhost.out | $USER1$/messagehost.sh
        }
# notify-service-by-msn command definition
define command{
        command_name    notify-service-by-msn
        command_line    /usr/bin/printf "%b" "***** Nagios ***** Notification Type: $NOTIFICATIONTYPE$ Service: $SERVICEDESC$ Host: $HOSTALIAS$ Address: $HOSTADDRESS$ State: $SERVICESTATE$ Date/Time: $LONGDATETIME$ Additional Info: $SERVICEOUTPUT$" > /usr/local/nagios/msnservice.out | $USER1$/messageservice.sh
        }
[root@TS263 servers]# less /usr/local/nagios/libexec/messageservice.sh
#!/bin/bash
message=`cat /usr/local/nagios/msnservice.out`
wget -qO- http://noc.chinarenservice.com/msn/index.php?SendMess="$message"

4、添加一个MSN接收消息的联系人

[root@TS263 servers]# less /usr/local/nagios/etc/servers/contacts.cfg
define contact{
        contact_name                    freeke2
        alias                           freeke2
        use                             generic-contact
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    w,u,c,r
        host_notification_options       d,u,r
        service_notification_commands   notify-service-by-msn
        host_notification_commands      notify-host-by-msn
        email                           myfreeke@gmail.com
        pager                           15920094782
        address1                        myfreeke@gmail.com
        address2                        555-555-5555
        }
添加上面的联系人后,注意在联系人组中也需要添加上该联系人

[root@TS263 servers]# less /usr/local/nagios/etc/servers/contactgroup.cfg
define contactgroup{
        contactgroup_name admin
        alias Nagios Administrators
        members support,freeke2
        }

然后在service  配置是添加上contact_groups admin 就可以正常使用MSN报警功能了。效果就像上面的图一下接收报警信息!

配置nagios使用MSN,问了不少人,由于自己不懂shell和写代码,以至于自己在这上面郁闷了非常长的一段时间!

      上一篇:快速配置Linux下DHCP服务器配置 - Linux操作系统: 下一篇:Macbuntu 2.3 发布,漂亮的Ubuntu下仿苹果主题 - Linux操
    分享到:
    Macbuntu 2.3 发布,漂亮的Ubuntu下仿苹果...
       Macbuntu 是一个专门用于 Ubuntu 的风格转换包,通过其提供的 install.sh 脚本就可以把 Ubuntu 一键打造成完整的 Mac 风格。这里特别提到了完整性这一特点,是因为它不同于 Mac4Lin 这样只是表面风格的主题,Macbuntu 提供了更进一步的风格调整。        Download Macbuntu 2.3   http://gnome-look.org...
    快速配置Linux下DHCP服务器配置 - Linux...
      在以往的学习中,我们已经了解了DHCP服务的基础内容,相对的我们也学会了Windows系统下的DHCP服务器的配置。接下来我们主要讲解一下Linux DHCP服务器的配置内容。   Linux DHCP服务器配置   1.安装Linux DHCP服务软件包   RHEL4第四张光盘,dhcp-3.0.1-12_EL.i386.rpm   挂载 mount /dev/cdrom /media/cdro...
    •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
    • 在这里……