Chinaunix首页 | 论坛 | 博客
  • 博客访问: 519114
  • 博文数量: 126
  • 博客积分: 851
  • 博客等级: 准尉
  • 技术积分: 1287
  • 用 户 组: 普通用户
  • 注册时间: 2012-10-06 11:21
个人简介

个人最新博客地址http://www.skylway.com/

文章分类

全部博文(126)

文章存档

2016年(2)

2014年(60)

2013年(35)

2012年(29)

分类: Python/Ruby

2012-11-09 11:47:39

准备写个监控,client监控应用程序的日志,有异常插入数据到DB,server轮询DB,发现需要发送的告警的,发送邮件给相关人。其中server端的的告警类型,发送对象都是可以配置的。
今天测试了2个模块,监控日志文件和mail发送,纪录下perl发送mail的脚本
安装参考了参见

安装了2个module,
MIME::Base64 --这个可以不装;
Mail::Sender
debug打开日志还是比较重要。用变量时,邮箱地址的@,需要转义下。
#!/usr/bin/perl
use Mail::Sender;
my $text=aaaaaaa;
my $mailto="zhou_xinwei\@vobile.cn,zhou_xinwei\@vobile.cn,jiang_changlin\@vobile.cn";
open my $DEBUG, ">> /tmp/mail.log" or die "Can't open the debug file: $!\n";
my $sender = new Mail::Sender {
     smtp => 'mail.vobile.cn',
     from => [email='ops_report@vobile.cn']%27ops_report@vobile.cn%27[/email],
     on_errors => undef,
     client=>'hz-151.vobile.cn',
     debug => $DEBUG
} or die "Can't create the Mail::Sender object: $Mail::Sender::Error\n";
$sender->MailMsg({
       to =>$mailto,
       subject => "mail test do not replay",
       msg => $text,
       debug=>$DEBUG}) or print $Mail::Sender::Error;
$sender ->Close();
阅读(933) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~