-
Notifications
You must be signed in to change notification settings - Fork 103
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
add uptime to hostinfo checkup and tests #1392
Conversation
hc.data["uptime_friendly"] = formatUptime(uptimeRaw) | ||
} | ||
|
||
hc.data["uptime"] = uptimeRaw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be inside that err == nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i assumed it would just be zero value and the friendly would show the error. I can leave unset in that case if you'd like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm never really sure if the return is defined if there's an error. So my bias would be to drop it. (it should be zero, but...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah makes sense, adding to the follow up! thanks
@@ -71,6 +82,34 @@ func hostName() string { | |||
return hostname | |||
} | |||
|
|||
// formatUptime takes a raw uptime value in seconds | |||
// and returns a human friendly relative time string | |||
func formatUptime(uptime uint64) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fancy! I'd take fractional days.
tt := tt | ||
t.Run(tt.name, func(t *testing.T) { | ||
t.Parallel() | ||
if got := formatUptime(tt.uptime); got != tt.want { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine, but we usually use expected
and actual
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 thank you!
This change adds uptime to the Host Info checkup.
It will appear as informational output for doctor/flare as follows:
It will be logged within checkpoints as follows: