Add lastplot script that parses last, graphs reboots over time

This commit is contained in:
Anthony Wang 2024-03-01 00:42:24 +00:00
parent b2a0acfdcd
commit 9e24489a4f
Signed by: a
SSH key fingerprint: SHA256:B5ADfMCqd2M7d/jtXDoihAV/yfXOAbWWri9+GdCN4hQ
2 changed files with 19 additions and 0 deletions

18
lastplot Executable file
View 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()

View file

@ -34,4 +34,5 @@ print('Currently installed packages:', cnt)
print('Total installed packages:', installed)
print('Total removed packages:', removed)
plt.plot(x, y)
plt.savefig('pac.png')
plt.show()