Monitor uptime with threshold
-
- Posts: 239
- Joined: Mon Jun 27, 2016 11:05 pm
Monitor uptime with threshold
Can you let me know how i can monitor server uptime with critical therehold of 30 min.
Checking objects...
Error: Service check command 'check_uptime --warning 30: --critical 15' specified in service 'UPTIME' for host 'localhost' not defined anywhere!
Checking objects...
Error: Service check command 'check_uptime --warning 30: --critical 15' specified in service 'UPTIME' for host 'localhost' not defined anywhere!
Re: Monitor uptime with threshold
The error could be caused from either the check_uptime command is not defined in the commands.cfg file and you could use the example below if needed to add the command
Or that there is a mis-configuration for the UPTIME service and you would have to post the configuration here so we can see what is wrong with it.
I am guessing that you may be missing the exclamation points (!) in that check between the command name and the threshold settings.
You example for the thresholds should generate a warning if the uptime is less than 30 minutes and a critical if the uptime is longer than 15 minutes.
Take a look at the link below for some threshold examples and adjust your command to your requirements.
https://nagios-plugins.org/doc/guidelin ... HOLDFORMAT
Code: Select all
define command {
command_name check_uptime
command_line $USER1$/check_uptime $ARG1$
}
I am guessing that you may be missing the exclamation points (!) in that check between the command name and the threshold settings.
You example for the thresholds should generate a warning if the uptime is less than 30 minutes and a critical if the uptime is longer than 15 minutes.
Take a look at the link below for some threshold examples and adjust your command to your requirements.
https://nagios-plugins.org/doc/guidelin ... HOLDFORMAT
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
- Posts: 239
- Joined: Mon Jun 27, 2016 11:05 pm
Re: Monitor uptime with threshold
I have added the up time check but i recently checked and found that it is not giving me the correct up-time for the nodetgriep wrote:The error could be caused from either the check_uptime command is not defined in the commands.cfg file and you could use the example below if needed to add the commandOr that there is a mis-configuration for the UPTIME service and you would have to post the configuration here so we can see what is wrong with it.Code: Select all
define command { command_name check_uptime command_line $USER1$/check_uptime $ARG1$ }
I am guessing that you may be missing the exclamation points (!) in that check between the command name and the threshold settings.
You example for the thresholds should generate a warning if the uptime is less than 30 minutes and a critical if the uptime is longer than 15 minutes.
Take a look at the link below for some threshold examples and adjust your command to your requirements.
https://nagios-plugins.org/doc/guidelin ... HOLDFORMAT
Below is how i have added the command.
Re: Monitor uptime with threshold
@ericssonvietnam, as tgriep mentioned. If your command is the same for check_uptime, could you show us your $ARG$ when using this?
The check command for this service is what we're looking for to see if you are passing (!).
The check command for this service is what we're looking for to see if you are passing (!).
-
- Posts: 239
- Joined: Mon Jun 27, 2016 11:05 pm
Re: Monitor uptime with threshold
Below is how i have defined the command in commands.cfgkyang wrote:@ericssonvietnam, as tgriep mentioned. If your command is the same for check_uptime, could you show us your $ARG$ when using this?
The check command for this service is what we're looking for to see if you are passing (!).
define command {
command_name heck_uptime
command_line $USER1$/check_uptime $ARG1$
}
And in remotehost.cfg i have defined service and hostname as below :
define service{
use generic-service ; Name of service template to use
host_name bhraas02,UP_WSDP63B
service_description UPTIME
check_command check_uptime! --warning 30: --critical 15:
contact_groups nocuser
}
Below is the hostconfiguration in the same file
#Host 134
define host {
use linux-server
host_name UP_WSDP63B
alias UP_WSDP63B
address 10.2.48.46
contact_groups nocuser
notifications_enabled 1
}
But it is still showing me nagios server uptime
which is 39 days
-
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: Monitor uptime with threshold
@ericssonvietnam, You have a typo in you command definition:
Change:
to
Then please run:
Everything should be working now.
Change:
Code: Select all
define command {
command_name heck_uptime
command_line $USER1$/check_uptime $ARG1$
}
Code: Select all
define command {
command_name check_uptime
command_line $USER1$/check_uptime $ARG1$
}
Code: Select all
service nagios restart
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
-
- Posts: 239
- Joined: Mon Jun 27, 2016 11:05 pm
Re: Monitor uptime with threshold
i missed it while posting it is correctly present there as belownpolovenko wrote:@ericssonvietnam, You have a typo in you command definition:
Change:toCode: Select all
define command { command_name heck_uptime command_line $USER1$/check_uptime $ARG1$ }
Then please run:Code: Select all
define command { command_name check_uptime command_line $USER1$/check_uptime $ARG1$ }
Everything should be working now.Code: Select all
service nagios restart
define command {
command_name check_uptime
command_line $USER1$/check_uptime $ARG1$
}
-
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: Monitor uptime with threshold
@ericssonvietnam, I see what you're saying. I don't think you can monitor remote hosts with this plugin because this plugin can only run locally.
Theoretically, you could do something like:
But it's not going to work because the plugin itself won't accept -Host argument:
So what you can do is install some kind of agent on your remote host, like NRPE. It's going to run the plugin locally on your host and send information back to the Nagios host:
Theoretically, you could do something like:
Code: Select all
define command {
command_name check_uptime
command_line $USER1$/check_uptime -H $HOSTADDRESS$ $ARG1$
}
Code: Select all
Options:
-h, --help
Print detailed help screen
-V, --version
Print version information
--extra-opts=[section][@file]
Read options from an ini file. See
https://www.nagios-plugins.org/doc/extra-opts.html
for usage and examples.
-u, Time unit of measurement (seconds|minutes|hours|days) (default: minutes)
-w, Warning threshold
-c, Critcal threshold
-t, Plugin timeout, default 10 seconds
-vvv, Enable verbose output
Code: Select all
https://assets.nagios.com/downloads/nagioscore/docs/nrpe/NRPE.pdf
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
-
- Posts: 239
- Joined: Mon Jun 27, 2016 11:05 pm
Re: Monitor uptime with threshold
But we need to do this without installation of any agent or nrpe on the server.can u suggest.npolovenko wrote:@ericssonvietnam, I see what you're saying. I don't think you can monitor remote hosts with this plugin because this plugin can only run locally.
Theoretically, you could do something like:
But it's not going to work because the plugin itself won't accept -Host argument:Code: Select all
define command { command_name check_uptime command_line $USER1$/check_uptime -H $HOSTADDRESS$ $ARG1$ }
So what you can do is install some kind of agent on your remote host, like NRPE. It's going to run the plugin locally on your host and send information back to the Nagios host:Code: Select all
Options: -h, --help Print detailed help screen -V, --version Print version information --extra-opts=[section][@file] Read options from an ini file. See https://www.nagios-plugins.org/doc/extra-opts.html for usage and examples. -u, Time unit of measurement (seconds|minutes|hours|days) (default: minutes) -w, Warning threshold -c, Critcal threshold -t, Plugin timeout, default 10 seconds -vvv, Enable verbose output
Code: Select all
https://assets.nagios.com/downloads/nagioscore/docs/nrpe/NRPE.pdf
-
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: Monitor uptime with threshold
@ericssonvietnam, If installing an agent on the remote host is not an option then i'd suggest ./check_by_ssh plugin.
Navigate to /usr/local/nagios/libexec/
and run:
Let us know if this would work for you and if you need help creating a service definition with this plugin.
Navigate to /usr/local/nagios/libexec/
and run:
Code: Select all
./check_by_ssh -H Your_Server_IP -C uptime
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.