Page 1 of 1
Changing Check_disk_smb output format
Posted: Sat Jul 04, 2015 4:57 am
by Iantidon
Hi,
Is there a way I can change the output format of this check plugin?
I wanted to have a result in 'MB' instead of 'B'
[root@DEV-ITMON libexec]# ./check_disk_smb -H 172.24.142.228 -s e$ -u 'me_admin' -p 'password'
Disk ok - 1282.81G (68%) free on \\172.24.142.228\e$ | 'e$'=622971584512B;1700323865395.2;1900361967206.4;0;2000381018112
check_disk_smb.JPG
Appreciate your help on this.
Thanks,
Ian
Re: Changing Check_disk_smb output format
Posted: Mon Jul 06, 2015 10:54 am
by lmiltchev
If you had "MB" in the perfdata output, the gauge would show it correctly. It seems like that the perfdata is hardcoded in "B" in the plugin:
Code: Select all
$perfdata = "'" . $share . "'=" . $occupied_bytes . 'B;'
. $warn_bytes . ';'
. $crit_bytes . ';'
. '0;'
. $total_bytes;
I believe, you will need to modify the plugin to show perfdata in "M". Does the perfdata output change if you pass a different unit to the threshold value?
From the plugins's usage:
If thresholds are followed by either a k, M, or G then check to see if that much disk space is available (kilobytes, Megabytes, Gigabytes)
Re: Changing Check_disk_smb output format
Posted: Mon Jul 06, 2015 8:49 pm
by Iantidon
Hi,
I tried changing the thresholds. Below is the results.
COMMAND:
./check_disk_smb -H 172.24.142.228 -s e$ -u 'me_admin' -p '1122' -w '1700G' -c '1680G'
RESULT:
CRITICAL: Only 1660.06G (89%) free on \\172.24.142.228\e$ | 'e$'=217902481408B;175019917312;196494753792;0;2000381018112
I attached the plugin I am using as well.
Regards,
Ian
Re: Changing Check_disk_smb output format
Posted: Tue Jul 07, 2015 9:10 am
by jdalrymple
I would imagine the reason that the plugin developer left the perfdata in bytes was so that there weren't unit problems when comparing 2 different metrics. For instance what if you have a smb share with 17 TiB of used space and only 50 MB of free space, and this was expected. Automatically manipulating the units might make it appear like there is a substantial deal more free space than used space.
That said - you can certainly modify the plugin to adjust the perfdata units as you see fit. The elegant way would be to add a command argument specifying the output units. The inelegant way would be to simply divde the perfdata values $occupied_bytes, $warn_bytes, $crit_bytes and $total_bytes by 1024 as many times as suits you:
Code: Select all
$perfdata = "'" . $share . "'=" . $occupied_bytes . 'B;'
. $warn_bytes . ';'
. $crit_bytes . ';'
. '0;'
. $total_bytes;