included annotations for uptime

main
vitrinekast 8 months ago
parent 8b3b0bceb6
commit 754fb91de3

@ -45,6 +45,18 @@
</div>
<article>
<h2>What happened today?</h2>
<pre>uptime -s</pre>
<p>2024-03-18 07:51:34</p>
<span class="annotation fn-annotatation" level="1">
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.
</span>
<p>the ones below do not have the "right" annotation levels</p>
<pre>last_user_added</pre>
<p>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,14 +225,6 @@ colord:x:130:
</span>
<pre>since_last_boot</pre>
<p>2024-03-05 08:13:37
<span class="annotation fn-annotatation" level="1">
A level 1 annotation for since_last_boot
</span>
<pre>list_package_installs</pre>
<p>2024-03-10 15:16:14 install libtk8.6:armhf <none> 8.6.13-2

@ -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,7 +39,8 @@ 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
)

@ -45,6 +45,18 @@
</div>
<article>
<h2>What happened today?</h2>
<pre>uptime -s</pre>
<p>{{ since_last_boot }}</p>
{% if since_last_boot is defined %}
<span class="annotation fn-annotatation" level="1">
{% 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 %}
</span>
{% endif %}
<p>the ones below do not have the "right" annotation levels</p>
<pre>last_user_added</pre>
<p>{{last_user_added}}
{% if last_user_added is defined %}
@ -85,15 +97,6 @@
(no input)
{% endif %}
<pre>since_last_boot</pre>
<p>{{since_last_boot}}
{% if since_last_boot is defined %}
<span class="annotation fn-annotatation" level="1">
A level 1 annotation for since_last_boot
</span>
{% else %}
(no input)
{% endif %}
<pre>list_package_installs</pre>
<p>{{list_package_installs}}

Loading…
Cancel
Save