check free disk space

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
happy
Posts: 20
Joined: Wed Nov 28, 2012 4:37 pm

check free disk space

Post by happy »

Hi

I am using Nagios command (check_nt!USEDDISKSPACE!-l f -w 90 -c 95) to send alert if used space is over 90% / 95%).

I am now looking into setting up alerts if free disk space is lower than say 5GB. I believe Nagios core is not able to do it but a script or plug-in could be used to do that.

I wonder if anyone has a script/ plug-in that they can share which can send alerts based on free disk space integer.

Thanks.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: check free disk space

Post by scottwilkerson »

You cannot do this with check_nt but you can with check_nrpe (using NSClient). You would use something like this

Code: Select all

check_nrpe -H IP -p 5666 -c CheckDriveSize -a ShowAll MinWarnFree=10% MinCritFree=5G Drive=c:
http://www.nsclient.org/nscp/wiki/Check ... ze/samples
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
happy
Posts: 20
Joined: Wed Nov 28, 2012 4:37 pm

Re: check free disk space

Post by happy »

Hi scottwilkerson

Thank you for taking time to reply - apologies that it took me a while to work on this.

When I run the command you provided from the terminal I get the following:

# ./check_nrpe -H <xxx.xxx.xxx.xxx> -p 5666 -c CheckDriveSize -a ShowAll MinWarnFree=10% MinCritFree=5% Drive=c:
Exception processing request: Request contained arguments (not currently allowed, check the allow arguments option).

# ./check_nrpe -H <xxx.xxx.xxx.xxx> -p 5666
I (0,4,1,66 2012-11-18) seem to be doing fine...
verifies that check_nrpe is available is is able to reach the host.

Do you know which option may not be allowed and how to fix it?

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

Re: check free disk space

Post by slansing »

Exception processing request: Request contained arguments (not currently allowed, check the allow arguments option).
Have you checked the allow arguments option? It is located within the configuration file "NSC/nsclient.ini" and should be titled along the lines of:

Code: Select all

allow_arguments
happy
Posts: 20
Joined: Wed Nov 28, 2012 4:37 pm

Re: check free disk space

Post by happy »

Hi

Thank you for replying and pointing me to the correct direction. I was able to made necessary changes to the config file and now I am able to run the following command from terminal and get the expected output.

Code: Select all

./check_nrpe -H <my host ip address> -p 5666 -c CheckDriveSize -a ShowAll MinWarnFree=10% MinCritFree=5G Drive=f:
I am fairly new to Nagios and when I try to integrate it into Nagios I run into issues. Do you know what is the missing part of the puzzle?

In my command.ini file I have added

Code: Select all

define command {
  command_name CheckDriveSize
  command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckDriveSize -a ShowAll MinWarnFree=$ARG2$ MinCritFree=5G Drive=c:
}
in my windows.cfg file I have added

Code: Select all

define service{
        use                     generic-service
        host_name               <my host name>
        service_description     C:\ Drive Space
        check_command           CheckDriveSize c:,5G!10%
        }
To above Nagios is not happy. Do you know what is needed?
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: check free disk space

Post by slansing »

I think I have spotted the problem, in your command definition change the command_line to the following:

Code: Select all

$USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$ -a ShowAll MinWarnFree=$ARG2$ MinCritFree=5G Drive=c:

Code: Select all

check_command           check_nrpe!CheckDriveSize!15!
happy
Posts: 20
Joined: Wed Nov 28, 2012 4:37 pm

Re: check free disk space

Post by happy »

Hi Slansing

The changes you recommended has not fixed the issue. After making the changes when I run pre flight test I get the error:
Error: Service check command 'check_nrpe' specified in service 'C:\ Drive Space' for host '<myhostname>' not defined anywhere!

If I commend out the service_description line in the windows.cfg then I don't get any error but I don't receive any alerts either.

Do you know if I need to define service_description at another place first?

Thanks!!!
User avatar
gshergill
Posts: 231
Joined: Tue Aug 07, 2012 5:08 am

Re: check free disk space

Post by gshergill »

Hi happy,

In your command.ini (command.ini is on the nagios server?) you have the following, correct?

Code: Select all

define command {
  command_name CheckDriveSize
  command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$ -a ShowAll MinWarnFree=$ARG2$ MinCritFree=5G Drive=c:
}
So in your windows.cfg you should have the following:

Code: Select all

define service{
        use                     generic-service
        host_name               <my host name>
        service_description     C:\ Drive Space
        check_command           CheckDriveSize!CheckDriveSize!10%
        }
In command.ini you define a "command_name", which is used for the "check_command" in the windows.cfg. The format of "check_command" is normally "command_name!<ARG1>!<ARG2>.....".

I hope this is helpful, I'm assuming your command.ini is on your nagios machine.

Kind Regards,

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

Re: check free disk space

Post by slansing »

Doh! How did I not see that... I must have ran out of coffee. Thank's for the input as always Gshergill!
happy
Posts: 20
Joined: Wed Nov 28, 2012 4:37 pm

Re: check free disk space

Post by happy »

Hi gshergill and Slansing

Thank you for all your help. I was able to get the required results and configured it as required. I currently have:

Code: Select all

define command {
  command_name CheckDriveSize
  command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$ -a ShowAll MinWarnFree=$ARG2$ MinCritFree=5G Drive=c:
}

define service{
        use                              generic-service
        host_name                  <myhostname>
        service_description     C:\ Drive Space
        check_command          CheckDriveSize!CheckDriveSize!5G
}
How can I change the command_line 'Drive=c' into argument so that I am able to check multiple drive letters with the same command_line?

I tried the following but it did not work and I am not able to figure it out :(

Code: Select all

command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$ -a ShowAll MinWarnFree=$ARG2$ Drive=$ARG3$ MinCritFree=5G

check_command          CheckDriveSize!CheckDriveSize!c:!CheckDriveSize!5G
I appreciate your time!
Locked