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

check drive free space instead of percentage of free space

Post by Frédéric GRANAT »

Hi,
I use the following command in my service template to check percentage of free space :
$USER1$/check_wmi_plus.pl -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ -m checkdrivesize -a "$ARG3$" -w $ARG4$ -c $ARG5$ $ARG6$

where
ARG3 = several disks (C|D|Q,...etc)
ARG4 = percentage of free space warning
ARG5 = percentage of free space critical

Now, I don't want to check the percentage but the value of free space remaining (5 Gb by example)
ARG4=5G
ARG5=3G

How can I do ?

Rgds,

Frederic
Last edited by dwhitfield on Fri Sep 30, 2016 10:24 am, edited 1 time in total.
Reason: marking with green check mark
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

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

Post by slansing »

Have a look at this snippit from the plugin's internal help flag:
for MODE=checkdrivesize:
-w _UsedGB=10G -w 15 -w _Free%=5: -c _UsedGB=20G -c _Used%=25
This will generate a warning if
- the Used GB on the drive is more than 10G or
- the used % of the drive is more than 15% or
- the free % of the drive is less than 5%

This will generate a critical if
- the Used GB on the drive is more than 20G or
- the used % of the drive is more than 25%
That should help get the ball rolling, it looks like you need to designate a "_FreeGB" value:
Valid Warning/Critical Fields are: _Used% (Default), _UsedGB, _Free%, _FreeGB.
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,
that doesn't work

Here's my command

Code: Select all

$USER1$/check_wmi_plus.pl -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ -m checkdrivesize -a "$ARG3$" -w _FreeGB=$ARG4$ -c _FreeGB=$ARG5$ $ARG6$
Here's my template (using above command)

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
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

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

Post by sreinhardt »

What about it is not working? To be clear, this check does not check if there is 5GB free, it only checks how much you presently have used. So if you have a 250gb drive, and you have want to see when you only have 5GB left, you need to set warning to -w 245gb, not -w 5gb.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
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 »

I'm very astonished since someone of the support tells me that there was a way to check free space.
If, according to you, there's is no way to chek free space, then what is the use of _FreeGB and _Free%.
I will await the answer of slansing.
Rgds,

Frederic
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 believe the plugin's logic is "wrong" with the "_FreeGB" argument. It should give you a "Warning" or "Critical" if LESS than the thresholds specified. But the plugin does the opposite.

For example, when I have less than 20 GB free space, I would like to get a warning, but if I have less than 10 GB - I would like to get a critical. So, I try:

Code: Select all

/usr/local/nagios/libexec/check_wmi_plus.pl -H <myhost> -u '<username>' -p '<password>' -m checkdrivesize -a 'C': -w '_FreeGB=20' -c '_FreeGB=10'
however, the output is:

Code: Select all

CRITICAL - [Triggered by _FreeGB>10] - C: Total=452.96GB, Used=197.61GB (43.6%), Free=255.35GB (56.4%)     |'C: Space'=197.61GB; 'C: Utilisation'=43.6%;
I get a "CRITICAL", because my free space (255.35 GB) is MORE than my threshold of 10GB... which is not what I am after.

If I try:

Code: Select all

/usr/local/nagios/libexec/check_wmi_plus.pl -H <myhost> -u '<username>' -p '<password>' -m checkdrivesize -a 'C': -w '_FreeGB=400' -c '_FreeGB=300'
then I get:

Code: Select all

OK - C: Total=452.96GB, Used=197.61GB (43.6%), Free=255.35GB (56.4%)     |'C: Space'=197.61GB; 'C: Utilisation'=43.6%;
because my free space LESS than the thresholds specified.

I am not sure what is going to be the best solution, but I would probably use "_UsedGB" or "_Used%" instead of "_FreeGB" and "_Free%".
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 »

I would probably use "_UsedGB" or "_Used%" instead of "_FreeGB" and "_Free%".
=> The problem is that the total amount of disk is different on each server. So _UsedGB will have to be different.

It seems to me that it's normal to check free space, and it's not possible on Nagios.
What solution do you propose to check free space (in GB)?

Frederic
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

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

Post by slansing »

It is most definitely possible to check free space.. this is a issue with the way the plugin you are choosing to use is formatted.. you may want to look into check_nrpe, check_nt, NRDP, or even SNMP. There are many ways to return performance metrics from a Windows system. Have you taken a look at your system's performance counters? There are a incredible amount of options available on that front alone. Let us know if you need assistance with any of these, but if you are set on using that wmi plugin you will want to contact it's developer and ask if they can make a patch to the code for you, or you could alter it your self if the licensing allows.
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 saw that it was possible to check free space in Gb with check_nrpe.
But I would have to make a big change on my nagios platform (spending a lot of time on it).
I hoped that I could check it with my actual command but it seems it's not possible.

I'm going to manage by myself.

Frederic
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

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

Post by slansing »

NRPE would require you to install the NSClient++ agent on your windows system, though it is quite easy to configure. Let us know if you need assistance.
Locked