Zabbix自动化监控QQ交流群:9888359 欢迎喜欢交流的朋友加入!
一、环境
cat /etc/redhat-release
操作系统:CentOS Linux release 7.3.1611 (Core)
Zabbix软件版本:zabbix_server (Zabbix) 3.2.9
二、安装所需包
yum install lrzsz chrony gcc gcc-c++ git openssl-devel perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker -y
systemctl enable chronyd
systemctl start chronyd
三、安装Mojo-Webqq
curl -L https://cpanmin.us/ -o /usr/bin/cpanm && chmod +x /usr/bin/cpanm
cpanm --mirror http://mirrors.sohu.com/CPAN/ Digest::MD5 Encode::Locale IO::Socket::SSL Mojolicious Time::Piece Time::Seconds Compress::Raw::Zlib Digest::SHA --force
cpanm Mojo::SMTP::Client MIME::Lite
cd /usr/src/ && git clone https://github.com/sjdy521/Mojo-Webqq.git
cd Mojo-Webqq/ && perl Makefile.PL
make && make install
vim /usr/local/bin/MojoWebqq.pl
#!/usr/bin/env perl
use Mojo::Webqq;
my ($host,$port,$post_api);
$host = "0.0.0.0";
$qq = "10880347";
$port = 5000;
my $client = Mojo::Webqq->new(qq=>$qq);
$client->load("PostQRcode",data=>{
smtp => 'smtp.qq.com',
port => '25',
from => '[email protected]',
to => '[email protected]',
user => '[email protected]',
pass => '***',
});
$client->login();
#$client->load("ShowMsg");
$client->load("Openqq",data=>{listen=>[{host=>$host,port=>$port}], post_api=>$post_api});
$client->run();
添加执行权限
chmod +x /usr/local/bin/MojoWebqq.pl
后台启动Mojo-Webqq进程
/usr/local/bin/MojoWebqq.pl >>/var/log/zabbix/zabbix-Mojo-Webqq.log 2>&1 &
tail -f /var/log/zabbix/zabbix-Mojo-Webqq.log
(Missing semicolon on previous line?)
syntax error at /usr/local/bin/MojoWebqq.pl line 14, near "pass => '"
Execution of /usr/local/bin/MojoWebqq.pl aborted due to compilation errors.
[17/10/29 20:36:43] [info] 当前正在使用 Mojo-Webqq v2.1.4
[17/10/29 20:36:43] [info] 执行插件[ Mojo::Webqq::Plugin::PostQRcode ]
[17/10/29 20:36:43] [info] 初始化 smartqq 客户端参数...
[17/10/29 20:36:43] [info] 正在获取登录二维码...
[17/10/29 20:36:44] [info] 二维码已下载到本地[ /tmp/mojo_webqq_qrcode_default.png ]
[17/10/29 20:36:44] [info] 登录二维码已经发送到邮箱: [email protected]
[17/10/29 20:36:44] [info] 等待手机QQ扫描二维码...
测试结果
如果出现该问题:
[17/11/21 17:20:32] [error] 发送邮件,请先安装模块 Mojo::SMTP::Client
[17/11/21 17:20:32] [error] 插件[Mojo::Webqq::Plugin::PostQRcode]邮件发送失败:
解决办法
cpanm Mojo::SMTP::Client MIME::Lite --force
Zabbix自动化监控QQ交流群:9888359 欢迎喜欢交流的朋友加入!