From 9e24489a4f45e3d282a765505d787d92c17ea838 Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Fri, 1 Mar 2024 00:42:24 +0000 Subject: [PATCH] Add lastplot script that parses last, graphs reboots over time --- lastplot | 18 ++++++++++++++++++ pacplot | 1 + 2 files changed, 19 insertions(+) create mode 100755 lastplot diff --git a/lastplot b/lastplot new file mode 100755 index 0000000..7f04ff9 --- /dev/null +++ b/lastplot @@ -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() diff --git a/pacplot b/pacplot index 41c6a21..88048c1 100755 --- a/pacplot +++ b/pacplot @@ -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()