check drive free space instead of percentage of free space

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
stf_792
Posts: 48
Joined: Fri Jul 17, 2015 12:55 pm

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

Post 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})
bwallace
Posts: 1145
Joined: Tue Nov 17, 2015 1:57 pm

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

Post 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?
Be sure to check out the Knowledgebase for helpful articles and solutions!
Frédéric GRANAT
Posts: 445
Joined: Mon Nov 19, 2012 11:36 am

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

Post 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 :
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

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

Post 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
You do not have the required permissions to view the files attached to this post.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Frédéric GRANAT
Posts: 445
Joined: Mon Nov 19, 2012 11:36 am

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

Post 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$
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

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

Post 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
You do not have the required permissions to view the files attached to this post.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Frédéric GRANAT
Posts: 445
Joined: Mon Nov 19, 2012 11:36 am

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

Post 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:
You do not have the required permissions to view the files attached to this post.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

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

Post 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?
Former Nagios Employee
Frédéric GRANAT
Posts: 445
Joined: Mon Nov 19, 2012 11:36 am

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

Post 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
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

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

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