zabbix 设置邮件警告

回复 收藏
1)、vim /etc/zabbix/alertscripts/smail.pl

#!/usr/bin/perl
use Net::SMTP;
   use HTTP::Date qw(time2iso str2time time2iso time2isoz);
# mail_user should be your_mail@163.com
sub send_mail{
       if ( $#ARGV < 2 ){
        print "please input 收件人 主题  内容!\n";
                exit(-1);
                    }
    my $name= $ARGV[2];
my $CurrTime = time2iso(time());
    my $to_address  = shift;
    my $mail_user   = 'liuyangjun@zjcap.cn';
    my $mail_pwd    = 'Lyj!2015';
    my $mail_server = 'smtp.exmail.qq.com';

    my $from    = "From: $mail_user\n";
    my $subject = "Subject:$ARGV[1]";
    my $info = "$CurrTime--$name ";
     my $message = <new($mail_server);

    $smtp->auth($mail_user, $mail_pwd) || die "Auth Error! $!";
    $smtp->mail($mail_user);
    $smtp->to($to_address);

    $smtp->data();             # begin the data
    $smtp->datasend($from);    # set user
    $smtp->datasend($subject); # set subject
    $smtp->datasend("\n\n");
    $smtp->datasend("$message\n"); # set content
    $smtp->dataend();
    $smtp->quit();
};
$receive=$ARGV[0];
@arr_mail=( "$receive");
foreach (@arr_mail){
send_mail $_;
};

2)、设置 administration-> media types -> create media type  

3)、设置 Configuration -> Actions -> create Action ( trigger )






4)、设置  group 权限 或者 user 权限  Administration -> users
2016-02-19 10:58 举报
已邀请:
0

1101066558

赞同来自:

图片上不了
0

zxc123

赞同来自:

学习了

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: