博客首页 注册 建议与交流 排行榜 加入友情链接
推荐 投诉 搜索: 帮助

系统※网络技术实验室

System & Databses & Networking & Security & Services
evegl.cublog.cn
[原创]一个perl的msn信息发送程序。
文件: lib.rar
大小: 23KB
下载: 下载
#!/usr/local/perl/bin/perl
use lib "/usr/local/nagios/bin/lib";
use lib "/usr/local/perl/lib";
use strict;
use MSN;
use File::Basename;
@ARGV == 2 || die "Syntax: ",basename($0)," <admin>\n";
$|=1;
my $handle = 'your@hotmail.com';
my $password = 'password';
my $admin = $ARGV[0];
my $message = $ARGV[1];
my $msn = new MSN( 'Handle' => $handle, 'Password' => $password, 'Messaging' => 1, 'Debug' => 0, 'AutoReconnect' => 0);
$msn->setHandler( 'Connected' => \&Connected );
$msn->setHandler( 'Message' => \&Logout );
$msn->connect();
my $run = 1;
while($run) {
    $msn->do_one_loop();
}
sub Connected
{
        print( "$handle has connected successfully!\n" );
        $msn->call( $admin,"$message", 'Color' => '00FF00', 'Name' => 'Nagios' );
}
sub Logout
{
        $msn->disconnect();
        $run = 0;
}
 
附件中包含所要的lib文件
 
一些其他的库
perl -MCPAN -e 'install Hash::Merge'
perl -MCPAN -e 'install Net::MSN'
perl -MCPAN -e 'install Crypt::SSLeay'

发表于: 2008-07-08,修改于: 2008-07-21 11:30,已浏览165次,有评论7条 推荐 投诉
网友: myfreeke 时间:2008-07-16 14:57:37 IP地址:210.22.7.★
[root@TS263 msn]# perl hello.pl freeke@chinarenservice.com test
Use of uninitialized value in concatenation (.) or string at lib/MSN/Notification.pm line 864.
Use of uninitialized value in concatenation (.) or string at lib/MSN/Notification.pm line 864.
Use of uninitialized value in concatenation (.) or string at lib/MSN/Notification.pm line 864.
Use of uninitialized value in concatenation (.) or string at lib/MSN/Notification.pm line 864.
Use of uninitialized value in concatenation (.) or string at lib/MSN/Notification.pm line 864.
Use of uninitialized value in concatenation (.) or string at lib/MSN/Notification.pm line 864.
Use of uninitialized value in concatenation (.) or string at lib/MSN/Notification.pm line 864.
Use of uninitialized value in concatenation (.) or string at lib/MSN/Notification.pm line 864.
Use of uninitialized value in concatenation (.) or string at lib/MSN/Notification.pm line 864.
Killing dead socket at lib/MSN.pm line 723.

这是什么问题呢?

网友: myfreeke 时间:2008-07-16 14:59:33 IP地址:210.22.7.★
如果要把您这个工具加在nagios中,该如何配置commands.cfg

网友: 本站网友 时间:2008-07-17 14:24:58 IP地址:222.212.192.★
可以使用,但是,需要回复了才能终止进程,不然,check 就无法继续,而且是所有其它 host service 的 check 都无法继续了,如何才能发出信息就退出呢?

网友: evegl 时间:2008-07-21 11:33:55 IP地址:218.247.140.★
有个超时时间,不过最好是将接收报警的人加为好友,不然报警是收到的。
至于nagios里的配置,看看手册就明白了,很简单。我可以给你借鉴一下我的配置,但还是希望你能理解最好。

define command{
        command_name    service-notify-by-msn
        command_line    /usr/bin/perl /usr/local/nagios/bin/msn_send.pl $CONTACTADDRESS1$ "`/bin/echo -e "***** Nagios  *****\nNotification Type: $NOTIFICATIONTYPE$\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\nDate/Time: $SHORTDATETIME$\nAdditional Info:\n$SERVICEOUTPUT$"`"
}

网友: evegl 时间:2008-07-21 11:35:14 IP地址:218.247.140.★
有个网站,能对msn进行群配置,那个配合着用更方便了。

网友: 本站网友 时间:2008-07-25 10:43:49 IP地址:222.212.192.★
我有把报警 MSN 和接收报警的 MSN 互相加为好友啊。
还是需要设置超时时间吧。

很感谢 evegl 能分享这个程序。

网友: myfreeke 时间:2008-07-26 15:03:19 IP地址:218.18.17.★
非常喜欢你这个Perl 发MSN消息的模块,但我没有配置成功, 我现在使用PHP的类Sendmsg 来发消息!
http://56802890.qzone.qq.com


给我留言
版权所有 ChinaUnix.net 页面生成时间:8.91042