diff --git a/output.html b/output.html index e05445a..b3e04f9 100644 --- a/output.html +++ b/output.html @@ -45,6 +45,18 @@

What happened today?

+ +
uptime -s
+

2024-03-18 07:51:34

+ + + This is common, the fragility of these machines are more prominant than any cloud user expects. Partially because of scale, partially because a lot of labour that happen in datacenters just escapes us all when we want to just upload an image. + + + + +

the ones below do not have the "right" annotation levels

+
last_user_added

Feb 29 15:08:48 chopchop useradd[8744]: new user: name=colord, UID=118, GID=130, home=/var/lib/colord, shell=/usr/sbin/nologin, from=/dev/pts/4 @@ -72,7 +84,7 @@ [ - ] console-setup.sh [ + ] cron [ + ] cups - [ - ] cups-browsed + [ + ] cups-browsed [ + ] dbus [ + ] dphys-swapfile [ + ] exim4 @@ -213,15 +225,7 @@ colord:x:130: -

since_last_boot
-

2024-03-05 08:13:37 - - - - A level 1 annotation for since_last_boot - - - +

list_package_installs

2024-03-10 15:16:14 install libtk8.6:armhf 8.6.13-2 2024-03-10 15:16:14 status half-installed libtk8.6:armhf 8.6.13-2 diff --git a/script.py b/script.py index afe390e..f6792d4 100644 --- a/script.py +++ b/script.py @@ -1,13 +1,16 @@ from jinja2 import Environment, FileSystemLoader - -## Getting the data import subprocess +from datetime import datetime + +today = datetime.today() last_user_added = subprocess.run(["sudo", "journalctl","_COMM=useradd","-r","-n", "1" , "--output-fields=MESSAGE"], capture_output=True).stdout.decode('UTF-8') users_created_today = subprocess.run(["sudo", "journalctl", "-S","today","_COMM=useradd","-r","-n","1","--output-fields=MESSAGE"], capture_output=True).stdout.decode('UTF-8') list_active_services = subprocess.run(["sudo", "service", "--status-all"], capture_output=True).stdout.decode('UTF-8') list_groups = subprocess.run(["getent","group"], capture_output=True).stdout.decode('UTF-8') -since_last_boot = subprocess.run(["uptime","-s"], capture_output=True).stdout.decode('UTF-8') +since_last_boot = subprocess.run(["uptime","-s"], capture_output=True).stdout.decode('UTF-8').strip() +slb_date = datetime.strptime(since_last_boot, "%Y-%m-%d %H:%M:%S") +time_since_last_boot = today - slb_date list_package_installs = subprocess.run(["grep", 'install', "/var/log/dpkg.log"], capture_output=True).stdout.decode('UTF-8') list_package_upgrade = subprocess.run(["grep", 'upgrade', "/var/log/dpkg.log"], capture_output=True).stdout.decode('UTF-8') list_package_remove = subprocess.run(["grep", 'remove', "/var/log/dpkg.log"], capture_output=True).stdout.decode('UTF-8') @@ -36,9 +39,10 @@ output = template.render( device_info=device_info, debian_version=debian_version, kernel_version=kernel_version, - hostname=hostname + hostname=hostname, + days_since_last_boot = time_since_last_boot.days ) with open("output.html", "w") as f: - print(output, file=f) + print(output, file=f) \ No newline at end of file diff --git a/templates/template.jinja b/templates/template.jinja index 298d8a6..10cc80c 100644 --- a/templates/template.jinja +++ b/templates/template.jinja @@ -45,6 +45,18 @@

What happened today?

+ +
uptime -s
+

{{ since_last_boot }}

+ {% if since_last_boot is defined %} + + {% if days_since_last_boot|int > 15 %}This is unusual, we are used to ...{% else %}This is common, the fragility of these machines are more prominant than any cloud user expects. Partially because of scale, partially because a lot of labour that happen in datacenters just escapes us all when we want to just upload an image.{% endif %} + + {% endif %} + + +

the ones below do not have the "right" annotation levels

+
last_user_added

{{last_user_added}} {% if last_user_added is defined %} @@ -85,16 +97,7 @@ (no input) {% endif %} -

since_last_boot
-

{{since_last_boot}} - {% if since_last_boot is defined %} - - A level 1 annotation for since_last_boot - - {% else %} - (no input) - {% endif %} - +

list_package_installs

{{list_package_installs}} {% if list_package_installs is defined %}