thanks Christian !

git-svn-id: http://svn.centreon.com/trunk/plugins-2.x@8400 6bcd3966-0018-0410-8128-fd23d134de7e
This commit is contained in:
Julien Mathis 2009-06-13 15:53:56 +00:00
parent 7e47745fab
commit ad1b8c4655
1 changed files with 18 additions and 3 deletions

View File

@ -159,6 +159,8 @@ my ($virt_alloc, my $virt_used, my $virt_size);
my $indexV = 0;
my $indexR = 0;
my $indexC = 0;
foreach my $key (oid_lex_sort(keys %$result)) {
if ($result->{$key} =~ m/Swap|Virtual/) {
my @cpt = split /\./,$key;
@ -168,6 +170,10 @@ foreach my $key (oid_lex_sort(keys %$result)) {
my @cpt = split /\./,$key;
$indexR = $cpt[scalar(@cpt)-1];
}
if ($result->{$key} =~ m/Cached/) {
my @cpt = split /\./,$key;
$indexC = $cpt[scalar(@cpt)-1];
}
}
if ($indexV == 0 || $indexR == 0) {
printf("ERROR: cannot find ram information");
@ -177,6 +183,7 @@ my $OID_hrStorage_used = ".1.3.6.1.2.1.25.2.3.1.6";
my $OID_Swap_storage_used = ".1.3.6.1.2.1.25.2.3.1.6.".$indexV;
my $OID_RealM_storage_used = ".1.3.6.1.2.1.25.2.3.1.6.".$indexR;
my $used_mem = $session->get_table(Baseoid => $OID_hrStorage_used);
if (!defined($used_mem)) {
printf("ERROR: Description Table hrStorageUsed : %s.\n", $session->error);
@ -187,6 +194,7 @@ if (!defined($used_mem)) {
my $OID_hrStorage_size = ".1.3.6.1.2.1.25.2.3.1.5";
my $OID_Swap_storage_size = ".1.3.6.1.2.1.25.2.3.1.5.".$indexV;
my $OID_RealM_storage_size = ".1.3.6.1.2.1.25.2.3.1.5.".$indexR;
my $OID_Cache_storage_size = ".1.3.6.1.2.1.25.2.3.1.5.".$indexC;
my $total_mem = $session->get_table(Baseoid => $OID_hrStorage_size);
if (!defined($total_mem)) {
@ -198,6 +206,7 @@ if (!defined($total_mem)) {
my $OID_storage_allocationUnits = ".1.3.6.1.2.1.25.2.3.1.4";
my $OID_Swap_storage_allocationUnits = ".1.3.6.1.2.1.25.2.3.1.4.".$indexV;
my $OID_RealM_storage_allocationUnits = ".1.3.6.1.2.1.25.2.3.1.4.".$indexR;
my $OID_Cache_storage_allocationUnits = ".1.3.6.1.2.1.25.2.3.1.4.".$indexC;
my $alloc_units = $session->get_table(Baseoid => $OID_storage_allocationUnits);
if (!defined($alloc_units)) {
printf("ERROR: Description Table hrStorageUsed : %s.\n", $session->error);
@ -207,9 +216,15 @@ if (!defined($alloc_units)) {
my $swap_used = $used_mem->{$OID_Swap_storage_used} * $alloc_units->{$OID_Swap_storage_allocationUnits};
my $realM_used = $used_mem->{$OID_RealM_storage_used} * $alloc_units->{$OID_RealM_storage_allocationUnits};
my $cache_used = 0;
if (defined $indexC > 0) {
$cache_used = $total_mem->{$OID_Cache_storage_size} * $alloc_units->{$OID_Cache_storage_allocationUnits};
}
my $swap_size = $total_mem->{$OID_Swap_storage_size} * $alloc_units->{$OID_Swap_storage_allocationUnits};
my $realM_size = $total_mem->{$OID_RealM_storage_size} * $alloc_units->{$OID_RealM_storage_allocationUnits};
my $total_memory_used = $swap_used + $realM_used;
my $total_memory_used = $swap_used + $realM_used - $cache_used;
my $total_memory_size = $swap_size + $realM_size;
# percentage of total, physical and swap memory used
@ -265,9 +280,9 @@ sub print_usage () {
sub print_help () {
print "#=========================================\n";
print "# Copyright (c) 2007 Merethis SARL =\n";
print "# Copyright (c) 2007-2009 Merethis SARL =\n";
print "# Developped by Julien Mathis =\n";
print "# Bugs to http://www.oreon-project.org/ =\n";
print "# Bugs to http://www.centreon.com =\n";
print "#=========================================\n";
print_usage();
print "\n";