Uptime Powered

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.
Locked
martinsrs
Posts: 5
Joined: Wed Aug 21, 2019 4:38 pm

Uptime Powered

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Uptime Powered

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
martinsrs
Posts: 5
Joined: Wed Aug 21, 2019 4:38 pm

Re: Uptime Powered

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Uptime Powered

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
martinsrs
Posts: 5
Joined: Wed Aug 21, 2019 4:38 pm

Re: Uptime Powered

Post 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.
martinsrs
Posts: 5
Joined: Wed Aug 21, 2019 4:38 pm

Re: Uptime Powered

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Uptime Powered

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked