19 lines
436 B
Python
Executable file
19 lines
436 B
Python
Executable file
#!/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()
|