Fix #1475
This commit is contained in:
parent
c17adfe9cd
commit
b00491024d
|
@ -114,11 +114,10 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
'filter-name:s' => { name => 'filter_name' },
|
||||||
"filter-name:s" => { name => 'filter_name' },
|
'warning-status:s' => { name => 'warning_status', default => '' },
|
||||||
"warning-status:s" => { name => 'warning_status', default => '' },
|
'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /UP/i' },
|
||||||
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /UP/i' },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
|
@ -138,13 +137,26 @@ sub prefix_backend_output {
|
||||||
}
|
}
|
||||||
|
|
||||||
my $mapping = {
|
my $mapping = {
|
||||||
alBackendName => { oid => '.1.3.6.1.4.1.23263.4.2.1.3.3.1.3' },
|
entreprise => {
|
||||||
alBackendQueueCur => { oid => '.1.3.6.1.4.1.23263.4.2.1.3.3.1.4' },
|
alBackendQueueCur => { oid => '.1.3.6.1.4.1.23263.4.2.1.3.3.1.4' },
|
||||||
alBackendSessionCur => { oid => '.1.3.6.1.4.1.23263.4.2.1.3.3.1.7' },
|
alBackendSessionCur => { oid => '.1.3.6.1.4.1.23263.4.2.1.3.3.1.7' },
|
||||||
alBackendSessionTotal => { oid => '.1.3.6.1.4.1.23263.4.2.1.3.3.1.10' },
|
alBackendSessionTotal => { oid => '.1.3.6.1.4.1.23263.4.2.1.3.3.1.10' },
|
||||||
alBackendBytesIN => { oid => '.1.3.6.1.4.1.23263.4.2.1.3.3.1.12' },
|
alBackendBytesIN => { oid => '.1.3.6.1.4.1.23263.4.2.1.3.3.1.12' },
|
||||||
alBackendBytesOUT => { oid => '.1.3.6.1.4.1.23263.4.2.1.3.3.1.13' },
|
alBackendBytesOUT => { oid => '.1.3.6.1.4.1.23263.4.2.1.3.3.1.13' },
|
||||||
alBackendStatus => { oid => '.1.3.6.1.4.1.23263.4.2.1.3.3.1.20' },
|
alBackendStatus => { oid => '.1.3.6.1.4.1.23263.4.2.1.3.3.1.20' },
|
||||||
|
},
|
||||||
|
csv => {
|
||||||
|
alBackendQueueCur => { oid => '.1.3.6.1.4.1.29385.106.1.1.2' },
|
||||||
|
alBackendSessionCur => { oid => '.1.3.6.1.4.1.29385.106.1.1.4' },
|
||||||
|
alBackendSessionTotal => { oid => '.1.3.6.1.4.1.29385.106.1.1.7' },
|
||||||
|
alBackendBytesIN => { oid => '.1.3.6.1.4.1.29385.106.1.1.8' },
|
||||||
|
alBackendBytesOUT => { oid => '.1.3.6.1.4.1.29385.106.1.1.9' },
|
||||||
|
alBackendStatus => { oid => '.1.3.6.1.4.1.29385.106.1.1.17' },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
my $mapping_name = {
|
||||||
|
csv => '.1.3.6.1.4.1.29385.106.1.1.0',
|
||||||
|
entreprise => '.1.3.6.1.4.1.23263.4.2.1.3.3.1.3', # alBackendName
|
||||||
};
|
};
|
||||||
|
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
|
@ -156,34 +168,25 @@ sub manage_selection {
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{backend} = {};
|
$self->{backend} = {};
|
||||||
my $snmp_result = $options{snmp}->get_multiple_table(
|
|
||||||
oids => [
|
|
||||||
{ oid => $mapping->{alBackendName}->{oid} },
|
|
||||||
{ oid => $mapping->{alBackendQueueCur}->{oid} },
|
|
||||||
{ oid => $mapping->{alBackendSessionCur}->{oid} },
|
|
||||||
{ oid => $mapping->{alBackendSessionTotal}->{oid} },
|
|
||||||
{ oid => $mapping->{alBackendBytesIN}->{oid} },
|
|
||||||
{ oid => $mapping->{alBackendBytesOUT}->{oid} },
|
|
||||||
{ oid => $mapping->{alBackendStatus}->{oid} },
|
|
||||||
],
|
|
||||||
return_type => 1, nothing_quit => 1);
|
|
||||||
|
|
||||||
foreach my $oid (keys %{$snmp_result}) {
|
my $snmp_result = $options{snmp}->get_multiple_table(oids => [ { oid => $mapping_name->{csv} }, { oid => $mapping_name->{entreprise} } ], nothing_quit => 1);
|
||||||
next if ($oid !~ /^$mapping->{alBackendName}->{oid}\.(.*)$/);
|
my $branch = 'entreprise';
|
||||||
|
if (defined($snmp_result->{ $mapping_name->{csv} }) && scalar(%{$snmp_result->{ $mapping_name->{csv} }}) > 0) {
|
||||||
|
$branch = 'csv';
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach my $oid (keys %{$snmp_result->{ $mapping_name->{$branch} }}) {
|
||||||
|
$oid =~ /^$mapping_name->{$branch}\.(.*)$/;
|
||||||
my $instance = $1;
|
my $instance = $1;
|
||||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
my $name = $snmp_result->{$mapping_name->{$branch}}->{$oid};
|
||||||
|
|
||||||
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 '' &&
|
||||||
$result->{alBackendName} !~ /$self->{option_results}->{filter_name}/) {
|
$name !~ /$self->{option_results}->{filter_name}/) {
|
||||||
$self->{output}->output_add(long_msg => "skipping '" . $result->{wgPolicyName} . "': no matching filter.", debug => 1);
|
$self->{output}->output_add(long_msg => "skipping backend '" . $name . "'.", debug => 1);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result->{alBackendBytesIN} *= 8;
|
$self->{backend}->{$instance} = { display => $name };
|
||||||
$result->{alBackendBytesOUT} *= 8;
|
|
||||||
$self->{backend}->{$instance} = { display => $result->{alBackendName},
|
|
||||||
%$result
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scalar(keys %{$self->{backend}}) <= 0) {
|
if (scalar(keys %{$self->{backend}}) <= 0) {
|
||||||
|
@ -191,6 +194,24 @@ sub manage_selection {
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$options{snmp}->load(
|
||||||
|
oids => [
|
||||||
|
map($_->{oid}, values(%{$mapping->{$branch}}))
|
||||||
|
],
|
||||||
|
instances => [keys %{$self->{backend}}],
|
||||||
|
instance_regexp => '^(.*)$'
|
||||||
|
);
|
||||||
|
$snmp_result = $options{snmp}->get_leef(nothing_quit => 1);
|
||||||
|
|
||||||
|
foreach (keys %{$self->{backend}}) {
|
||||||
|
my $result = $options{snmp}->map_instance(mapping => $mapping->{$branch}, results => $snmp_result, instance => $_);
|
||||||
|
|
||||||
|
$result->{alBackendBytesIN} *= 8;
|
||||||
|
$result->{alBackendBytesOUT} *= 8;
|
||||||
|
|
||||||
|
$self->{backend}->{$_} = { %{$self->{backend}->{$_}}, %$result };
|
||||||
|
}
|
||||||
|
|
||||||
$self->{cache_name} = "haproxy_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' .
|
$self->{cache_name} = "haproxy_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' .
|
||||||
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
|
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
|
||||||
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all'));
|
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all'));
|
||||||
|
|
|
@ -105,8 +105,7 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
|
||||||
"filter-name:s" => { name => 'filter_name' },
|
"filter-name:s" => { name => 'filter_name' },
|
||||||
"warning-status:s" => { name => 'warning_status', default => '' },
|
"warning-status:s" => { name => 'warning_status', default => '' },
|
||||||
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /OPEN/i' },
|
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /OPEN/i' },
|
||||||
|
@ -129,12 +128,24 @@ sub prefix_frontend_output {
|
||||||
}
|
}
|
||||||
|
|
||||||
my $mapping = {
|
my $mapping = {
|
||||||
alFrontendName => { oid => '.1.3.6.1.4.1.23263.4.2.1.3.2.1.3' },
|
entreprise => {
|
||||||
alFrontendSessionCur => { oid => '.1.3.6.1.4.1.23263.4.2.1.3.2.1.4' },
|
alFrontendSessionCur => { oid => '.1.3.6.1.4.1.23263.4.2.1.3.2.1.4' },
|
||||||
alFrontendSessionTotal => { oid => '.1.3.6.1.4.1.23263.4.2.1.3.2.1.7' },
|
alFrontendSessionTotal => { oid => '.1.3.6.1.4.1.23263.4.2.1.3.2.1.7' },
|
||||||
alFrontendBytesIN => { oid => '.1.3.6.1.4.1.23263.4.2.1.3.2.1.8' },
|
alFrontendBytesIN => { oid => '.1.3.6.1.4.1.23263.4.2.1.3.2.1.8' },
|
||||||
alFrontendBytesOUT => { oid => '.1.3.6.1.4.1.23263.4.2.1.3.2.1.9' },
|
alFrontendBytesOUT => { oid => '.1.3.6.1.4.1.23263.4.2.1.3.2.1.9' },
|
||||||
alFrontendStatus => { oid => '.1.3.6.1.4.1.23263.4.2.1.3.2.1.13' },
|
alFrontendStatus => { oid => '.1.3.6.1.4.1.23263.4.2.1.3.2.1.13' },
|
||||||
|
},
|
||||||
|
csv => {
|
||||||
|
alFrontendSessionCur => { oid => '.1.3.6.1.4.1.29385.106.1.0.4' },
|
||||||
|
alFrontendSessionTotal => { oid => '.1.3.6.1.4.1.29385.106.1.0.7' },
|
||||||
|
alFrontendBytesIN => { oid => '.1.3.6.1.4.1.29385.106.1.0.8' },
|
||||||
|
alFrontendBytesOUT => { oid => '.1.3.6.1.4.1.29385.106.1.0.9' },
|
||||||
|
alFrontendStatus => { oid => '.1.3.6.1.4.1.29385.106.1.0.17' },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
my $mapping_name = {
|
||||||
|
csv => '.1.3.6.1.4.1.29385.106.1.0.0',
|
||||||
|
entreprise => '.1.3.6.1.4.1.23263.4.2.1.3.2.1.3', # alFrontendName
|
||||||
};
|
};
|
||||||
|
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
|
@ -146,33 +157,25 @@ sub manage_selection {
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{frontend} = {};
|
$self->{frontend} = {};
|
||||||
my $snmp_result = $options{snmp}->get_multiple_table(
|
|
||||||
oids => [
|
|
||||||
{ oid => $mapping->{alFrontendName}->{oid} },
|
|
||||||
{ oid => $mapping->{alFrontendSessionCur}->{oid} },
|
|
||||||
{ oid => $mapping->{alFrontendSessionTotal}->{oid} },
|
|
||||||
{ oid => $mapping->{alFrontendBytesIN}->{oid} },
|
|
||||||
{ oid => $mapping->{alFrontendBytesOUT}->{oid} },
|
|
||||||
{ oid => $mapping->{alFrontendStatus}->{oid} },
|
|
||||||
],
|
|
||||||
return_type => 1, nothing_quit => 1);
|
|
||||||
|
|
||||||
foreach my $oid (keys %{$snmp_result}) {
|
my $snmp_result = $options{snmp}->get_multiple_table(oids => [ { oid => $mapping_name->{csv} }, { oid => $mapping_name->{entreprise} } ], nothing_quit => 1);
|
||||||
next if ($oid !~ /^$mapping->{alFrontendName}->{oid}\.(.*)$/);
|
my $branch = 'entreprise';
|
||||||
|
if (defined($snmp_result->{ $mapping_name->{csv} }) && scalar(%{$snmp_result->{ $mapping_name->{csv} }}) > 0) {
|
||||||
|
$branch = 'csv';
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach my $oid (keys %{$snmp_result->{ $mapping_name->{$branch} }}) {
|
||||||
|
$oid =~ /^$mapping_name->{$branch}\.(.*)$/;
|
||||||
my $instance = $1;
|
my $instance = $1;
|
||||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
my $name = $snmp_result->{$mapping_name->{$branch}}->{$oid};
|
||||||
|
|
||||||
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 '' &&
|
||||||
$result->{alFrontendName} !~ /$self->{option_results}->{filter_name}/) {
|
$name !~ /$self->{option_results}->{filter_name}/) {
|
||||||
$self->{output}->output_add(long_msg => "skipping '" . $result->{wgPolicyName} . "': no matching filter.", debug => 1);
|
$self->{output}->output_add(long_msg => "skipping frontend '" . $name . "'.", debug => 1);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result->{alFrontendBytesIN} *= 8;
|
$self->{frontend}->{$instance} = { display => $name };
|
||||||
$result->{alFrontendBytesOUT} *= 8;
|
|
||||||
$self->{frontend}->{$instance} = { display => $result->{alFrontendName},
|
|
||||||
%$result
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scalar(keys %{$self->{frontend}}) <= 0) {
|
if (scalar(keys %{$self->{frontend}}) <= 0) {
|
||||||
|
@ -180,6 +183,24 @@ sub manage_selection {
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$options{snmp}->load(
|
||||||
|
oids => [
|
||||||
|
map($_->{oid}, values(%{$mapping->{$branch}}))
|
||||||
|
],
|
||||||
|
instances => [keys %{$self->{frontend}}],
|
||||||
|
instance_regexp => '^(.*)$'
|
||||||
|
);
|
||||||
|
$snmp_result = $options{snmp}->get_leef(nothing_quit => 1);
|
||||||
|
|
||||||
|
foreach (keys %{$self->{frontend}}) {
|
||||||
|
my $result = $options{snmp}->map_instance(mapping => $mapping->{$branch}, results => $snmp_result, instance => $_);
|
||||||
|
|
||||||
|
$result->{alFrontendBytesIN} *= 8;
|
||||||
|
$result->{alFrontendBytesOUT} *= 8;
|
||||||
|
|
||||||
|
$self->{frontend}->{$_} = { %{$self->{frontend}->{$_}}, %$result };
|
||||||
|
}
|
||||||
|
|
||||||
$self->{cache_name} = "haproxy_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' .
|
$self->{cache_name} = "haproxy_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' .
|
||||||
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
|
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
|
||||||
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all'));
|
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all'));
|
||||||
|
|
Loading…
Reference in New Issue