Check if there is one node only in the cluster
This commit is contained in:
Quentin Garnier 2014-11-04 13:54:16 +01:00
parent c32224b5b7
commit c963c47b10
1 changed files with 16 additions and 0 deletions

View File

@ -64,6 +64,7 @@ sub new {
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"one-node-status:s" => { name => 'one_node_status', default => 'critical' },
});
return $self;
@ -72,6 +73,11 @@ sub new {
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if ($self->{output}->is_litteral_status(status => $self->{option_results}->{one_node_status}) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong one-node-status status option '" . $self->{option_results}->{one_node_status} . "'.");
$self->{output}->option_exit();
}
}
sub run {
@ -119,6 +125,12 @@ sub run {
$self->{result}->{$oid_fgHaStatsSerial}->{$key}, $maps_sync_status{$sync_status}));
}
}
if (scalar(keys %{$self->{result}->{$oid_fgHaStatsSerial}}) == 1 &&
!$self->{output}->is_status(value => $self->{option_results}->{one_node_status}, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $self->{option_results}->{one_node_status},
short_msg => sprintf("Cluster with one node only"));
}
}
$self->{output}->display();
@ -135,6 +147,10 @@ Check cluster status (FORTINET-FORTIGATE-MIB).
=over 8
=item B<--one-node-status>
Status if only one node (default: 'critical').
=back
=cut