perl实现异常时报警
#!/usr/bin/perl -wuse DBI;
use LWP::Simple qw(get);
# $driver="mysql";
$dbh=DBI->connect("DBI:mysql:csunet:localhost","root","")||die"can not connect database";
# 产生当天日期
$year = (gmtime time) + 1900;
$month = (gmtime time) + 1;
$date = (gmtime time);
$today = $year."-".$month."-".$date;
$sql = "select phone from duty_info where RiQi='" .$today. "'";
$sth=$dbh->prepare($sql) || die "Occur an error when query database!";
$sth->execute();
$numRows=$sth->rows;
while(@row=$sth->fetchrow_array)
{
$number = $row;
}
if($numRows == 1)
{
my $url = 'http://202.197.54.130:9999/cgi-bin/csend.exe?N=13687363993,' .$number. '&M=省网7206路由器出现故障请检查';
my $content = get $url;
print $content;
print "/n";
}
print "满足条件的数为: $numRows /n";
print $today;
print "/n";
print $sql;
print "/n";
$sth->finish();
$dbh->disconnect();
exit 0;
页:
[1]