Skip to content

Commit

Permalink
Merge pull request #12 from slauger/development
Browse files Browse the repository at this point in the history
New check "staserver" (#11)
  • Loading branch information
slauger authored Feb 26, 2017
2 parents c6588d4 + f97faba commit 3b77909
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Currently the plugin has the following subcommands:
- **above, below:** check if a value is above/below a threshold (e.g. traffic limits, concurrent connections)
- **sslcert:**: check the lifetime for installed ssl certificates
- **nsconfig:** check for configuration changes which are not saved to disk
- **staservers:** check if configured STA servers are available
- **debug:** debug command, print all data for a endpoint

This plugin works with VPX, MPX and SDX NetScaler Appliances. The api responses may differ by build, appliance type and your installed license.
Expand Down Expand Up @@ -99,6 +100,14 @@ If you want to connect to your NetScaler with SSL/HTTPS you should also install
# NetScaler::Config
./check_netscaler.pl -H ${IPADDR} -s -C nsconfig

## Check if STA servers are working

# NetScaler::STA
./check_netscaler.pl -H ${IPADDR} -s -C staservers

# NetScaler::STA
./check_netscaler.pl -H ${IPADDR} -s -C staservers -n vs_vpn_gateway

## Debug command
# Print all LB vServers (stat endpoint)
./check_netscaler.pl -H ${IPADDR} -s -C debug -o lbvserver
Expand Down
43 changes: 43 additions & 0 deletions check_netscaler.pl
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@
} elsif ($plugin->opts->command eq 'nsconfig') {
# check for unsaved configuration changes
check_nsconfig($plugin);
} elsif ($plugin->opts->command eq 'staserver') {
# check the state of the staservers
check_staserver($plugin);
} elsif ($plugin->opts->command eq 'debug') {
# dump the full response of the nitro api
check_debug($plugin);
Expand Down Expand Up @@ -532,6 +535,46 @@ sub check_sslcert
}
}

sub check_staserver
{
my $plugin = shift;

my %params;
$params{'endpoint'} = $plugin->opts->endpoint || 'config';
$params{'objectname'} = $plugin->opts->objectname || '';
$params{'options'} = undef;

if ($params{'objectname'} eq '') {
$params{'objecttype'} = $plugin->opts->objecttype || 'vpnglobal_staserver_binding';
} else {
$params{'objecttype'} = $plugin->opts->objecttype || 'vpnvserver_staserver_binding';
}

my $response = nitro_client($plugin, \%params);
$response = $response->{$params{'objecttype'}};

# return critical if all staservers are down at once
my $critical = 1;

# check if any stas are in down state
foreach $response (@{$response}) {
if ($response->{'staauthid'} eq '') {
$plugin->add_message(WARNING, $response->{'staserver'} . ' unavailable;');
} else {
$plugin->add_message(OK, $response->{'staserver'} . ' OK (' . $response->{'staauthid'}.');');
$critical = 0;
}
}

my ($code, $message) = $plugin->check_messages;

if ($critical) {
$plugin->nagios_exit(CRITICAL, 'staservice ' . $message);
} else {
$plugin->nagios_exit($code, 'staservice ' . $message);
}
}

sub check_nsconfig
{
my $plugin = shift;
Expand Down

0 comments on commit 3b77909

Please sign in to comment.