mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-27 07:34:35 +02:00
(plugin) hardware::ups::socomec::netvision - netvision v5 supported (#3914)
This commit is contained in:
parent
e4c7f13446
commit
b261b6fad4
@ -49,8 +49,7 @@ sub new {
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
});
|
||||
$options{options}->add_options(arguments => {});
|
||||
|
||||
return $self;
|
||||
}
|
||||
@ -58,10 +57,19 @@ sub new {
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $oid_upsAlarmsPresent = '.1.3.6.1.4.1.4555.1.1.7.1.6.1.0';
|
||||
my $snmp_result = $options{snmp}->get_leef(oids => [ $oid_upsAlarmsPresent ], nothing_quit => 1);
|
||||
my $oid_upsAlarmsPresent_netvisionv6 = '.1.3.6.1.4.1.4555.1.1.7.1.6.1.0';
|
||||
my $oid_upsAlarmsPresent_netvisionv5 = '.1.3.6.1.4.1.4555.1.1.1.1.6.1.0';
|
||||
my $snmp_result = $options{snmp}->get_leef(
|
||||
oids => [
|
||||
$oid_upsAlarmsPresent_netvisionv6,
|
||||
$oid_upsAlarmsPresent_netvisionv5
|
||||
],
|
||||
nothing_quit => 1
|
||||
);
|
||||
|
||||
$self->{global} = { current_alarms => $snmp_result->{$oid_upsAlarmsPresent} };
|
||||
$self->{global} = {
|
||||
current_alarms => defined($snmp_result->{$oid_upsAlarmsPresent_netvisionv6}) ? $snmp_result->{$oid_upsAlarmsPresent_netvisionv6} : $snmp_result->{$oid_upsAlarmsPresent_netvisionv5}
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -72,7 +72,7 @@ sub set_counters {
|
||||
}
|
||||
},
|
||||
{ label => 'charge-remaining-minutes', nlabel => 'battery.charge.remaining.minutes', display_ok => 0, set => {
|
||||
key_values => [ { name => 'minute_remain' } ],
|
||||
key_values => [ { name => 'minute_remain', no_value => 'unknown' } ],
|
||||
output_template => 'minutes remaining: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
@ -117,35 +117,57 @@ sub new {
|
||||
return $self;
|
||||
}
|
||||
|
||||
my $map_status = {
|
||||
my $map_status_v6 = {
|
||||
1 => 'unknown', 2 => 'normal', 3 => 'charging', 4 => 'test',
|
||||
5 => 'discharging', 6 => 'low', 7 => 'depleted', 8 => 'failure',
|
||||
9 => 'disconnected'
|
||||
};
|
||||
my $map_status_v5 = {
|
||||
1 => 'unknown', 2 => 'normal', 3 => 'low',
|
||||
4 => 'depleted', 5 => 'discharging',
|
||||
6 => 'failure', 7 => 'upsOff'
|
||||
};
|
||||
|
||||
my $mapping = {
|
||||
status => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.2.1', map => $map_status }, # upsBatteryStatus
|
||||
minute_remain => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.2.3' }, # upsEstimatedMinutesRemaining
|
||||
charge_remain => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.2.4' }, # upsEstimatedChargeRemaining
|
||||
voltage => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.2.5' }, # upsBatteryVoltage (dV)
|
||||
temperature => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.2.6' }, # upsBatteryTemperature (degrees Centigrade)
|
||||
current => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.2.8' } # upsBatteryCurrent (dA)
|
||||
netvision5 => {
|
||||
status => { oid => '.1.3.6.1.4.1.4555.1.1.1.1.2.1', map => $map_status_v5 }, # upsBatteryStatus
|
||||
minute_remain => { oid => '.1.3.6.1.4.1.4555.1.1.1.1.2.3' }, # upsEstimatedMinutesRemaining
|
||||
charge_remain => { oid => '.1.3.6.1.4.1.4555.1.1.1.1.2.4' }, # upsEstimatedChargeRemaining
|
||||
voltage => { oid => '.1.3.6.1.4.1.4555.1.1.1.1.2.5' }, # upsBatteryVoltage (dV)
|
||||
temperature => { oid => '.1.3.6.1.4.1.4555.1.1.1.1.2.6' } # upsBatteryTemperature (degrees Centigrade)
|
||||
},
|
||||
netvision6 => {
|
||||
status => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.2.1', map => $map_status_v6 }, # upsBatteryStatus
|
||||
minute_remain => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.2.3' }, # upsEstimatedMinutesRemaining
|
||||
charge_remain => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.2.4' }, # upsEstimatedChargeRemaining
|
||||
voltage => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.2.5' }, # upsBatteryVoltage (dV)
|
||||
temperature => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.2.6' }, # upsBatteryTemperature (degrees Centigrade)
|
||||
current => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.2.8' } # upsBatteryCurrent (dA)
|
||||
}
|
||||
};
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $label = 'netvision6';
|
||||
my $snmp_result = $options{snmp}->get_leef(
|
||||
oids => [ map($_->{oid} . '.0', values(%$mapping)) ],
|
||||
nothing_quit => 1
|
||||
oids => [ map($_->{oid} . '.0', values(%{$mapping->{$label}})) ]
|
||||
);
|
||||
$self->{global} = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => 0);
|
||||
if (!defined($snmp_result->{ $mapping->{netvision6}->{status} . '.0' })) {
|
||||
$label = 'netvision5';
|
||||
$snmp_result = $options{snmp}->get_leef(
|
||||
oids => [ map($_->{oid} . '.0', values(%{$mapping->{$label}})) ],
|
||||
nothing_quit => 1
|
||||
);
|
||||
}
|
||||
|
||||
$self->{global} = $options{snmp}->map_instance(mapping => $mapping->{$label}, results => $snmp_result, instance => 0);
|
||||
$self->{global}->{current} = (defined($self->{global}->{current}) && $self->{global}->{current} =~ /\d/ && $self->{global}->{current} != -1 && $self->{global}->{current} != 65535) ?
|
||||
$self->{global}->{current} * 0.1 : 0;
|
||||
$self->{global}->{voltage} = (defined($self->{global}->{voltage}) && $self->{global}->{voltage} =~ /\d/ && $self->{global}->{voltage} != -1 && $self->{global}->{voltage} != 65535) ?
|
||||
$self->{global}->{voltage} * 0.1 : 0;
|
||||
$self->{global}->{temperature} = (defined($self->{global}->{temperature}) && $self->{global}->{temperature} =~ /\d/) ? $self->{global}->{temperature} * 0.1 : 0;
|
||||
$self->{global}->{minute_remain} = (defined($self->{global}->{minute_remain}) && $self->{global}->{minute_remain} =~ /\d/) ? $self->{global}->{minute_remain} : 'unknown';
|
||||
$self->{global}->{minute_remain} = (defined($self->{global}->{minute_remain}) && $self->{global}->{minute_remain} =~ /\d/ && $self->{global}->{minute_remain} != -1) ? $self->{global}->{minute_remain} : 'unknown';
|
||||
$self->{global}->{charge_remain} = (defined($self->{global}->{charge_remain}) && $self->{global}->{charge_remain} =~ /\d/) ? $self->{global}->{charge_remain} : undef;
|
||||
}
|
||||
|
||||
|
@ -82,34 +82,61 @@ sub new {
|
||||
}
|
||||
|
||||
my $mapping = {
|
||||
voltage => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.3.3.1.2' }, # upsInputVoltage (dV)
|
||||
current => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.3.3.1.3' } # upsInputCurrent (dA)
|
||||
netvision5 => {
|
||||
voltage => { oid => '.1.3.6.1.4.1.4555.1.1.1.1.3.3.1.2' }, # upsInputVoltage (dV)
|
||||
current => { oid => '.1.3.6.1.4.1.4555.1.1.1.1.3.3.1.3' } # upsInputCurrent (dA)
|
||||
},
|
||||
netvision6 => {
|
||||
voltage => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.3.3.1.2' }, # upsInputVoltage (dV)
|
||||
current => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.3.3.1.3' } # upsInputCurrent (dA)
|
||||
}
|
||||
};
|
||||
my $mapping2 = {
|
||||
frequency => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.3.2' } # upsInputFrequency (dHZ)
|
||||
netvision5 => {
|
||||
frequency => { oid => '.1.3.6.1.4.1.4555.1.1.1.1.3.2' } # upsInputFrequency (dHZ)
|
||||
},
|
||||
netvision6 => {
|
||||
frequency => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.3.2' } # upsInputFrequency (dHZ)
|
||||
}
|
||||
};
|
||||
my $tables = {
|
||||
netvision5 => {
|
||||
upsInput => '.1.3.6.1.4.1.4555.1.1.1.1.3',
|
||||
upsInputEntry => '.1.3.6.1.4.1.4555.1.1.1.1.3.3.1'
|
||||
},
|
||||
netvision6 => {
|
||||
upsInput => '.1.3.6.1.4.1.4555.1.1.7.1.3',
|
||||
upsInputEntry => '.1.3.6.1.4.1.4555.1.1.7.1.3.3.1'
|
||||
}
|
||||
};
|
||||
|
||||
my $oid_upsInput = '.1.3.6.1.4.1.4555.1.1.7.1.3';
|
||||
my $oid_upsInputEntry = '.1.3.6.1.4.1.4555.1.1.7.1.3.3.1';
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $label = 'netvision6';
|
||||
my $snmp_result = $options{snmp}->get_table(
|
||||
oid => $oid_upsInput,
|
||||
start => $mapping2->{frequency}->{oid},
|
||||
end => $mapping->{current}->{oid},
|
||||
nothing_quit => 1
|
||||
oid => $tables->{$label}->{upsInput},
|
||||
start => $mapping2->{$label}->{frequency}->{oid},
|
||||
end => $mapping->{$label}->{current}->{oid}
|
||||
);
|
||||
if (scalar(keys %$snmp_result) <= 0) {
|
||||
$label = 'netvision5';
|
||||
$snmp_result = $options{snmp}->get_table(
|
||||
oid => $tables->{$label}->{upsInput},
|
||||
start => $mapping2->{$label}->{frequency}->{oid},
|
||||
end => $mapping->{$label}->{current}->{oid},
|
||||
nothing_quit => 1
|
||||
);
|
||||
}
|
||||
|
||||
$self->{iline} = {};
|
||||
foreach my $oid (keys %$snmp_result) {
|
||||
next if ($oid !~ /^$oid_upsInputEntry\.\d+\.(.*)$/);
|
||||
next if ($oid !~ /^$tables->{$label}->{upsInputEntry}\.\d+\.(.*)$/);
|
||||
my $instance = $1;
|
||||
next if (defined($self->{iline}->{$instance}));
|
||||
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||
foreach (('current', 'voltage')) {
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping->{$label}, results => $snmp_result, instance => $instance);
|
||||
foreach ('current', 'voltage') {
|
||||
$result->{$_} = 0 if (defined($result->{$_}) && (
|
||||
$result->{$_} eq '' || $result->{$_} == -1 || $result->{$_} == 65535 || $result->{$_} == 655350));
|
||||
$result->{$_} *= 0.1;
|
||||
@ -126,7 +153,7 @@ sub manage_selection {
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
$self->{global} = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result, instance => 0);
|
||||
$self->{global} = $options{snmp}->map_instance(mapping => $mapping2->{$label}, results => $snmp_result, instance => 0);
|
||||
$self->{global}->{frequency} = defined($self->{global}->{frequency}) && $self->{global}->{frequency} != -1 && $self->{global}->{frequency} != 65535
|
||||
? ($self->{global}->{frequency} * 0.1) : 0;
|
||||
}
|
||||
|
@ -107,32 +107,60 @@ my $map_status = {
|
||||
};
|
||||
|
||||
my $mapping = {
|
||||
voltage => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.4.4.1.2' }, # upsOutputVoltage (Volt)
|
||||
current => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.4.4.1.3' }, # upsOutputCurrent (dA)
|
||||
percent_load => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.4.4.1.4' } # upsOutputPercentLoad
|
||||
netvision5 => {
|
||||
voltage => { oid => '.1.3.6.1.4.1.4555.1.1.1.1.4.4.1.2' }, # upsOutputVoltage (Volt)
|
||||
current => { oid => '.1.3.6.1.4.1.4555.1.1.1.1.4.4.1.3' }, # upsOutputCurrent (dA)
|
||||
percent_load => { oid => '.1.3.6.1.4.1.4555.1.1.1.1.4.4.1.4' } # upsOutputPercentLoad
|
||||
},
|
||||
netvision6 => {
|
||||
voltage => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.4.4.1.2' }, # upsOutputVoltage (Volt)
|
||||
current => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.4.4.1.3' }, # upsOutputCurrent (dA)
|
||||
percent_load => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.4.4.1.4' } # upsOutputPercentLoad
|
||||
}
|
||||
};
|
||||
my $mapping2 = {
|
||||
status => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.4.1', map => $map_status } # upsOutputSource
|
||||
netvision5 => {
|
||||
status => { oid => '.1.3.6.1.4.1.4555.1.1.1.1.4.1', map => $map_status } # upsOutputSource
|
||||
},
|
||||
netvision6 => {
|
||||
status => { oid => '.1.3.6.1.4.1.4555.1.1.7.1.4.1', map => $map_status } # upsOutputSource
|
||||
}
|
||||
};
|
||||
my $tables = {
|
||||
netvision5 => {
|
||||
upsOutput => '.1.3.6.1.4.1.4555.1.1.1.1.4',
|
||||
upsOutputEntry => '.1.3.6.1.4.1.4555.1.1.1.1.4.4.1'
|
||||
},
|
||||
netvision6 => {
|
||||
upsOutput => '.1.3.6.1.4.1.4555.1.1.7.1.4',
|
||||
upsOutputEntry => '.1.3.6.1.4.1.4555.1.1.7.1.4.4.1'
|
||||
}
|
||||
};
|
||||
my $oid_upsOutput = '.1.3.6.1.4.1.4555.1.1.7.1.4';
|
||||
my $oid_upsOutputEntry = '.1.3.6.1.4.1.4555.1.1.7.1.4.4.1';
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $label = 'netvision6';
|
||||
my $snmp_result = $options{snmp}->get_table(
|
||||
oid => $oid_upsOutput,
|
||||
end => $mapping->{percent_load}->{oid},
|
||||
nothing_quit => 1
|
||||
oid => $tables->{$label}->{upsOutput},
|
||||
end => $mapping->{$label}->{percent_load}->{oid}
|
||||
);
|
||||
if (scalar(keys %$snmp_result) <= 0) {
|
||||
$label = 'netvision5';
|
||||
$snmp_result = $options{snmp}->get_table(
|
||||
oid => $tables->{$label}->{upsOutput},
|
||||
end => $mapping->{$label}->{percent_load}->{oid},
|
||||
nothing_quit => 1
|
||||
);
|
||||
}
|
||||
|
||||
$self->{oline} = {};
|
||||
foreach my $oid (keys %$snmp_result) {
|
||||
next if ($oid !~ /^$oid_upsOutputEntry\.\d+\.(.*)$/);
|
||||
next if ($oid !~ /^$tables->{$label}->{upsOutputEntry}\.\d+\.(.*)$/);
|
||||
my $instance = $1;
|
||||
next if (defined($self->{oline}->{$instance}));
|
||||
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping->{$label}, results => $snmp_result, instance => $instance);
|
||||
foreach (keys %$result) {
|
||||
delete $result->{$_} if (
|
||||
(defined($self->{option_results}->{ignore_zero_counters}) && $result->{$_} == 0) ||
|
||||
@ -146,7 +174,7 @@ sub manage_selection {
|
||||
}
|
||||
}
|
||||
|
||||
$self->{global} = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result, instance => 0);
|
||||
$self->{global} = $options{snmp}->map_instance(mapping => $mapping2->{$label}, results => $snmp_result, instance => 0);
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -29,7 +29,6 @@ sub new {
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '0.1';
|
||||
$self->{modes} = {
|
||||
'alarms' => 'hardware::ups::socomec::netvision::snmp::mode::alarms',
|
||||
'battery' => 'hardware::ups::socomec::netvision::snmp::mode::battery',
|
||||
|
Loading…
x
Reference in New Issue
Block a user