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