enhance indent big
This commit is contained in:
parent
f26d4dfb5d
commit
8c40b63b13
|
@ -122,10 +122,14 @@ sub manage_selection {
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
my $result = $options{snmp}->get_leef(oids => [$oid_sysStatClientCurConns, $oid_sysStatServerCurConns,
|
my $result = $options{snmp}->get_leef(
|
||||||
$oid_sysClientsslStatCurConns, $oid_sysServersslStatCurConns,
|
oids => [
|
||||||
$oid_sysClientsslStatTotNativeConns, $oid_sysClientsslStatTotCompatConns],
|
$oid_sysStatClientCurConns, $oid_sysStatServerCurConns,
|
||||||
nothing_quit => 1);
|
$oid_sysClientsslStatCurConns, $oid_sysServersslStatCurConns,
|
||||||
|
$oid_sysClientsslStatTotNativeConns, $oid_sysClientsslStatTotCompatConns
|
||||||
|
],
|
||||||
|
nothing_quit => 1
|
||||||
|
);
|
||||||
$self->{global} = {
|
$self->{global} = {
|
||||||
client => $result->{$oid_sysStatClientCurConns},
|
client => $result->{$oid_sysStatClientCurConns},
|
||||||
client_ssl => $result->{$oid_sysClientsslStatCurConns},
|
client_ssl => $result->{$oid_sysClientsslStatCurConns},
|
||||||
|
|
|
@ -86,14 +86,12 @@ sub new {
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
'warning-sync-status:s' => { name => 'warning_sync_status', default => '' },
|
||||||
"filter-counters:s" => { name => 'filter_counters' },
|
'critical-sync-status:s' => { name => 'critical_sync_status', default => '%{syncstatus} =~ /unknown|syncFailed|syncDisconnected|incompatibleVersion/' },
|
||||||
"warning-sync-status:s" => { name => 'warning_sync_status', default => '' },
|
'warning-failover-status:s' => { name => 'warning_failover_status', default => '' },
|
||||||
"critical-sync-status:s" => { name => 'critical_sync_status', default => '%{syncstatus} =~ /unknown|syncFailed|syncDisconnected|incompatibleVersion/' },
|
'critical-failover-status:s' => { name => 'critical_failover_status', default => '%{failoverstatus} =~ /unknown/' },
|
||||||
"warning-failover-status:s" => { name => 'warning_failover_status', default => '' },
|
});
|
||||||
"critical-failover-status:s" => { name => 'critical_failover_status', default => '%{failoverstatus} =~ /unknown/' },
|
|
||||||
});
|
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
@ -139,29 +137,37 @@ my $mapping = {
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $result = $options{snmp}->get_leef(oids => [$mapping->{sysAttrFailoverIsRedundant}->{oid} . '.0',
|
my $snmp_result = $options{snmp}->get_leef(
|
||||||
$mapping->{sysAttrModeMaint}->{oid} . '.0',
|
oids => [
|
||||||
$mapping->{sysCmSyncStatusId}->{oid} . '.0',
|
$mapping->{sysAttrFailoverIsRedundant}->{oid} . '.0',
|
||||||
$mapping->{sysCmFailoverStatusId}->{oid} . '.0'],
|
$mapping->{sysAttrModeMaint}->{oid} . '.0',
|
||||||
nothing_quit => 1);
|
$mapping->{sysCmSyncStatusId}->{oid} . '.0',
|
||||||
my $result2 = $options{snmp}->map_instance(mapping => $mapping, results => $result, instance => '0');
|
$mapping->{sysCmFailoverStatusId}->{oid} . '.0'
|
||||||
|
],
|
||||||
|
nothing_quit => 1
|
||||||
|
);
|
||||||
|
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => '0');
|
||||||
|
|
||||||
if ($result2->{sysAttrModeMaint} eq 'true') {
|
if ($result->{sysAttrModeMaint} eq 'true') {
|
||||||
$self->{output}->output_add(severity => 'OK',
|
$self->{output}->output_add(
|
||||||
short_msg => 'maintenance mode is active');
|
severity => 'OK',
|
||||||
|
short_msg => 'maintenance mode is active'
|
||||||
|
);
|
||||||
$self->{output}->display();
|
$self->{output}->display();
|
||||||
$self->{output}->exit();
|
$self->{output}->exit();
|
||||||
}
|
}
|
||||||
if ($result2->{sysAttrFailoverIsRedundant} eq 'false') {
|
if ($result->{sysAttrFailoverIsRedundant} eq 'false') {
|
||||||
$self->{output}->output_add(severity => 'OK',
|
$self->{output}->output_add(
|
||||||
short_msg => 'failover mode is disable');
|
severity => 'OK',
|
||||||
|
short_msg => 'failover mode is disable'
|
||||||
|
);
|
||||||
$self->{output}->display();
|
$self->{output}->display();
|
||||||
$self->{output}->exit();
|
$self->{output}->exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{global} = {
|
$self->{global} = {
|
||||||
syncstatus => $result2->{sysCmSyncStatusId},
|
syncstatus => $result->{sysCmSyncStatusId},
|
||||||
failoverstatus => $result2->{sysCmFailoverStatusId},
|
failoverstatus => $result->{sysCmFailoverStatusId},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,6 @@ use base qw(centreon::plugins::mode);
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
my $oid_ltmNodeAddrName = '.1.3.6.1.4.1.3375.2.2.4.1.2.1.17'; # old
|
|
||||||
my $oid_ltmNodeAddrStatusName = '.1.3.6.1.4.1.3375.2.2.4.3.2.1.7'; # new
|
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
@ -48,36 +45,66 @@ sub check_options {
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $snmp_result = $self->{snmp}->get_multiple_table(oids => [ { oid => $oid_ltmNodeAddrName }, { oid => $oid_ltmNodeAddrStatusName } ], nothing_quit => 1);
|
my $map_pool_status = {
|
||||||
|
0 => 'none', 1 => 'green',
|
||||||
|
2 => 'yellow', 3 => 'red',
|
||||||
|
4 => 'blue', 5 => 'gray',
|
||||||
|
};
|
||||||
|
my $map_pool_enabled = {
|
||||||
|
0 => 'none', 1 => 'enabled', 2 => 'disabled', 3 => 'disabledbyparent',
|
||||||
|
};
|
||||||
|
my $mapping = {
|
||||||
|
AvailState => { oid => '.1.3.6.1.4.1.3375.2.2.4.3.2.1.3', map => $map_pool_status },
|
||||||
|
EnabledState => { oid => '.1.3.6.1.4.1.3375.2.2.4.3.2.1.4', map => $map_pool_enabled },
|
||||||
|
};
|
||||||
|
my $oid_ltmNodeAddrStatusEntry = '.1.3.6.1.4.1.3375.2.2.4.3.2.1';
|
||||||
|
|
||||||
my ($branch_name) = ($oid_ltmNodeAddrStatusName);
|
my $snmp_result = $options{snmp}->get_table(
|
||||||
if (!defined($snmp_result->{$oid_ltmNodeAddrStatusName}) || scalar(keys %{$snmp_result->{$oid_ltmNodeAddrStatusName}}) == 0) {
|
oid => $oid_ltmNodeAddrStatusEntry,
|
||||||
($branch_name) = ($oid_ltmNodeAddrName);
|
start => $mapping->{AvailState}->{oid},
|
||||||
}
|
end => $mapping->{EnabledState}->{oid},
|
||||||
|
nothing_quit => 1
|
||||||
|
);
|
||||||
|
my $results = {};
|
||||||
|
foreach my $oid (keys %$snmp_result) {
|
||||||
|
next if ($oid !~ /^$mapping->{AvailState}->{oid}\.(.*?)\.(.*)$/);
|
||||||
|
my ($num, $index) = ($1, $2);
|
||||||
|
|
||||||
|
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $num . '.' . $index);
|
||||||
|
my $name = $self->{output}->to_utf8(join('', map(chr($_), split(/\./, $index))));
|
||||||
|
|
||||||
$self->{node} = {};
|
|
||||||
foreach my $oid (keys %{$snmp_result->{$branch_name}}) {
|
|
||||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||||
$snmp_result->{$branch_name}->{$oid} !~ /$self->{option_results}->{filter_name}/) {
|
$name !~ /$self->{option_results}->{filter_name}/) {
|
||||||
$self->{output}->output_add(long_msg => "skipping service class '" . $snmp_result->{$branch_name}->{$oid} . "'.", debug => 1);
|
$self->{output}->output_add(long_msg => "skipping node '" . $name . "'.", debug => 1);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{node}->{$snmp_result->{$branch_name}->{$oid}} = { name => $snmp_result->{$branch_name}->{$oid} };
|
$results->{$name} = {
|
||||||
|
status => $result->{AvailState},
|
||||||
|
state => $result->{EnabledState},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run {
|
sub run {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->{snmp} = $options{snmp};
|
|
||||||
|
|
||||||
$self->manage_selection();
|
my $results = $self->manage_selection(snmp => $options{snmp});
|
||||||
foreach my $name (sort keys %{$self->{node}}) {
|
foreach my $name (sort keys %$results) {
|
||||||
$self->{output}->output_add(long_msg => "'" . $name . "'");
|
$self->{output}->output_add(
|
||||||
|
long_msg => sprintf(
|
||||||
|
'[name: %s] [status: %s] [state: %s]',
|
||||||
|
$name,
|
||||||
|
$results->{$name}->{status},
|
||||||
|
$results->{$name}->{state},
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{output}->output_add(severity => 'OK',
|
$self->{output}->output_add(severity => 'OK',
|
||||||
short_msg => 'List Nodes:');
|
short_msg => 'List nodes:');
|
||||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||||
$self->{output}->exit();
|
$self->{output}->exit();
|
||||||
}
|
}
|
||||||
|
@ -85,16 +112,19 @@ sub run {
|
||||||
sub disco_format {
|
sub disco_format {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{output}->add_disco_format(elements => ['name']);
|
$self->{output}->add_disco_format(elements => ['name', 'status', 'state']);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub disco_show {
|
sub disco_show {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->{snmp} = $options{snmp};
|
|
||||||
|
|
||||||
$self->manage_selection();
|
my $results = $self->manage_selection(snmp => $options{snmp});
|
||||||
foreach my $name (sort keys %{$self->{node}}) {
|
foreach my $name (sort keys %$results) {
|
||||||
$self->{output}->add_disco_entry(name => $name);
|
$self->{output}->add_disco_entry(
|
||||||
|
name => $name,
|
||||||
|
status => $results->{$name}->{status},
|
||||||
|
state => $results->{$name}->{state}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,6 @@ sub manage_selection {
|
||||||
}
|
}
|
||||||
|
|
||||||
$results->{$name} = {
|
$results->{$name} = {
|
||||||
display => $name,
|
|
||||||
status => $result->{AvailState},
|
status => $result->{AvailState},
|
||||||
state => $result->{EnabledState},
|
state => $result->{EnabledState},
|
||||||
};
|
};
|
||||||
|
@ -108,7 +107,7 @@ sub run {
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{output}->output_add(severity => 'OK',
|
$self->{output}->output_add(severity => 'OK',
|
||||||
short_msg => 'List Pools:');
|
short_msg => 'List pools:');
|
||||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||||
$self->{output}->exit();
|
$self->{output}->exit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,7 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
'name:s' => { name => 'name' },
|
'filter-name:s' => { name => 'filter_name' },
|
||||||
'regexp' => { name => 'use_regexp' },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
|
@ -86,36 +85,45 @@ sub manage_selection {
|
||||||
($branch, $map) = ($oid_ltmVirtualServEntry, 'old');
|
($branch, $map) = ($oid_ltmVirtualServEntry, 'old');
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{vs} = {};
|
my $results = {};
|
||||||
foreach my $oid (keys %{$snmp_result->{$branch}}) {
|
foreach my $oid (keys %{$snmp_result->{$branch}}) {
|
||||||
next if ($oid !~ /^$mapping->{$map}->{AvailState}->{oid}\.(.*?)\.(.*)$/);
|
next if ($oid !~ /^$mapping->{$map}->{AvailState}->{oid}\.(.*?)\.(.*)$/);
|
||||||
my ($num, $index) = ($1, $2);
|
my ($num, $index) = ($1, $2);
|
||||||
my $result = $options{snmp}->map_instance(mapping => $mapping->{$map}, results => $snmp_result->{$branch}, instance => $num . '.' . $index);
|
my $result = $options{snmp}->map_instance(mapping => $mapping->{$map}, results => $snmp_result->{$branch}, instance => $num . '.' . $index);
|
||||||
|
|
||||||
$result->{Name} = $self->{output}->to_utf8(join('', map(chr($_), split(/\./, $index))));
|
my $name = $self->{output}->to_utf8(join('', map(chr($_), split(/\./, $index))));
|
||||||
if (defined($self->{option_results}->{name}) && $self->{option_results}->{name} ne '') {
|
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||||
next if (defined($self->{option_results}->{use_regexp}) && $result->{Name} !~ /$self->{option_results}->{name}/);
|
$name !~ /$self->{option_results}->{filter_name}/) {
|
||||||
next if ($result->{Name} ne $self->{option_results}->{name});
|
$self->{output}->output_add(long_msg => "skipping virtual server '" . $name . "'.", debug => 1);
|
||||||
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{vs}->{$result->{Name}} = { %$result };
|
$results->{$name} = {
|
||||||
|
status => $result->{AvailState},
|
||||||
|
state => $result->{EnabledState},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run {
|
sub run {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->manage_selection(%options);
|
my $results = $self->manage_selection(snmp => $options{snmp});
|
||||||
foreach (sort keys %{$self->{vs}}) {
|
foreach my $name (sort keys %$results) {
|
||||||
$self->{output}->output_add(long_msg =>
|
$self->{output}->output_add(
|
||||||
"[name = '" . $self->{vs}->{$_}->{Name} . "']" .
|
long_msg => sprintf(
|
||||||
"[availstate = '" . $self->{vs}->{$_}->{AvailState} . "']" .
|
'[name: %s] [status: %s] [state: %s]',
|
||||||
"[enabledtate = '" . $self->{vs}->{$_}->{EnabledState} . "']"
|
$name,
|
||||||
|
$results->{$name}->{status},
|
||||||
|
$results->{$name}->{state},
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{output}->output_add(severity => 'OK',
|
$self->{output}->output_add(severity => 'OK',
|
||||||
short_msg => 'List Virtual Servers:');
|
short_msg => 'List virtual servers:');
|
||||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||||
$self->{output}->exit();
|
$self->{output}->exit();
|
||||||
}
|
}
|
||||||
|
@ -123,18 +131,18 @@ sub run {
|
||||||
sub disco_format {
|
sub disco_format {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{output}->add_disco_format(elements => ['name', 'availstate', 'enabledtate']);
|
$self->{output}->add_disco_format(elements => ['name', 'status', 'state']);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub disco_show {
|
sub disco_show {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->manage_selection(%options);
|
my $results = $self->manage_selection(snmp => $options{snmp});
|
||||||
foreach (sort keys %{$self->{vs}}) {
|
foreach my $name (sort keys %$results) {
|
||||||
$self->{output}->add_disco_entry(
|
$self->{output}->add_disco_entry(
|
||||||
name => $self->{vs}->{$_}->{Name},
|
name => $name,
|
||||||
availstate => $self->{vs}->{$_}->{AvailState},
|
status => $results->{$name}->{status},
|
||||||
enabledtate => $self->{vs}->{$_}->{EnabledState},
|
state => $results->{$name}->{state}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,13 +157,9 @@ List F-5 Virtual Servers.
|
||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
=item B<--name>
|
=item B<--filter-name>
|
||||||
|
|
||||||
Set the virtual server name.
|
Filter by virtual server name.
|
||||||
|
|
||||||
=item B<--regexp>
|
|
||||||
|
|
||||||
Allows to use regexp to filter virtual server name (with option --name).
|
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
|
|
@ -157,10 +157,9 @@ sub new {
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
'filter-name:s' => { name => 'filter_name' },
|
||||||
"filter-name:s" => { name => 'filter_name' },
|
});
|
||||||
});
|
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
@ -186,8 +185,10 @@ sub manage_selection {
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
my $results = $options{snmp}->get_table(oid => $oid_sysTmmStatEntry,
|
my $results = $options{snmp}->get_table(
|
||||||
nothing_quit => 1);
|
oid => $oid_sysTmmStatEntry,
|
||||||
|
nothing_quit => 1
|
||||||
|
);
|
||||||
|
|
||||||
$self->{tmm} = {};
|
$self->{tmm} = {};
|
||||||
foreach my $oid (keys %$results) {
|
foreach my $oid (keys %$results) {
|
||||||
|
|
|
@ -301,10 +301,10 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
"filter-name:s" => { name => 'filter_name' },
|
'filter-name:s' => { name => 'filter_name' },
|
||||||
"threshold-overload:s@" => { name => 'threshold_overload' },
|
'threshold-overload:s@' => { name => 'threshold_overload' },
|
||||||
"units-traffic:s" => { name => 'units_traffic', default => '%' },
|
'units-traffic:s' => { name => 'units_traffic', default => '%' },
|
||||||
"speed:s" => { name => 'speed' },
|
'speed:s' => { name => 'speed' },
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
|
@ -388,10 +388,13 @@ sub manage_selection {
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
my $results = $options{snmp}->get_multiple_table(oids => [
|
my $results = $options{snmp}->get_multiple_table(
|
||||||
{ oid => $oid_sysTrunkTable },
|
oids => [
|
||||||
{ oid => $oid_sysTrunkStatTable },
|
{ oid => $oid_sysTrunkTable },
|
||||||
], nothing_quit => 1);
|
{ oid => $oid_sysTrunkStatTable },
|
||||||
|
],
|
||||||
|
nothing_quit => 1
|
||||||
|
);
|
||||||
|
|
||||||
$self->{trunks} = {};
|
$self->{trunks} = {};
|
||||||
foreach my $oid (keys %{$results->{$oid_sysTrunkTable}}) {
|
foreach my $oid (keys %{$results->{$oid_sysTrunkTable}}) {
|
||||||
|
|
Loading…
Reference in New Issue