Page 1 of 2
Check_disk and swap usage via NRPE
Posted: Mon Feb 13, 2017 10:10 am
by tomas95go
Hi people, I'm having the next issue:
When I try to Check the Disk of the remote host Nagios tell me that is not possible to find the path to the disk.
When I try to monitor Swap Usage via NRPE or normal way (You know the default one) I get a Critical message saying: that the Swap does not exist or is not defined(normal way) or swap command is not defined (via NRPE) this last one, I know I have to define the command on nrpe.cfg, the pŕoblem is: I don't know how to define it!.
Re: Check_disk and swap usage via NRPE
Posted: Mon Feb 13, 2017 12:18 pm
by rkennedy
Can you show us the related command definitions so we can see what's going on behind the error messages?
Re: Check_disk and swap usage via NRPE
Posted: Mon Feb 13, 2017 2:11 pm
by tomas95go
rkennedy wrote:Can you show us the related command definitions so we can see what's going on behind the error messages?
Thanks for the repply,Off course!, not quite sure wich commands definitions you want so I will put all of them:
Monitoring host:
from: /usr/local/nagios/etc/objects/commands.cfg
Code: Select all
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -t 20
}
from: /usr/local/nagios/etc/nrpe.cfg
Code: Select all
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
The Remote Host has the exact same nrpe.cfg.
Let me know if this is what I have to show you or you need anything alse.
Re: Check_disk and swap usage via NRPE
Posted: Mon Feb 13, 2017 3:35 pm
by rkennedy
Thank you, this is what we need on the command side.
When I try to monitor Swap Usage via NRPE or normal way (You know the default one) I get a Critical message saying: that the Swap does not exist or is not defined(normal way) or swap command is not defined (via NRPE) this last one, I know I have to define the command on nrpe.cfg, the pŕoblem is: I don't know how to define it!.
Could you also show us the service definitions or commands you're running to produce this error? Just trying to gain perspective here.
Re: Check_disk and swap usage via NRPE
Posted: Mon Feb 13, 2017 4:00 pm
by tomas95go
rkennedy wrote:Thank you, this is what we need on the command side.
Could you also show us the service definitions or commands you're running to produce this error? Just trying to gain perspective here.
Yeah, no problem:
All of thisFrom: /usr/local/nagios/etc/objects/localhost.cfg
Code: Select all
define service{
use local-service
host_name Ubuntu
service_description /dev/hda1 Free Space
check_command check_nrpe!check_hda1
}
EDIT: This is the error message: DISK CRITICAL - /dev/hda1 is not accessible: No such file or directory
Note: When I try the command (lsblk -fm) to see my HDD on the remote host the name is sda1, try to change it but doesn't work so I keep it this way.
Swap check with nrpe:
Code: Select all
define service{
use local-service ; Name of service template to use
host_name Ubuntu
service_description Swap Usage
check_command check_nrpe!check_swap
}
Actually: The state with this change to: Unknown: check_swap: Could not parse arguments .
Swap check with the default way:
Code: Select all
define service{
use local-service ; Name of service template to use
host_name Ubuntu
service_description Swap Usage
check_command check_local_swap!20!10
}
The state of this one is still Critical: SWAP CRITICAL - 0% free (0 MB out of 0 MB) - Swap is either disabled, not present, or of zero size.
Note: When I do "free -m" on the remote host I get this:
Total/used/free/shared/ buff/cache/ available
Memory:2000 /61 /1442 /1 /495 /1784
Swap: 2045 0 2045
Re: Check_disk and swap usage via NRPE
Posted: Mon Feb 13, 2017 4:22 pm
by tgriep
The command
Code: Select all
check_command check_local_swap!20!10
That you defined it for checking the swap on the nagios server and not the remote server.
To check the swap on the remote server, you would add a command to the remote server's nrpe.cfg file like the example below.
Code: Select all
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 40% -c 20%
Then restart the NRPE Agent on the remote system and then edit the check_command on the Nagios server like below
Code: Select all
check_command check_nrpe!check_swap!20!10
Try that and post back if this is what you are looking for.
Re: Check_disk and swap usage via NRPE
Posted: Mon Feb 13, 2017 4:41 pm
by tomas95go
tgriep wrote:Try that and post back if this is what you are looking for.
That worked!!!
Now the only thing that is not working is the check_nrpe!check_hda1
And I got a question that with the thing you said in your reply and I think I never understand it, services like:
Code: Select all
define service{
use local-service ; Name of service template to use
host_name Ubuntu
service_description Current Load
check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
}
That one, are monitoring the Nagios Sv (Local machine) or the remote host? May be is a dumb question but I'm new at Nagios
Other questions's I have now that I'm thinking on it:
Why SSH service sometimes says to me: Socket Timeout but then the service is fixed by itself.
And the other one is: the nrpe client on the remote host could crash or something? I'm asking this because few days ago, something happened to the nrpe client on the remote host and all of the nrpe services were in warning, I restart the nrpe client on the remote host and that fixed it.
Re: Check_disk and swap usage via NRPE
Posted: Mon Feb 13, 2017 5:34 pm
by tgriep
Create a command in the nrpe.cfg file like the example below
Code: Select all
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /
And create your service check like this example
Code: Select all
define service{
use local-service
host_name Ubuntu
service_description Root / Free Space
check_command check_nrpe!check_disk
}
That will check the root partition's space for you using just the / for the name and not the full device name and that should fix that for you.
If the check has the work local in it, it usually means to check the local system the command is run on and in your case that is the nagios server.
The SSH timeout could that that the remote server is taking longer than the default timeout but you can add the following to the command to increase it to 59 seconds.
Re: Check_disk and swap usage via NRPE
Posted: Mon Feb 13, 2017 6:03 pm
by tomas95go
It's all working now! I really appreciate your help tgriep and rkennedy.
The last thing I'm going to ask you two, where can I learn about the nrpe monitoring services ,more nagios plugins for monitoring and the arguments of the commands.
Thanks again

!
Re: Check_disk and swap usage via NRPE
Posted: Mon Feb 13, 2017 9:19 pm
by dwhitfield
tomas95go wrote:
The last thing I'm going to ask you two, where can I learn about the nrpe monitoring services ,more nagios plugins for monitoring and the arguments of the commands.
There's more than one answer to those, but these should set you on your way:
NRPE:
https://assets.nagios.com/downloads/nag ... e/NRPE.pdf
Plugins:
http://nagios-plugins.org/
Arguments:
https://assets.nagios.com/downloads/nag ... acros.html
That should keep you busy for a while, but if you need more, let us know! Off the top of my head, I know there's another 13-page NRPE document out there!