As a long time user of the snmpdiskspace.monitor, I was misled everytime
an alert went of, as it reported significantly more "disk free" then
available.
Cause was that ext2/ext3 filesystems reserves 5 % for emergencies, ie
root usage only. This diskspace is not available to the general user
("df" doesn't see it), but according to SNMP this diskspace is unused
and hence snmpdiskspace.monitor reports much more disk free then is
available in reality. The problem is of course that recipients of the
alert think the amount of diskspace still suffices, while in reality the
situation is more urgent than it looks.
The solution turns out te be really simple: check if the filesystem is
ext2/ext3 and reduce the total diskspace by 5 % in the
snmpdiskspace.monitor. This is indeed the correct calculation for
calculating the true numbers. Alerts now generated correspond with what
one sees with "df".
The patch is against Ed's version "1.5 2005/01/13". Attached is the
context diff. It might look impressive, but it's only four lines of code.
Something else, in the "new SNMP::Session" call I NEED to add a "Version
=> 2" parameter. Else the monitor crashes with "could not get SNMP
info: Unknown user name". Debugging turns out te be quite obscure. I
would prefer it if the monitor came with a parameter or comment or
somesuch that would remind me of its existence.
Cheers,
--
| Hans Kinwel
| [EMAIL PROTECTED]
*** snmpdiskspace.monitor.old 2005-11-16 14:38:10.000000000 +0100
--- snmpdiskspace.monitor.new 2005-11-16 15:07:05.000000000 +0100
***************
*** 331,337 ****
sub get_values {
my ($host) = @_;
! my
(@disklist,$Type,$Descr,$AllocationUnits,$Size,$Used,$Freespace,$Percent,$InodePercent);
my ($v,$s);
--- 331,337 ----
sub get_values {
my ($host) = @_;
! my
(@disklist,$Type,$FSType,$Descr,$AllocationUnits,$Size,$Used,$Freespace,$Percent,$InodePercent);
my ($v,$s);
***************
*** 361,366 ****
--- 361,367 ----
['hrStorageAllocationUnits'],
['hrStorageSize'],
['hrStorageUsed'],
+ ['hrFSType'],
);
***************
*** 372,377 ****
--- 373,388 ----
$AllocationUnits = $v->[3]->val;
$Size = $v->[4]->val;
$Used = $v->[5]->val;
+ $FSType = $v->[6]->val;
+
+ # if filesystem == ext2/ext3 then...
+ # ext2/ext3 filesystems reserve 5 % of diskspace for
emergencies.
+ # Substract from total, and get an outcome much more in line
with
+ # what "df" tells you
+ # ".1.3.6.1.2.1.25.3.9.23" is "OID:
HOST-RESOURCES-TYPES::hrFSLinuxExt2"
+ if ($FSType eq ".1.3.6.1.2.1.25.3.9.23") {
+ $Size = $Size * 0.95;
+ }
$Freespace = (($Size - $Used) * $AllocationUnits);
print STDERR "Found HOST MIB filesystem: Type=$Type,
Descr=$Descr, AllocationUnits=$AllocationUnits, Size=$Size, Used=$Used\n" if
$DEBUG;
_______________________________________________
mon mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/mon