Best way for monitoring and alerting of running Bluefin version

I installed Bluefin on my family’s computers with the idea that I would have less sysadmin work than with “normal” distros. I was particularly sold on the automatic updates with rollback option.

So far so good. But now I’ve noticed that nobody is rebooting. Which of course ruins the effort again. As a solution I see a reboot reminder to the user, which have 2 weeks old versions running. Plus an alert to me for versions that are 4 weeks old.

Before I write any scripts:

  • Does anyone have any ideas on the best way I could implement this?
  • Are there any good and simple tools for this? (i.e. not a huge tool like Prometheus…)
  • Is something like this already being considered?

Addendum: I am aware of cockpit and rpm-ostree status. But I always have to be active with it. I would like to have an automatic alert that I have to remind the users.

1 Like

A libnotify notification when an image is over X days would likely do the job: Desktop Notifications Specification

See also:

I will look into it, thanks!

Okay … After a lot of googling, duckduckgoing and also some chatgpting I think I have something that works. I also took inspiration from ublue-motd. The issue mentioned above talks about user-motd.sh, which I couldn’t find.

Maybe somebody can take a look at the script and give me feedback? That would be great! I’ll attach it below.

BTW: I specifically didn’t customize ublue-motd as I thought it was something very different after all. What do you think?

But what now?

But now I don’t know how to proceed, as I’m a rooky sysadmin coming from more traditional distros like Debian and only slowly venturing into the atomic distros.

How do I get my script to work on Bluefin? Normally I would create a systemd timer and a unit file. But on a read-only file system… :exploding_head:

Can somebody help me with that?

#!/usr/bin/bash

bluenotify() {
	
	local NOTIFY_TITLE=""
	local NOTIFY_BODY=""
	local NOTIFY_ICON=""
	local NOTIFY_ACTION=""

	case $1 in
		update)
			NOTIFY_TITLE="Update Now"
			NOTIFY_BODY="Your latest available image is over 1 month old. Please update now."
			NOTIFY_ICON="software-update-urgent"
			NOTIFY_ACTION='UPDATE=Update Now'
			;;
		reboot)
			NOTIFY_TITLE="Reboot Now"
			NOTIFY_BODY="There is a newer image available. Just reboot to use it."
			NOTIFY_ICON="system-reboot"
			NOTIFY_ACTION='REBOOT=Reboot Now'
			;;
	esac

    local ACTION=$(notify-send \
		--icon="$NOTIFY_ICON" \
		--urgency=critical \
		--action="$NOTIFY_ACTION" \
		--action=INFO="More Info" \
		"$NOTIFY_TITLE" "$NOTIFY_BODY")
    
	case $ACTION in
		UPDATE)
			xdg-terminal-exec -- bash -c 'ujust update'
			;;
		REBOOT)
			xdg-terminal-exec -- bash -c 'systemctl reboot'
			;;
		INFO)
			xdg-terminal-exec -- bash -c 'rpm-ostree status --booted'
			;;
	esac
}

AVAILABLE_IMAGE_DATE=$(rpm-ostree status --booted | sed -n 's/.*Timestamp: \(.*\)/\1/p')
AVAILABLE_IMAGE_DATE_SECONDS=$(date -d "$AVAILABLE_IMAGE_DATE" +%s)
BOOTED_IMAGE_DATE=$(rpm-ostree status --booted | sed -n 's/.*Version:.*(\(.*\))/\1/p')
BOOTED_IMAGE_DATE_SECONDS=$(date -d "$BOOTED_IMAGE_DATE" +%s)
CURRENT_SECONDS=$(date +%s)

AGE_AVAILABLE_IMAGE=$((CURRENT_SECONDS - AVAILABLE_IMAGE_DATE_SECONDS))
AGE_BOOTED_IMAGE=$((CURRENT_SECONDS - BOOTED_IMAGE_DATE_SECONDS))
DIFF_IMAGES=$((AVAILABLE_IMAGE_DATE_SECONDS - BOOTED_IMAGE_DATE_SECONDS))

MONTH=$((30 * 24 * 60 * 60))
WEEK=$((7 * 24 * 60 * 60))

if [ "$AGE_BOOTED_IMAGE" -lt "$WEEK" ]; then
	exit
elif [ -n "$AVAILABLE_IMAGE_DATE" ] && [ "$AGE_AVAILABLE_IMAGE" -ge "$MONTH" ]; then
	bluenotify update
elif [ -n "$AVAILABLE_IMAGE_DATE" ] && [ "$DIFF_IMAGES" -ge "$WEEK" ]; then
	bluenotify reboot
fi

1 Like

You can do normal systemd stuff in /etc since it is writeable.

any updates on this, both aurora and bluefin desperately requires something like this. the updates are painfully slow as it is already

If someone was working on it it’d be updated in the github ticket.