enh windows snmp swap (#1069)

This commit is contained in:
Colin Gagnaire 2018-07-20 17:10:11 +02:00 committed by GitHub
parent c6ce3ba253
commit b36fe66f8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 6 deletions

View File

@ -35,9 +35,11 @@ sub new {
{ {
"warning:s" => { name => 'warning' }, "warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' }, "critical:s" => { name => 'critical' },
"real-swap" => { name => 'real_swap' },
}); });
$self->{swap_memory_id} = undef; $self->{swap_memory_id} = undef;
$self->{physical_memory_id} = undef;
return $self; return $self;
} }
@ -79,7 +81,7 @@ sub run {
$self->{output}->add_option_msg(short_msg => "Cannot find virtual memory informations."); $self->{output}->add_option_msg(short_msg => "Cannot find virtual memory informations.");
$self->{output}->option_exit(); $self->{output}->option_exit();
} }
if (!defined($self->{physical_memory_id})) { if (defined($self->{option_results}->{real_swap}) && !defined($self->{physical_memory_id})) {
$self->{output}->add_option_msg(short_msg => "Cannot find physical memory informations."); $self->{output}->add_option_msg(short_msg => "Cannot find physical memory informations.");
$self->{output}->option_exit(); $self->{output}->option_exit();
} }
@ -88,11 +90,15 @@ sub run {
my $oid_hrStorageSize = '.1.3.6.1.2.1.25.2.3.1.5'; 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 $oid_hrStorageUsed = '.1.3.6.1.2.1.25.2.3.1.6';
$self->{snmp}->load(oids => [$oid_hrStorageAllocationUnits, $oid_hrStorageSize, $oid_hrStorageUsed], my $physicalSize = 0;
instances => [$self->{physical_memory_id}]); my $physicalUsed = 0;
$result = $self->{snmp}->get_leef(); if (defined($self->{option_results}->{real_swap})) {
my $physicalSize = $result->{$oid_hrStorageSize . "." . $self->{physical_memory_id}}; $self->{snmp}->load(oids => [$oid_hrStorageAllocationUnits, $oid_hrStorageSize, $oid_hrStorageUsed],
my $physicalUsed = $result->{$oid_hrStorageUsed . "." . $self->{physical_memory_id}}; 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}};
}
$self->{snmp}->load(oids => [$oid_hrStorageAllocationUnits, $oid_hrStorageSize, $oid_hrStorageUsed], $self->{snmp}->load(oids => [$oid_hrStorageAllocationUnits, $oid_hrStorageSize, $oid_hrStorageUsed],
instances => [$self->{swap_memory_id}]); instances => [$self->{swap_memory_id}]);