Added support for specific maxadmin path

Added support for specific maxadmin path
This commit is contained in:
MassimilianoPinto
2015-03-06 18:15:14 +01:00
parent 84f00cfe36
commit b2cee0ae18
6 changed files with 50 additions and 14 deletions

View File

@ -1,5 +1,16 @@
MaxScale Nagios plugins, for Nagios 3.5.1 MaxScale Nagios plugins, for Nagios 3.5.1
MaxScale must be configured with 'maxscaled' protocol for the administration interface
[AdminInterface]
type=service
router=cli
[AdminListener]
type=listener
service=AdminInterface
protocol=maxscaled
port=6603
1) copy check_maxscale_*.pl under /usr/lib64/nagios/plugins 1) copy check_maxscale_*.pl under /usr/lib64/nagios/plugins
2) copy maxscale_commands.cfg, server1.cfg to /etc/nagios/objects/ 2) copy maxscale_commands.cfg, server1.cfg to /etc/nagios/objects/
@ -11,10 +22,22 @@ cfg_file=/etc/nagios/objects/maxscale_commands.cfg
cfg_file=/etc/nagios/objects/server1.cfg cfg_file=/etc/nagios/objects/server1.cfg
Please note: Please note:
- modify server IP address in server1.cfg - modify server IP address in server1.cfg, pointing to MaxScale server
- maxadmin executable must be in the nagios server - maxadmin executable must be in the nagios server
- default AdminInterface port is 6603
- default maxadmin executable path is /usr/local/skysql/maxscale/bin/maxadmin
It can be changed by -m option
Example related to server1.cfg
# Check MaxScale sessions, on the remote machine.
define service{
use local-service ; Name of service template to use
host_name server1
service_description MaxScale_sessions
check_command check_maxscale_resource!6603!admin!skysql!sessions!/path_to/maxadmin
notifications_enabled 0
}
4) Restart Nagios 4) Restart Nagios

View File

@ -72,17 +72,21 @@ EOF
'P' => 6603, # port 'P' => 6603, # port
'm' => '/usr/local/skysql/maxscale/bin/maxadmin', # maxadmin 'm' => '/usr/local/skysql/maxscale/bin/maxadmin', # maxadmin
); );
my $MAXADMIN_DEFAULT = $opts{'m'};
getopts('r:hH:u:p:P:m:', \%opts) getopts('r:hH:u:p:P:m:', \%opts)
or usage( $ERRORS{"UNKNOWN"} ); or usage( $ERRORS{"UNKNOWN"} );
usage( $ERRORS{'OK'} ) if $opts{'h'}; usage( $ERRORS{'OK'} ) if $opts{'h'};
my $MAXADMIN_RESOURCE = $opts{'r'}; my $MAXADMIN_RESOURCE = $opts{'r'};
my $MAXADMIN = $opts{'m'}; my $MAXADMIN = $opts{'m'};
if (!defined $MAXADMIN || length($MAXADMIN) == 0) {
$MAXADMIN = $MAXADMIN_DEFAULT;
}
-x $MAXADMIN or -x $MAXADMIN or
die "$curr_script: Failed to find required tool: $MAXADMIN. Please install it or use the -m option to point to another location."; die "$curr_script: Failed to find required tool: $MAXADMIN. Please install it or use the -m option to point to another location.";
my ( $state, $status ) = ( "OK", 'maxadmin ' . $MAXADMIN_RESOURCE .' succeeds.' );
# Just in case of problems, let's not hang Nagios # Just in case of problems, let's not hang Nagios
$SIG{'ALRM'} = sub { $SIG{'ALRM'} = sub {
print ("UNKNOWN: No response from MaxScale server (alarm)\n"); print ("UNKNOWN: No response from MaxScale server (alarm)\n");
@ -117,7 +121,7 @@ my %monitor_data;
while ( <MAXSCALE> ) { while ( <MAXSCALE> ) {
chomp; chomp;
if ( /Unable to connect to MaxScale/ ) { if ( /(Failed|Unable) to connect to MaxScale/ ) {
printf "CRITICAL: $_\n"; printf "CRITICAL: $_\n";
close(MAXSCALE); close(MAXSCALE);
exit(2); exit(2);

View File

@ -72,17 +72,22 @@ EOF
'P' => 6603, # port 'P' => 6603, # port
'm' => '/usr/local/skysql/maxscale/bin/maxadmin', # maxadmin 'm' => '/usr/local/skysql/maxscale/bin/maxadmin', # maxadmin
); );
my $MAXADMIN_DEFAULT = $opts{'m'};
getopts('r:hH:u:p:P:m:', \%opts) getopts('r:hH:u:p:P:m:', \%opts)
or usage( $ERRORS{"UNKNOWN"} ); or usage( $ERRORS{"UNKNOWN"} );
usage( $ERRORS{'OK'} ) if $opts{'h'}; usage( $ERRORS{'OK'} ) if $opts{'h'};
my $MAXADMIN_RESOURCE = $opts{'r'}; my $MAXADMIN_RESOURCE = $opts{'r'};
my $MAXADMIN = $opts{'m'}; my $MAXADMIN = $opts{'m'};
if (!defined $MAXADMIN || length($MAXADMIN) == 0) {
$MAXADMIN = $MAXADMIN_DEFAULT;
}
-x $MAXADMIN or -x $MAXADMIN or
die "$curr_script: Failed to find required tool: $MAXADMIN. Please install it or use the -m option to point to another location."; die "$curr_script: Failed to find required tool: $MAXADMIN. Please install it or use the -m option to point to another location.";
my ( $state, $status ) = ( "OK", 'maxadmin ' . $MAXADMIN_RESOURCE .' succeeds.' );
# Just in case of problems, let's not hang Nagios # Just in case of problems, let's not hang Nagios
$SIG{'ALRM'} = sub { $SIG{'ALRM'} = sub {
print ("UNKNOWN: No response from MaxScale server (alarm)\n"); print ("UNKNOWN: No response from MaxScale server (alarm)\n");
@ -128,7 +133,7 @@ if ($resource_type eq "session") {
while ( <MAXSCALE> ) { while ( <MAXSCALE> ) {
chomp; chomp;
if ( /Unable to connect to MaxScale/ ) { if ( /(Failed|Unable) to connect to MaxScale/ ) {
printf "CRITICAL: $_\n"; printf "CRITICAL: $_\n";
close(MAXSCALE); close(MAXSCALE);
exit(2); exit(2);

View File

@ -72,17 +72,21 @@ EOF
'P' => 6603, # port 'P' => 6603, # port
'm' => '/usr/local/skysql/maxscale/bin/maxadmin', # maxadmin 'm' => '/usr/local/skysql/maxscale/bin/maxadmin', # maxadmin
); );
my $MAXADMIN_DEFAULT = $opts{'m'};
getopts('r:hH:u:p:P:m:', \%opts) getopts('r:hH:u:p:P:m:', \%opts)
or usage( $ERRORS{"UNKNOWN"} ); or usage( $ERRORS{"UNKNOWN"} );
usage( $ERRORS{'OK'} ) if $opts{'h'}; usage( $ERRORS{'OK'} ) if $opts{'h'};
my $MAXADMIN_RESOURCE = $opts{'r'}; my $MAXADMIN_RESOURCE = $opts{'r'};
my $MAXADMIN = $opts{'m'}; my $MAXADMIN = $opts{'m'};
if (!defined $MAXADMIN || length($MAXADMIN) == 0) {
$MAXADMIN = $MAXADMIN_DEFAULT;
}
-x $MAXADMIN or -x $MAXADMIN or
die "$curr_script: Failed to find required tool: $MAXADMIN. Please install it or use the -m option to point to another location."; die "$curr_script: Failed to find required tool: $MAXADMIN. Please install it or use the -m option to point to another location.";
my ( $state, $status ) = ( "OK", 'maxadmin ' . $MAXADMIN_RESOURCE .' succeeds.' );
# Just in case of problems, let's not hang Nagios # Just in case of problems, let's not hang Nagios
$SIG{'ALRM'} = sub { $SIG{'ALRM'} = sub {
print ("UNKNOWN: No response from MaxScale server (alarm)\n"); print ("UNKNOWN: No response from MaxScale server (alarm)\n");
@ -122,7 +126,7 @@ my $start_queue_len = 0;
while ( <MAXSCALE> ) { while ( <MAXSCALE> ) {
chomp; chomp;
if ( /Unable to connect to MaxScale/ ) { if ( /(Failed|Unable) to connect to MaxScale/ ) {
printf "CRITICAL: $_\n"; printf "CRITICAL: $_\n";
close(MAXSCALE); close(MAXSCALE);
exit(2); exit(2);

View File

@ -15,17 +15,17 @@
# check maxscale monitors # check maxscale monitors
define command{ define command{
command_name check_maxscale_monitors command_name check_maxscale_monitors
command_line $USER1$/check_maxscale_monitors.pl -H $HOSTADDRESS$ -P $ARG1$ -u $ARG2$ -p $ARG3$ -r $ARG4$ command_line $USER1$/check_maxscale_monitors.pl -H $HOSTADDRESS$ -P $ARG1$ -u $ARG2$ -p $ARG3$ -r $ARG4$ -m $ARG5$
} }
# check maxscale threads # check maxscale threads
define command{ define command{
command_name check_maxscale_threads command_name check_maxscale_threads
command_line $USER1$/check_maxscale_threads.pl -H $HOSTADDRESS$ -P $ARG1$ -u $ARG2$ -p $ARG3$ -r $ARG4$ command_line $USER1$/check_maxscale_threads.pl -H $HOSTADDRESS$ -P $ARG1$ -u $ARG2$ -p $ARG3$ -r $ARG4$ -m $ARG5$
} }
# check maxscale resource (listeners, services, etc) # check maxscale resource (listeners, services, etc)
define command{ define command{
command_name check_maxscale_resource command_name check_maxscale_resource
command_line $USER1$/check_maxscale_resources.pl -H $HOSTADDRESS$ -P $ARG1$ -u $ARG2$ -p $ARG3$ -r $ARG4$ command_line $USER1$/check_maxscale_resources.pl -H $HOSTADDRESS$ -P $ARG1$ -u $ARG2$ -p $ARG3$ -r $ARG4$ -m $ARG5$
} }

View File

@ -101,7 +101,7 @@ define service{
notifications_enabled 0 notifications_enabled 0
} }
# Define a service to check Script on the local machine. # Define a service to check Script on the remote machine.
define service{ define service{
use local-service ; Name of service template to use use local-service ; Name of service template to use
host_name server1 host_name server1