re-calculating virtual memory for windows machines (#929)
This commit is contained in:
parent
4d4531cde6
commit
c6ce3ba253
|
@ -70,9 +70,16 @@ sub run {
|
|||
if ($result->{$key} =~ /^Virtual memory$/i) {
|
||||
$self->{swap_memory_id} = $oid;
|
||||
}
|
||||
if ($result->{$key} =~ /^Physical memory$/i) {
|
||||
$self->{physical_memory_id} = $oid;
|
||||
}
|
||||
}
|
||||
|
||||
if (!defined($self->{swap_memory_id})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Cannot find virtual memory informations.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (!defined($self->{physical_memory_id})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Cannot find physical memory informations.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
@ -81,12 +88,18 @@ 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';
|
||||
|
||||
$self->{snmp}->load(oids => [$oid_hrStorageAllocationUnits, $oid_hrStorageSize, $oid_hrStorageUsed],
|
||||
instances => [$self->{physical_memory_id}]);
|
||||
$result = $self->{snmp}->get_leef();
|
||||
my $physicalSize = $result->{$oid_hrStorageSize . "." . $self->{physical_memory_id}};
|
||||
my $physicalUsed = $result->{$oid_hrStorageUsed . "." . $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}} * $result->{$oid_hrStorageAllocationUnits . "." . $self->{swap_memory_id}};
|
||||
my $total_size = $result->{$oid_hrStorageSize . "." . $self->{swap_memory_id}} * $result->{$oid_hrStorageAllocationUnits . "." . $self->{swap_memory_id}};
|
||||
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 $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' } ]);
|
||||
|
|
Loading…
Reference in New Issue