← Back to Docs

How to monitor available package updates

Use Monibot to monitor available software updates for your servers.

Keeping your server up-to-date

If you are running a server, it is important that you keep it updated. For Linux, that means you have to run your package manager's update mechanism often enough so that your server stays up-to-date and secure. In this article, we'll use the apt system found on Debian-based distributions (Debian, Ubuntu, Linux-Mint, etc.) for illustration purposes.

To show available package updates, you would normally run the following commands:

root:~# apt update
root:~# apt list --upgradable
Listing... Done
linux-image-amd64/oldoldstable,oldoldstable 4.19+105+deb10u21 amd64 [upgradable from: 4.19+105+deb10u20]
N: There are 2 additional versions. Please use the '-a' switch to see them.

The apt update command is used to update the local package database. The apt list --upgradable command then lists all package that can be upgraded now. In the example above, one update (a new Linux image) is available. You, as a server administrator, can now decide if you want to install the new packages or not.

To keep your server up-to-date, you have to check regularly, for example once a day, for available package updates. This process is time-consuming, so let's automate it with Monibot.

Create a Monibot metric

Let's create a metric that monitors the number of upgradable packages.

  • Log into Monibot and click the 'Metrics' menu.
  • Click the 'New Metric' button. Enter a name for the metric, e.g. 'Package Updates'. You can chose any name here, it's used only for display.
  • As metric type, select 'Gauge'. A gauge is a numeric value that can go up and down, which is what we want for the number of upgradable packages.
  • Click 'Save'. Monibot creates the metric and assigns a unique ID to it, the metric ID. You will need that later.

Send metric values to Monibot

To send values for the 'Package Updates' metric, you can use the curl command or our moni command line tool, which we'll use in the following.

As root, create a 'packages.sh' script with the following content:


# update local package db
apt update

# initialize api key and metric id - please replace with your values

# get number of updates and store it in PACKAGES variable
PACKAGES=$(apt list --upgradable | grep upgradable  | wc -l)

# use moni 'set' command to upload value to Monibot

This script will get the number of upgradable apt packages and send it to the 'Package Updates' metric.

Now put the script in your root's crontab, so that it is executed automatically, for example once per hour.

root:~# crontab -l
# m h   dom mon dow   command
0  *    *   *   *     /root/packages.sh

From now on, Monibot will show the number of available package updates as a metric. When the metric shows a value of 1 or more, you know you'll have to log in to your server and start an update.

Made and hosted in Germany
© 2024 monibot.io