Révision f5dd2be4
Fixed overflow with >4Gb memory
| plugins/other/snmp_memory | ||
|---|---|---|
| 48 | 48 |
$host = $1; |
| 49 | 49 |
if ($host =~ /^([^:]+):(\d+)$/) |
| 50 | 50 |
{
|
| 51 |
$host = $1;
|
|
| 52 |
$port = $2;
|
|
| 51 |
$host = $1;
|
|
| 52 |
$port = $2;
|
|
| 53 | 53 |
} |
| 54 | 54 |
} |
| 55 | 55 |
elsif (!defined($host)) |
| ... | ... | |
| 62 | 62 |
my $hrSWRunPerfMem = "1.3.6.1.2.1.25.5.1.1.2."; |
| 63 | 63 |
|
| 64 | 64 |
my ($session, $error) = Net::SNMP->session( |
| 65 |
-hostname => $host,
|
|
| 66 |
-community => $community,
|
|
| 67 |
-port => $port
|
|
| 65 |
-hostname => $host,
|
|
| 66 |
-community => $community,
|
|
| 67 |
-port => $port
|
|
| 68 | 68 |
); |
| 69 | 69 |
|
| 70 | 70 |
if (!defined ($session)) |
| ... | ... | |
| 88 | 88 |
|
| 89 | 89 |
if ($memsize > 0) |
| 90 | 90 |
{
|
| 91 |
print "graph_args --base 1024 -l 0 --upper-limit $memsize\n";
|
|
| 91 |
print "graph_args --base 1024 -l 0 --upper-limit $memsize\n";
|
|
| 92 | 92 |
} |
| 93 | 93 |
else |
| 94 | 94 |
{
|
| 95 |
print "graph_args --base 1024 -l 0\n";
|
|
| 95 |
print "graph_args --base 1024 -l 0\n";
|
|
| 96 | 96 |
} |
| 97 | 97 |
|
| 98 | 98 |
print "memory.draw AREA\n"; |
| 99 | 99 |
print "memory.label memory\n"; |
| 100 |
|
|
| 100 |
|
|
| 101 | 101 |
exit 0; |
| 102 | 102 |
} |
| 103 | 103 |
|
| ... | ... | |
| 122 | 122 |
|
| 123 | 123 |
if (!defined $response->{$oid})
|
| 124 | 124 |
{
|
| 125 |
print "undef\n" if $DEBUG;
|
|
| 126 |
return undef;
|
|
| 125 |
print "undef\n" if $DEBUG;
|
|
| 126 |
return undef;
|
|
| 127 | 127 |
} |
| 128 | 128 |
else |
| 129 | 129 |
{
|
| 130 |
print "\"$response->{$oid}\"\n" if $DEBUG;
|
|
| 131 |
return $response->{$oid};
|
|
| 130 |
print "\"$response->{$oid}\"\n" if $DEBUG;
|
|
| 131 |
return $response->{$oid};
|
|
| 132 | 132 |
} |
| 133 | 133 |
} |
| 134 | 134 |
|
| ... | ... | |
| 141 | 141 |
my $num = 0; |
| 142 | 142 |
my $ret = $oid . "0"; |
| 143 | 143 |
my $response; |
| 144 |
|
|
| 144 |
|
|
| 145 | 145 |
print "# Starting browse of $oid...\n" if $DEBUG; |
| 146 |
|
|
| 146 |
|
|
| 147 | 147 |
while (1) |
| 148 | 148 |
{
|
| 149 |
if ($num == 0)
|
|
| 150 |
{
|
|
| 151 |
print "# Checking for $ret...\n" if $DEBUG;
|
|
| 152 |
$response = $handle->get_request ($ret);
|
|
| 153 |
}
|
|
| 154 |
if ($num or !defined $response)
|
|
| 155 |
{
|
|
| 156 |
print "# Checking for sibling of $ret...\n" if $DEBUG;
|
|
| 157 |
$response = $handle->get_next_request ($ret);
|
|
| 158 |
}
|
|
| 159 |
if (!$response)
|
|
| 160 |
{
|
|
| 161 |
return undef;
|
|
| 162 |
}
|
|
| 163 |
my @keys = keys %$response;
|
|
| 164 |
$ret = $keys[0];
|
|
| 165 |
print "# Analyzing $ret (compared to $oid)...\n" if $DEBUG;
|
|
| 166 |
last unless ($ret =~ /^$oid/);
|
|
| 167 |
$num++;
|
|
| 168 |
next unless ($response->{$ret} =~ /$regex/);
|
|
| 169 |
@keys = split (/\./, $ret);
|
|
| 170 |
$result->{$keys[-1]} = $response->{$ret};;
|
|
| 171 |
print "# Index $num: ", $keys[-1], " (", $response->{$ret}, ")\n" if $DEBUG;
|
|
| 149 |
if ($num == 0)
|
|
| 150 |
{
|
|
| 151 |
print "# Checking for $ret...\n" if $DEBUG;
|
|
| 152 |
$response = $handle->get_request ($ret);
|
|
| 153 |
}
|
|
| 154 |
if ($num or !defined $response)
|
|
| 155 |
{
|
|
| 156 |
print "# Checking for sibling of $ret...\n" if $DEBUG;
|
|
| 157 |
$response = $handle->get_next_request ($ret);
|
|
| 158 |
}
|
|
| 159 |
if (!$response)
|
|
| 160 |
{
|
|
| 161 |
return undef;
|
|
| 162 |
}
|
|
| 163 |
my @keys = keys %$response;
|
|
| 164 |
$ret = $keys[0];
|
|
| 165 |
print "# Analyzing $ret (compared to $oid)...\n" if $DEBUG;
|
|
| 166 |
last unless ($ret =~ /^$oid/);
|
|
| 167 |
$num++;
|
|
| 168 |
next unless ($response->{$ret} =~ /$regex/);
|
|
| 169 |
@keys = split (/\./, $ret);
|
|
| 170 |
$result->{$keys[-1]} = $response->{$ret};;
|
|
| 171 |
print "# Index $num: ", $keys[-1], " (", $response->{$ret}, ")\n" if $DEBUG;
|
|
| 172 | 172 |
}; |
| 173 | 173 |
return $result; |
| 174 | 174 |
} |
Formats disponibles : Unified diff