Nagios plugins update
Nagios plugins update
This commit is contained in:
parent
683bb5a818
commit
c4beb7f6a1
@ -96,17 +96,17 @@ alarm($TIMEOUT);
|
||||
|
||||
my $command = $MAXADMIN . ' -h ' . $opts{'H'} . ' -u ' . $opts{'u'} . ' -p "' . $opts{'p'} . '" -P ' . $opts{'P'} . ' ' . "show " . $MAXADMIN_RESOURCE;
|
||||
|
||||
#print "maxadmin command: $command\n";
|
||||
#
|
||||
# print "maxadmin command: $command\n";
|
||||
#
|
||||
|
||||
open (MAXSCALE, "$command 2>&1 |")
|
||||
or die "can't get data out of Maxscale: $!";
|
||||
|
||||
my $hostname = qx{hostname}; chomp $hostname;
|
||||
my $waiting_backend = 0;
|
||||
my $service;
|
||||
my $start_output = 0;
|
||||
my $n_threads = 0;
|
||||
my $p_threads = 0;
|
||||
my $n_monitors = 0;
|
||||
my $performance_data="";
|
||||
|
||||
|
||||
@ -128,8 +128,8 @@ while ( <MAXSCALE> ) {
|
||||
}
|
||||
|
||||
if ( /^Monitor\:/ ) {
|
||||
$n_threads++;
|
||||
$this_key = 'monitor' . $n_threads;
|
||||
$n_monitors++;
|
||||
$this_key = 'monitor' . $n_monitors;
|
||||
$monitor_data{$this_key} = {
|
||||
'1name'=> '',
|
||||
'2state' => '',
|
||||
@ -172,10 +172,6 @@ while ( <MAXSCALE> ) {
|
||||
}
|
||||
|
||||
if ( /(Sampling interval\:)\s+(\d+) milliseconds/ ) {
|
||||
#my @data_row = split(':', $_);
|
||||
#my $name = $data_row[1];
|
||||
#$name =~ s/^\s+|\s+$//g;
|
||||
#$monitor_data{$this_key}{'4interval'}=$name;
|
||||
$monitor_data{$this_key}{'4interval'}=$2;
|
||||
}
|
||||
|
||||
@ -189,7 +185,6 @@ while ( <MAXSCALE> ) {
|
||||
|
||||
|
||||
for my $key ( sort(keys %monitor_data) ) {
|
||||
#print "-- key: [$key]\n";
|
||||
my $local_hash = {};
|
||||
$performance_data .= " $key=";
|
||||
$local_hash = $monitor_data{$key};
|
||||
@ -197,12 +192,12 @@ while ( <MAXSCALE> ) {
|
||||
foreach my $key (sort (keys (%new_hash))) {
|
||||
$performance_data .= $new_hash{$key} . ";";
|
||||
}
|
||||
chop($performance_data);
|
||||
}
|
||||
|
||||
chop($performance_data);
|
||||
|
||||
if ($n_threads) {
|
||||
printf "OK: %d monitors found |%s\n", $n_threads, $performance_data;
|
||||
if ($n_monitors) {
|
||||
printf "OK: %d monitors found |%s\n", $n_monitors, $performance_data;
|
||||
close(MAXSCALE);
|
||||
exit 0;
|
||||
} else {
|
||||
|
@ -97,16 +97,16 @@ alarm($TIMEOUT);
|
||||
|
||||
my $command = $MAXADMIN . ' -h ' . $opts{'H'} . ' -u ' . $opts{'u'} . ' -p "' . $opts{'p'} . '" -P ' . $opts{'P'} . ' ' . "list " . $MAXADMIN_RESOURCE;
|
||||
|
||||
#print "maxadmin command: $command\n";
|
||||
open (MAXSCALE, "$command 2>&1 |")
|
||||
or die "can't get data out of Maxscale: $!";
|
||||
#
|
||||
# print "maxadmin command: $command\n";
|
||||
#
|
||||
|
||||
open (MAXSCALE, "$command 2>&1 |") or die "can't get data out of Maxscale: $!";
|
||||
|
||||
my $hostname = qx{hostname}; chomp $hostname;
|
||||
my $waiting_backend = 0;
|
||||
my $service;
|
||||
|
||||
my $start_output = 0;
|
||||
my $n_threads = 0;
|
||||
my $p_threads = 0;
|
||||
my $n_resources = 0;
|
||||
my $performance_data="";
|
||||
|
||||
|
||||
@ -128,7 +128,9 @@ if ($resource_type eq "session") {
|
||||
$resource_match = "Session";
|
||||
}
|
||||
|
||||
#print "Matching [$resource_match]\n";
|
||||
#
|
||||
# print "Matching [$resource_match]\n";
|
||||
#
|
||||
|
||||
while ( <MAXSCALE> ) {
|
||||
chomp;
|
||||
@ -146,12 +148,12 @@ while ( <MAXSCALE> ) {
|
||||
}
|
||||
if ($start_output) {
|
||||
next if (/--/ || $_ eq '');
|
||||
$n_threads++;
|
||||
$n_resources++;
|
||||
if ($resource_type ne "session") {
|
||||
my $str;
|
||||
my $perf_line;
|
||||
my @data_row = split('\|', $_);
|
||||
$performance_data .= "module$n_threads=";
|
||||
$performance_data .= "$MAXADMIN_RESOURCE$n_resources=";
|
||||
foreach my $val (@data_row) {
|
||||
$str = $val;
|
||||
$str =~ s/^\s+|\s+$//g;
|
||||
@ -165,11 +167,17 @@ while ( <MAXSCALE> ) {
|
||||
|
||||
chop($performance_data);
|
||||
|
||||
if ($n_threads) {
|
||||
###############################################
|
||||
#
|
||||
# print OK or CRITICAL based on $n_resources
|
||||
#
|
||||
################################################
|
||||
|
||||
if ($n_resources) {
|
||||
if ($performance_data eq '') {
|
||||
printf "OK: %d $MAXADMIN_RESOURCE found\n", $n_threads;
|
||||
printf "OK: %d $MAXADMIN_RESOURCE found\n", $n_resources;
|
||||
} else {
|
||||
printf "OK: %d $MAXADMIN_RESOURCE found | %s\n", $n_threads, $performance_data;
|
||||
printf "OK: %d $MAXADMIN_RESOURCE found | %s\n", $n_resources, $performance_data;
|
||||
}
|
||||
close(MAXSCALE);
|
||||
exit 0;
|
||||
|
@ -96,14 +96,13 @@ alarm($TIMEOUT);
|
||||
|
||||
my $command = $MAXADMIN . ' -h ' . $opts{'H'} . ' -u ' . $opts{'u'} . ' -p "' . $opts{'p'} . '" -P ' . $opts{'P'} . ' ' . "show " . $MAXADMIN_RESOURCE;
|
||||
|
||||
#print "maxadmin command: $command\n";
|
||||
#
|
||||
# print "maxadmin command: $command\n";
|
||||
#
|
||||
|
||||
open (MAXSCALE, "$command 2>&1 |")
|
||||
or die "can't get data out of Maxscale: $!";
|
||||
open (MAXSCALE, "$command 2>&1 |") or die "can't get data out of Maxscale: $!";
|
||||
|
||||
my $hostname = qx{hostname}; chomp $hostname;
|
||||
my $waiting_backend = 0;
|
||||
my $service;
|
||||
my $start_output = 0;
|
||||
my $n_threads = 0;
|
||||
my $p_threads = 0;
|
||||
@ -175,15 +174,12 @@ while ( <MAXSCALE> ) {
|
||||
next;
|
||||
}
|
||||
|
||||
if ( ! /^\s+ID/ ) {
|
||||
#printf $_ ."\n";
|
||||
} else {
|
||||
#printf "[$_]" ."\n";
|
||||
if (/^\s+ID/ ) {
|
||||
$start_output = 1;
|
||||
next;
|
||||
}
|
||||
|
||||
if ($start_output && /^\s+\d/) {
|
||||
#printf "Thread [$_]" . "\n";
|
||||
$n_threads++;
|
||||
if (/Processing/) {
|
||||
$p_threads++;
|
||||
@ -193,14 +189,21 @@ while ( <MAXSCALE> ) {
|
||||
|
||||
close(MAXSCALE);
|
||||
|
||||
$command = $MAXADMIN . ' -h ' . $opts{'H'} . ' -u ' . $opts{'u'} . ' -p "' . $opts{'p'} . '" -P ' . $opts{'P'} . ' ' . "show epoll";
|
||||
|
||||
open( MAXSCALE, "/servers/maxinfo/bin/maxadmin -h 127.0.0.1 -P 8444 -uadmin -pskysql show epoll 2>&1 |" )
|
||||
or die "can't get data out of Maxscale: $!";
|
||||
open (MAXSCALE, "$command 2>&1 |") or die "can't get data out of Maxscale: $!";
|
||||
|
||||
my $queue_len = 0;
|
||||
|
||||
while ( <MAXSCALE> ) {
|
||||
chomp;
|
||||
chomp;
|
||||
|
||||
if ( /(Failed|Unable) to connect to MaxScale/ ) {
|
||||
printf "CRITICAL: $_\n";
|
||||
close(MAXSCALE);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if ( ! /Current event queue length/ ) {
|
||||
next;
|
||||
} else {
|
||||
@ -216,7 +219,6 @@ while ( <MAXSCALE> ) {
|
||||
}
|
||||
}
|
||||
|
||||
my $performance_data = "";
|
||||
my $performance_data_thread = "";
|
||||
my $performance_data_event = "";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user