Add lastplot script that parses last, graphs reboots over time
This commit is contained in:
parent
b2a0acfdcd
commit
9e24489a4f
18
lastplot
Executable file
18
lastplot
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# Graph the reboots by parsing the last command
|
||||
|
||||
from datetime import datetime
|
||||
from matplotlib import pyplot as plt
|
||||
from subprocess import check_output
|
||||
|
||||
|
||||
x = []
|
||||
lines = check_output('last --time-format iso | grep reboot | tr -s " " | cut -d " " -f5', shell=True).decode('utf-8')
|
||||
for line in lines.split('\n')[:-1]:
|
||||
x.append(datetime.fromisoformat(line))
|
||||
|
||||
|
||||
plt.hist(x, bins=200)
|
||||
plt.savefig('last.png')
|
||||
plt.show()
|
Loading…
Reference in a new issue