| Server IP : 118.27.122.248 / Your IP : 216.73.217.142 Web Server : Apache System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64 User : c9415830 ( 11735) PHP Version : 8.4.17 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /lib64/nagios/plugins/ |
Upload File : |
#!/bin/perl
use strict;
use warnings;
use Getopt::Long;
use DBI();
my $opt_crit = 0;
my $opt_warn = 0;
my $opt_query = '';
GetOptions('critical=i' => \$opt_crit, 'warning=i' => \$opt_warn);
sub ERROR {
print "UNKNOWN - database connection error.\n";
exit 3;
}
my $dsn = "DBI:mysql:mysql_read_default_file=/etc/nagios/.my.cnf;mysql_connect_timeout=15";
my $dbh = DBI->connect($dsn) || ERROR();
my $sth = $dbh->prepare("show status like 'Threads_connected';") || ERROR();
my $count = 0;
$sth->execute();
my $ref = $sth->fetchrow_hashref();
$count = $ref->{'Value'};
if($count >= $opt_crit) {
print "CRITICAL - $count client connection threads.\n";
exit 2;
} elsif($count >= $opt_warn) {
print "WARNING - $count client connection threads.\n";
exit 1;
} elsif($count >= 0) {
print "OK - $count client connection threads.\n";
exit 0;
} else {
print "UNKNOWN - couldn't get connection threads.\n";
exit 3;
}