Page 1 of 1

Uptime Powered

Posted: Thu Aug 22, 2019 11:54 am
by martinsrs
Good afternoon
I am trying to configure nagios to alarm if the server is powered on for more than 60 days.
But I can't, does anyone know how I can do this?
With -c it alarms when it is shorter than the time I set.

Re: Uptime Powered

Posted: Thu Aug 22, 2019 12:06 pm
by scottwilkerson
The default unit is minutes

Code: Select all

-u, Time unit of measurement (seconds|minutes|hours|days) (default: minutes)
Try

Code: Select all

/usr/local/nagios/libexec/check_uptime -c 60 -u days
or convert to minutes 60 * 24 * 60 = 86400

Code: Select all

/usr/local/nagios/libexec/check_uptime -c 86400

Re: Uptime Powered

Posted: Thu Aug 22, 2019 12:10 pm
by martinsrs
scottwilkerson wrote:The default unit is minutes

Code: Select all

-u, Time unit of measurement (seconds|minutes|hours|days) (default: minutes)
Try

Code: Select all

/usr/local/nagios/libexec/check_uptime -c 60 -u days
or convert to minutes 60 * 24 * 60 = 86400

Code: Select all

/usr/local/nagios/libexec/check_uptime -c 86400
I want it to be critical when it is on for more than 60 days, this command is for when it is less than 60 days on.

Re: Uptime Powered

Posted: Thu Aug 22, 2019 12:55 pm
by scottwilkerson
martinsrs wrote:I want it to be critical when it is on for more than 60 days, this command is for when it is less than 60 days on.
Not true, here's my example with a machine that has been up 85 days (more than 60)

Code: Select all

[root@localhost ~]# uptime
 11:44:37 up 85 days,  2:25,  2 users,  load average: 0.35, 0.36, 0.25
[root@localhost ~]# /usr/local/nagios/libexec/check_uptime -c 60 -u days
Uptime CRITICAL: 85 day(s) 2 hour(s) 25 minute(s) | uptime=85.000000;;60.000000;
for clarity, the command for LESS THAN 60 days would be

Code: Select all

/usr/local/nagios/libexec/check_uptime -c 60: -u days

Re: Uptime Powered

Posted: Thu Aug 22, 2019 2:49 pm
by martinsrs
How do I do this in Windows, is it the same thing?
In NSClient it looks like this:
alias_up = checkUpTime MinWarn = 1d MinWarn = 1h
And in Webadmin I passed the command that spoke.

Re: Uptime Powered

Posted: Thu Aug 22, 2019 2:54 pm
by martinsrs
scottwilkerson wrote:
martinsrs wrote:I want it to be critical when it is on for more than 60 days, this command is for when it is less than 60 days on.
Not true, here's my example with a machine that has been up 85 days (more than 60)

Code: Select all

[root@localhost ~]# uptime
 11:44:37 up 85 days,  2:25,  2 users,  load average: 0.35, 0.36, 0.25
[root@localhost ~]# /usr/local/nagios/libexec/check_uptime -c 60 -u days
Uptime CRITICAL: 85 day(s) 2 hour(s) 25 minute(s) | uptime=85.000000;;60.000000;
for clarity, the command for LESS THAN 60 days would be

Code: Select all

/usr/local/nagios/libexec/check_uptime -c 60: -u days
How do I do this in Windows, is it the same thing?
In NSClient it looks like this:
alias_up = checkUpTime MinWarn = 1d MinWarn = 1h
And in Webadmin I passed the command that spoke.

Re: Uptime Powered

Posted: Thu Aug 22, 2019 3:37 pm
by scottwilkerson
martinsrs wrote:How do I do this in Windows, is it the same thing?
No it is definitely different.

something like

Code: Select all

alias_up_60 = check_uptime "crit=uptime > -60d"
https://docs.nsclient.org/reference/win ... eck_uptime