Skip to content

Refactor sysinfo#12

Open
seven-beep wants to merge 20 commits into
ldidry:mainfrom
seven-beep:main
Open

Refactor sysinfo#12
seven-beep wants to merge 20 commits into
ldidry:mainfrom
seven-beep:main

Conversation

@seven-beep

Copy link
Copy Markdown

Sorry, but could you rebase your modifications on the main branch?

Here we go :)

original message:

I am not sure all will interest you but I have passed a few hours to refactor the sysinfo python script for my own usage :

  • use python3
  • dropped utmp for a more trivial output with the command "who"
  • use the findmnt command to filter the mounts and produce a more compact output
  • added error handling on theses statfs calls
  • restored the ip of the main interface
  • use a main function

Comment thread README.md Outdated

```
apt-get install figlet lsb-release python3-utmp bc
apt-get install figlet lsb-release bc

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

findmnt is in util-linux, could you add it, please?

Comment thread update-motd.d/sysinfo.py Outdated
"--noheading",
"--real",
"--uniq",
"--fstab",

@ldidry ldidry Nov 26, 2024

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With --fstab, you won’t show disks mounted with systemd mount units.

@ldidry

ldidry commented Nov 26, 2024

Copy link
Copy Markdown
Owner

To be honest, I don’t like displaying the IP address in the banner. You choose to display only one IP address into the many possibles (it may not suite all users) and ip route list dev won’t work on IPv6-only machines.

And I prefer having multiple login showing, with their IP address and time, as:

  • it allows me to know if I’m already logged
  • it allows me to see all the IP addresses of those connections (better for security)
  • if a co-worker has an old session on the server, I can ask them if it’s on purpose or if they can logout, allowing me, for ex., to reboot the server

We may have a config file to change the behavior of the script, like the hushlogin file.

@seven-beep

seven-beep commented Dec 2, 2024 via email

Copy link
Copy Markdown
Author

Initially I used this argument as I work with systems with a lot of bind mounts
and it felt unnecessary to list them all, eg:

  Mount points                         Disk usage       Inodes usage
 /                                   49%  of 19.3G     12.8% of 1299984
 /rw                                 35%  of 20.5G     26.3% of 1373568
 /home                               35%  of 20.5G     26.3% of 1373568
 /usr/local                          35%  of 20.5G     26.3% of 1373568
 /var/spool/cron                     35%  of 20.5G     26.3% of 1373568
 /etc/hosts                          35%  of 20.5G     26.3% of 1373568
 /var/lib/systemd/timers             35%  of 20.5G     26.3% of 1373568
 /var/lib/plocate                    35%  of 20.5G     26.3% of 1373568
 /var/lib/containerd                 35%  of 20.5G     26.3% of 1373568
 /etc/docker                         35%  of 20.5G     26.3% of 1373568
 /var/lib/docker                     35%  of 20.5G     26.3% of 1373568
 /home/user/.emacs.d/elpa            2%   of 3.9G      2.4% of 262144
 /rw/home/user/.emacs.d/elpa         2%   of 3.9G      2.4% of 262144
 /proc/xen                           -    of 0         100.0% of 00

However it seems impossible to filter theses mounts in one call,
(https://unix.stackexchange.com/questions/430074/how-to-exclude-bind-mounts-from-findmnt-results-list)
and --fstab is a bad compromise as mounts points may be declared in many others
ways than /etc/fstab.
@seven-beep

seven-beep commented Jan 28, 2025 via email

Copy link
Copy Markdown
Author

A filesystem may freeze the script if it is not accessible.

This had for effect to block ssh access in case of an indisponible remote
filesystem.
seven-beep added 2 commits May 2, 2026 10:51
apt will output something like 'Listing ... Done' which was counted as a package.
/var/run/reboot-required may be touched for other reasons that a pending kernel update.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants