Skip to content

Instantly share code, notes, and snippets.

@Konstantinusz
Last active October 25, 2020 20:25
Show Gist options
  • Save Konstantinusz/334cf96cd5b085f474867ae2d87550ea to your computer and use it in GitHub Desktop.
Save Konstantinusz/334cf96cd5b085f474867ae2d87550ea to your computer and use it in GitHub Desktop.
Hibernációt is figyelmebe vevő uptime
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