Changing Check_disk_smb output format

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
Iantidon
Posts: 7
Joined: Mon Oct 13, 2014 7:20 am

Changing Check_disk_smb output format

Post 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
You do not have the required permissions to view the files attached to this post.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Changing Check_disk_smb output format

Post 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)
Be sure to check out our Knowledgebase for helpful articles and solutions!
Iantidon
Posts: 7
Joined: Mon Oct 13, 2014 7:20 am

Re: Changing Check_disk_smb output format

Post 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
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Changing Check_disk_smb output format

Post 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;
Locked