diff options
author | Sven Nierlein <sven@consol.de> | 2024-02-23 17:24:28 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-23 17:24:28 (GMT) |
commit | 117cd8e4b826e471e795536228628d817df33f5a (patch) | |
tree | 4ce82a1ad714f95e0bb790aa9396f059bf5a3677 /plugins/t/check_disk.t | |
parent | 0c01f2946ed21f5e7977b5503f9c9f00e72fd708 (diff) | |
download | monitoring-plugins-117cd8e4b826e471e795536228628d817df33f5a.tar.gz |
check_disk increase alert precision (#1989)
* check_disk increase alert precision
Free disk percentage value was rounded to a full integer meaning it alerted about ~1% percent too early. This is about 10GB on a 1TB disk.
The warning and critical thresholds already support float values, so just the percentage calculation needs to be improved.
old:
./check_disk -w 35% -c 20% -p / -f -vvv
Thresholds(pct) for / warn: 35.000000 crit 20.000000
calling stat on /
For /, used_pct=65 free_pct=35 used_units=286451 free_units=156651 total_units=443102 used_inodes_pct=11 free_inodes_pct=89 fsp.fsu_blocksize=4096 mult=1048576
Freespace_units result=0
Freespace% result=1
Usedspace_units result=0
Usedspace_percent result=0
Usedinodes_percent result=0
Freeinodes_percent result=0
DISK WARNING - free space: WARNING [ / 156651MiB (35% inode=89%)];| /=300365643776B;302006979788;371700898201;0;464626122752
new:
./check_disk -w 35% -c 20% -p / -f -vvv
Thresholds(pct) for / warn: 35.000000 crit 20.000000
calling stat on /
For /, used_pct=64.649722 free_pct=35.350278 used_units=286464 free_units=156637 total_units=443102 used_inodes_pct=10.016183 free_inodes_pct=89.983817 fsp.fsu_blocksize=4096 mult=1048576
Freespace_units result=0
Freespace% result=0
Usedspace_units result=0
Usedspace_percent result=0
Usedinodes_percent result=0
Freeinodes_percent result=0
DISK OK - free space: / 156637MiB (35.4% inode=90%);| /=300379275264B;302006979788;371700898201;0;464626122752
* check_disk: adjust test case to support float precision
Diffstat (limited to 'plugins/t/check_disk.t')
-rw-r--r-- | plugins/t/check_disk.t | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t index bf8dd36..e0dd70e 100644 --- a/plugins/t/check_disk.t +++ b/plugins/t/check_disk.t | |||
@@ -44,7 +44,7 @@ my @perf_data = sort(split(/ /, $result->perf_output)); | |||
44 | # Calculate avg_free free on mountpoint1 and mountpoint2 | 44 | # Calculate avg_free free on mountpoint1 and mountpoint2 |
45 | # because if you check in the middle, you should get different errors | 45 | # because if you check in the middle, you should get different errors |
46 | $_ = $result->output; | 46 | $_ = $result->output; |
47 | my ($free_on_mp1, $free_on_mp2) = (m/\((\d+)%.*\((\d+)%/); | 47 | my ($free_on_mp1, $free_on_mp2) = (m/\((\d+\.\d+)%.*\((\d+\.\d+)%/); |
48 | die "Cannot parse output: $_" unless ($free_on_mp1 && $free_on_mp2); | 48 | die "Cannot parse output: $_" unless ($free_on_mp1 && $free_on_mp2); |
49 | my $avg_free = ceil(($free_on_mp1+$free_on_mp2)/2); | 49 | my $avg_free = ceil(($free_on_mp1+$free_on_mp2)/2); |
50 | my ($more_free, $less_free); | 50 | my ($more_free, $less_free); |