#!/usr/bin/perl
#取文件行数
##循环开始清空文件
use POSIX;
use CGI;
use DBI;
use HTTP::Date qw(time2iso str2time time2iso time2isoz);
use Net::SMTP;
sub send_mail{
if (@_ != 2){print "请输入2个参数\n";exit 1};
($m,$n) = @_; #将参数赋值给变量
my $to_address = $m;
my $CurrTime = time2iso(time());
my $to_address = $m;
my $mail_user = 'zhaoyangjian@zjcap.cn';
my $mail_pwd = 'xxx5';
my $mail_server = 'smtp.exmail.qq.com';
my $from = "From: $mail_user\n";
my $subject = "Subject: zjcap info\n";
my $info = "$CurrTime--$n";
my $message = <<CONTENT;
$info
CONTENT
my $smtp = Net::SMTP->new($mail_server);
perl 监控单个ip调用接口的次数
最新推荐文章于 2024-07-26 14:15:56 发布
这是一个Perl脚本,用于监控特定日志文件中单个IP地址调用接口的次数。当某个IP调用次数超过30次时,脚本会通过SMTP发送邮件通知。脚本涉及到文件操作、正则表达式匹配、计数和邮件发送。
摘要由CSDN通过智能技术生成