Page 2 of 2

Re: check drive free space instead of percentage of free spa

Posted: Wed Apr 13, 2016 3:07 pm
by stf_792
I know it is an old thread, but I was trying to solve the same issue, and was not able to find a solution.

After going through check_wmi_plus.pl code and experimenting, I was able to get it right.

Get Warning and Critical when free space drops below certain number of GB instead of percentage.


in example mentioned
Command view
$USER1$/check_wmi_plus.pl -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ -m checkdrivesize -a "$ARG3$" -w _FreeGB=$ARG4$ -c _FreeGB=$ARG5$ $ARG6$

ARG3=C|D|E|Q|H|I|L|M|N
ARG4=5G
ARG5=4G
5G and 4G need to be appended with colon

Code: Select all

Command view
$USER1$/check_wmi_plus.pl -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ -m checkdrivesize -a "$ARG3$" -w _FreeGB=$ARG4$ -c _FreeGB=$ARG5$ $ARG6$

ARG3=C|D|E|Q|H|I|L|M|N
ARG4=5G:
ARG5=4G:
so part of the string will look something like

Code: Select all

-w '_FreeGB=5:' -c '_FreeGB=4:'


according to this

EXAMPLE RANGES
This table lists example WARN/CRIT criteria and when they will trigger an alert.
10 < 0 or > 10, (outside the range of {0 .. 10})
10: < 10, (outside {10 .. infinity})
~:10 > 10, (outside the range of {-infinity .. 10})
10:20 < 10 or > 20, (outside the range of {10 .. 20})
\@10:20 = 10 and = 20, (inside the range of {10 .. 20})
10 < 0 or > 10, (outside the range of {0 .. 10})
10G < 0 or > 10G, (outside the range of {0 .. 10G})

Re: check drive free space instead of percentage of free spa

Posted: Wed Apr 13, 2016 3:26 pm
by bwallace
Thanks for sharing and glad to see this got straightened out! Did you have any other questions or may we lock this thread, seeing it is 1,100 days running?

Re: check drive free space instead of percentage of free spa

Posted: Fri Sep 23, 2016 8:08 am
by Frédéric GRANAT
Hi,
I've just tested the following syntax in my template and apply it to a service

Code: Select all

Command view
$USER1$/check_wmi_plus.pl -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ -m checkdrivesize -a "$ARG3$" -w _FreeGB=$ARG4$ -c _FreeGB=$ARG5$ $ARG6$

ARG3=C|D|E|Q|H|I|L|M|N
ARG4=5G:
ARG5=4G:
It doesn't work :

Re: check drive free space instead of percentage of free spa

Posted: Fri Sep 23, 2016 10:17 am
by lmiltchev
Try wrapping the $ARG3$ value in single quotes. I tried the following, which worked for me:

Code: Select all

define service {
	host_name			Windows7-WMI
	service_description		Drives
	use				xiwizard_windowswmi_service
	check_command			check_xi_service_wmiplus!'username'!'password'!checkdrivesize!-a 'C|D'!-w _FreeGB=5G -c _FreeGB=4G!!!
	max_check_attempts		5
	check_interval			5
	retry_interval			1
	check_period			xi_timeperiod_24x7
	notification_interval		60
	notification_period		xi_timeperiod_24x7
	notifications_enabled		1
	contacts			nagiosadmin
	_xiwizard			windowswmi
	register			1
	}
example01.PNG

Re: check drive free space instead of percentage of free spa

Posted: Tue Sep 27, 2016 9:26 am
by Frédéric GRANAT
Hi,
I tried the following with command $USER1$/check_wmi_plus.pl -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ -m checkdrivesize -a "$ARG3$" -w _FreeGB=$ARG4$ -c _FreeGB=$ARG5$ $ARG6$ :
$ARG3$='C:'|'D:'|'E:'|'Q:'|'H:'|'I:'|'L:'|'M:'|'N:' doesn't work
$ARG3$='C:|D:|E:|Q:|H:|I:|L:|M:|N:' doesn't work
$ARG3$='C|D|E|Q|H|I|L|M|N' doesn't work

$ARG3$=C:|D:|E:|Q:|H:|I:|L:|M:|N: works with command $USER1$/check_wmi_plus.pl -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ -m checkdrivesize -a "$ARG3$" -w $ARG4$ -c $ARG5$ $ARG6$

Re: check drive free space instead of percentage of free spa

Posted: Tue Sep 27, 2016 11:50 am
by lmiltchev
I tested the following scenario - in my command, $ARG4$ is NOT wrapped in quotes, and in the $ARG4$ field I have -a 'C|D' -w _FreeGB=5G -c _FreeGB=4G, which seems to work fine.
example01.PNG

Re: check drive free space instead of percentage of free spa

Posted: Thu Sep 29, 2016 8:37 am
by Frédéric GRANAT
Hi,
I tried your configuration : (please see the attached screen capture)

$ARGG$4=-a 'C|D|E|Q|H|I|L|M|N' -w _FreeGB=10G -c _FreeGB=5G

Here's the result of test command on a host having a disk size problem :

COMMAND: /usr/local/nagios/libexec/check_wmi_plus.pl -H xxxxxxxx -u domcompta/svc_riverbed -p dsisvc -m checkdrivesize -a 'C\|D\|E\|Q\|H\|I\|L\|M\|N' -w _FreeGB=10G -c _FreeGB=5G
OUTPUT: UNKNOWN - Could not find a drive matching 'C\|D\|E\|Q\|H\|I\|L\|M\|N' or the WMI data returned is invalid. Available Drives are C:, D:, E:, F:, M:, N:

Re: check drive free space instead of percentage of free spa

Posted: Thu Sep 29, 2016 11:44 am
by rkennedy
The test check command will not act as a regular Nagios check would due to escaping and permissions. When the check runs it's full course, does it work successfully, or what error do you see?

Re: check drive free space instead of percentage of free spa

Posted: Fri Sep 30, 2016 9:26 am
by Frédéric GRANAT
Hi,
You're right, the test doesn't work but the check works, so you can close the post.
Thanks,

Frederic

Re: check drive free space instead of percentage of free spa

Posted: Fri Sep 30, 2016 10:22 am
by dwhitfield
Glad to hear it is resolved. I am going to lock the thread. Please feel free to post again if you have you another issue. Thank you for using the Nagios forums!