Skip to content

check_uptime: Add option to report uptime in days instead of seconds #1750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2022

Conversation

amotl
Copy link
Contributor

@amotl amotl commented Feb 12, 2022

Dear community. Dear @wopfel and @sni.

Firsts things first: Thanks a stack for conceiving and maintaining this excellent collection of monitoring plugins.

This is a humble patch for the check_uptime.pl sensor to make it report the system uptime in days instead of seconds. It has been wired to a new --days option, in order not to change its default behavior.

The rationale is to reduce mental load for humans, when looking at the textual output of the sensor. While the "pretty" format already implemented by check_uptime.pl has good intentions, it didn't quite nail it for us.

With kind regards,
Andreas.


Previous situation

Currently, the baseline plugin output, with no way to change it, is:

CRITICAL: Uptime is 38829029 seconds.

We also tried using both options --for and --since. However, we still have not been happy with the corresponding output.

image

New situation

When using the proposed --days|-d option, the output will be:

CRITICAL: Uptime is 449 days.

In our opinion, this is much more pleasant.

image

@sni
Copy link
Contributor

sni commented Feb 14, 2022

Looks good. Could you please add a help entry as well?

Copy link
Contributor

@sni sni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine. Except, please add a help entry for the new option.

@amotl amotl force-pushed the amo/uptime-as-days branch 2 times, most recently from 9681e24 to 70a17f8 Compare February 15, 2022 00:38
@amotl
Copy link
Contributor Author

amotl commented Feb 15, 2022

Dear Sven,

thank you for the quick reply. I've just amended this patch according to your suggestions and also added a corresponding test case. Fixing a one-letter typo has been diverted to #1751.

With kind regards,
Andreas.

@amotl amotl requested a review from sni February 15, 2022 00:44
Copy link
Contributor

@sni sni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix the last typo

@@ -262,6 +274,7 @@ ()
print "-c (--critical) = Min. number of uptime to generate critical alert ( w < c )\n";
print "-f (--for) = Show uptime in a pretty format (Running for x weeks, x days, ...)\n";
print "-s (--since) = Show last boot in yyyy-mm-dd HH:MM:SS format (output from 'uptime -s')\n";
print "-s (--days) = Show uptime in days\n";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be -d i guess?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh my, it was late at night ;]. Thanks. Fixed!

Currently, the plugin output is:

  CRITICAL: Uptime is 38829029 seconds.

When using the proposed `--days|-d` option, it will be:

  CRITICAL: Uptime is 449 days.
@amotl amotl force-pushed the amo/uptime-as-days branch from 70a17f8 to 3b79309 Compare February 15, 2022 09:39
@amotl amotl requested a review from sni February 15, 2022 11:27
@sni sni merged commit c99a166 into monitoring-plugins:master Feb 15, 2022
@sni
Copy link
Contributor

sni commented Feb 15, 2022

great, thanks.

@amotl amotl deleted the amo/uptime-as-days branch February 15, 2022 15:17
@amotl amotl restored the amo/uptime-as-days branch February 15, 2022 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants