Last active
October 25, 2020 20:25
-
-
Save Konstantinusz/334cf96cd5b085f474867ae2d87550ea to your computer and use it in GitHub Desktop.
Hibernációt is figyelmebe vevő uptime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "time" | |
wu=%x{journalctl -b 0 -r|grep -i "Waking up from hibernate" -m 1} | |
li=%x{journalctl -b 0 -r|grep -i "Reached target Graphical Interface" -m 1} | |
t = (wu!="" ? wu : li).split[0..2].join(" ") | |
seconds=(Time.now-Time.parse(t)).round | |
d=seconds / (3600*24) | |
if d==0 then | |
puts "up: %02d hour, %02d min" % [(seconds-3600*24*(d)) / 3600, (seconds-3600*24*(d)) / 60 % 60, (seconds-3600*24*(d)) % 60] | |
else | |
puts "up: %01d day, %02d hour, %02d min" % [d, (seconds-3600*24*(d)) / 3600, (seconds-3600*24*(d)) / 60 % 60, (seconds-3600*24*(d)) % 60] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment