| Server IP : 118.27.122.120 / Your IP : 216.73.216.136 Web Server : Apache System : Linux web0216.sh.tyo1 4.18.0-553.141.2.lve.el7h.x86_64 #1 SMP Wed Jul 8 17:20:31 UTC 2026 x86_64 User : r4834334 ( 11094) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/thread-self/root/lib64/nagios/plugins/ |
Upload File : |
#!/usr/bin/perl
#
use strict;
use DBI;
use warnings;
use Time::HiRes qw(gettimeofday tv_interval);
my $dbname = 'monitoring';
my $dsn = "DBI:mysql:$dbname:mysql_read_default_file=/etc/nagios/.my.cnf;mysql_connect_timeout=15";
my $dbh = DBI->connect($dsn) || die $DBI::errstr;
my $timeout = 50;
my $sql;
my $sth;
my $responsetime;
my $retcode=0;
eval {
local $SIG{ALRM} = sub { die "timeout" };
alarm($timeout);
my $start = [gettimeofday];
$sql = "SELECT SQL_CALC_FOUND_ROWS wp_comments.comment_ID FROM wp_comments JOIN wp_posts ON wp_posts.ID = wp_comments.comment_ID WHERE wp_posts.post_status IN ('publish') ORDER BY wp_comments.comment_date_gmt DESC ";
$sth = $dbh->prepare($sql) || die $dbh->errstr;
my $result_set = $sth->execute || die $sth->errstr;
if ($result_set) {
my $rows = $sth->rows;
for (my $i = 0; $i < $rows; $i++) {
my @result = $sth->fetchrow_array;
}
}
$responsetime = sprintf "%.6f\n", tv_interval $start, [gettimeofday];
#print $responsetime;
$sth->finish;
$dbh->disconnect;
my $status="OK";
my $DATE = `/bin/date +%H%M`;
if ($responsetime > 5.0) {
$status="WARNING"; $retcode=1;
}
if ($responsetime > 10.0) {
if ($DATE >= 300 && $DATE <= 430) {
$status="WARNING"; $retcode=1;
}else{
$status="CRITICAL"; $retcode=2;
}
}
#sleep 30;
print "$status - ResponseTime time=$responsetime\n";
exit($retcode);
alarm(0);
};
if ($@ =~ /timeout/) {
print "CRITICAL - response Timeout over $timeout seconds\n"; $retcode=2;
exit($retcode);
}
elsif ($@) { die("ERROR: timeout") }