uptime: Check seconds_alert against raw seconds (#555)
Originally, uptime checked seconds_alert against seconds to determine whether to use color_alert, but if {days}, {hours}, or {mins} is used in the format string, seconds is truncated to exclude anything above a day, hour, or minute respectively. This caused seconds to always be below a seconds_alert value greater than a day, for example, if {days} is used, so the alert color was never used. Fix this by saving and checking against the raw seconds that were originally read.
This commit is contained in:
parent
414fbe1e5e
commit
3c6d2167e5
@ -34,6 +34,8 @@ class Uptime(IntervalModule):
|
|||||||
with open(self.file, "r") as f:
|
with open(self.file, "r") as f:
|
||||||
seconds = int(float(f.read().split()[0]))
|
seconds = int(float(f.read().split()[0]))
|
||||||
|
|
||||||
|
raw_seconds = seconds
|
||||||
|
|
||||||
days = seconds // (60 * 60 * 24)
|
days = seconds // (60 * 60 * 24)
|
||||||
hours = seconds // (60 * 60)
|
hours = seconds // (60 * 60)
|
||||||
minutes = seconds // 60
|
minutes = seconds // 60
|
||||||
@ -56,7 +58,7 @@ class Uptime(IntervalModule):
|
|||||||
}
|
}
|
||||||
self.data = fdict
|
self.data = fdict
|
||||||
if self.alert:
|
if self.alert:
|
||||||
if seconds > self.seconds_alert:
|
if raw_seconds > self.seconds_alert:
|
||||||
self.color = self.color_alert
|
self.color = self.color_alert
|
||||||
self.output = {
|
self.output = {
|
||||||
"full_text": formatp(self.format, **fdict),
|
"full_text": formatp(self.format, **fdict),
|
||||||
|
Loading…
Reference in New Issue
Block a user