+ Fix bug win real swap snmp

This commit is contained in:
garnier-quentin 2018-12-20 13:11:44 +01:00
parent 51c16b4419
commit 9e461fec00
1 changed files with 6 additions and 4 deletions

View File

@ -90,22 +90,24 @@ sub run {
my $oid_hrStorageSize = '.1.3.6.1.2.1.25.2.3.1.5';
my $oid_hrStorageUsed = '.1.3.6.1.2.1.25.2.3.1.6';
my $physicalSize = 0;
my $physicalUsed = 0;
my ($physicalSize, $physicalUsed, $physicalUnits) = (0, 0, 0);
if (defined($self->{option_results}->{real_swap})) {
$self->{snmp}->load(oids => [$oid_hrStorageAllocationUnits, $oid_hrStorageSize, $oid_hrStorageUsed],
instances => [$self->{physical_memory_id}]);
$result = $self->{snmp}->get_leef();
$physicalSize = $result->{$oid_hrStorageSize . "." . $self->{physical_memory_id}};
$physicalUsed = $result->{$oid_hrStorageUsed . "." . $self->{physical_memory_id}};
$physicalUnits = $result->{$oid_hrStorageAllocationUnits . "." . $self->{physical_memory_id}};
}
$self->{snmp}->load(oids => [$oid_hrStorageAllocationUnits, $oid_hrStorageSize, $oid_hrStorageUsed],
instances => [$self->{swap_memory_id}]);
$result = $self->{snmp}->get_leef();
my $swap_used = ($result->{$oid_hrStorageUsed . "." . $self->{swap_memory_id}} - $physicalUsed) * $result->{$oid_hrStorageAllocationUnits . "." . $self->{swap_memory_id}};
my $total_size = ($result->{$oid_hrStorageSize . "." . $self->{swap_memory_id}} - $physicalSize) * $result->{$oid_hrStorageAllocationUnits . "." . $self->{swap_memory_id}};
my $swap_used = ($result->{$oid_hrStorageUsed . "." . $self->{swap_memory_id}} * $result->{$oid_hrStorageAllocationUnits . "." . $self->{swap_memory_id}})
- ($physicalUsed * $physicalUnits);
my $total_size = ($result->{$oid_hrStorageSize . "." . $self->{swap_memory_id}} * $result->{$oid_hrStorageAllocationUnits . "." . $self->{swap_memory_id}})
- ($physicalSize * $physicalUnits);
my $prct_used = $swap_used * 100 / $total_size;
my $exit = $self->{perfdata}->threshold_check(value => $prct_used, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);