Pre-install crisis diagnostic tools on Ubuntu 24.04 and Rocky 9
Install sysstat, bpftrace, bcc and perf before an outage. Package names, versions, disk space and sar collection defaults compared on Ubuntu 24.04 and Rocky 9.
Once a server is crawling or its network is gone, pulling tools with apt or dnf gets hard, so diagnostic tools belong on the box beforehand. The same set was installed in Ubuntu 24.04 and Rocky 9 containers to compare package names, versions, space used and the state right after installation.
[1] Map the package names first. The same tool can have a different name, and one was missing from Rocky's default repositories.
| Purpose | Ubuntu 24.04 package (version) | Rocky 9 package (version) |
|---|---|---|
sar, iostat, mpstat, pidstat | sysstat 12.6.1 | sysstat 12.5.4 |
vmstat, top, free | procps 4.0.4 | procps-ng 3.3.17 |
| Per-process disk I/O | iotop-c 1.26 | iotop 0.6 |
| System call tracing | strace 6.8 | strace 6.12 |
| Packet capture | tcpdump 4.99.4 | tcpdump 4.99.0 |
| eBPF one-liners | bpftrace 0.20.2 | bpftrace 0.24.2 |
| eBPF tool collection | bpfcc-tools 0.29.1 (128 *-bpfcc) | bcc-tools 0.35.0 (130 entries in tools/) |
| CPU profiling | linux-tools-common + per-kernel package | perf 5.14.0-687.60.1 |
| NIC settings and stats | ethtool 6.7 | ethtool 6.15 |
| Open files | lsof 4.95 | lsof 4.94 |
| NIC utilisation | nicstat 1.95 | Not in default repos |
| Kernel event tracing | trace-cmd 3.2 | trace-cmd 3.3.1 |
| NUMA | numactl 2.0.18 | numactl 2.0.19 |
ss, ip | iproute2 6.1.0 | iproute 6.17.0 |
A single unknown name makes the whole dnf install stop, as it did here:
$ dnf -y -q --setopt=install_weak_deps=False install sysstat procps-ng iotop strace tcpdump bpftrace bcc-tools ethtool lsof nicstat trace-cmd numactl iproute perf > /tmp/inst.log 2>&1; tail -3 /tmp/inst.logError: Unable to find a match: nicstat[2] Install them, without recommended/weak dependencies.
$ sudo apt install --no-install-recommends sysstat procps iotop-c strace tcpdump bpftrace bpfcc-tools ethtool lsof nicstat trace-cmd numactl iproute2 linux-tools-common linux-tools-$(uname -r)$ sudo dnf --setopt=install_weak_deps=False install sysstat procps-ng iotop strace tcpdump bpftrace bcc-tools ethtool lsof trace-cmd numactl iproute perfOn Ubuntu, perf only runs with the linux-tools-<kernel version> package matching the running kernel. With the common package alone you get this (the container sees the host kernel, so no per-kernel package was installed):
$ perf --versionWARNING: perf not found for kernel 6.8.0-147 You may need to install the following packages for this specific kernel: linux-tools-6.8.0-147-generic linux-cloud-tools-6.8.0-147-generic…To have the matching linux-tools follow every kernel upgrade, keep linux-tools-generic installed, as the message suggests.
[3] Plan the disk space. The total of /usr, /var and /etc was measured before and after (du -sxm, so the unit is MiB):
| Before | After | Added | |
|---|---|---|---|
Ubuntu 24.04 (without the per-kernel linux-tools-<version>) | 134 MiB | 466 MiB | 332 MiB |
| Rocky 9 (without nicstat) | 303 MiB | 716 MiB | 413 MiB |
The Ubuntu row is the command in [2] minus linux-tools-$(uname -r); on a real server that package adds to the total.
Most of it is compiler machinery pulled in by the eBPF tools. The largest packages were libllvm18 and libclang-cpp18 on Ubuntu and gcc-toolset-15-gcc, llvm-libs and clang-libs on Rocky. On small VMs, drop bpfcc-tools/bcc-tools and keep only bpftrace.
[4] Make sure sar history is actually recorded. Live sar sampling works right after installation, but looking back in time needs collection to be running:
$ sar 2>&1 | head -2Cannot open /var/log/sysstat/sa27: No such file or directoryPlease check if data collecting is enabledThat was the Ubuntu container; on Rocky the path is /var/log/sa/. The two differed right after installation:
| Ubuntu 24.04 | Rocky 9 | |
|---|---|---|
| systemd units | Links created for sysstat.service, sysstat-collect.timer, sysstat-summary.timer | All three enabled |
| Extra switch | ENABLED="false" in /etc/default/sysstat | None |
| Data directory | /var/log/sysstat/ | /var/log/sa/ |
Unpacking the Ubuntu package shows two collection paths. Under systemd, sysstat-collect.timer starts sysstat-collect.service, which runs /usr/lib/sysstat/sa1 directly, and sa1 does not look at ENABLED. ENABLED is read by the cron path's /usr/lib/sysstat/debian-sa1 (which exits unless it is true) and by the package's configuration script, which enables or disables the three units (sysstat-collect.timer, sysstat-summary.timer, sysstat.service) to match it. So on a systemd server, whether collection runs is decided by the timer state. systemd does not run in a container, so whether the timer is on right after installation on a real server was not verified.
$ systemctl is-enabled sysstat-collect.timer sysstat-summary.timer sysstat$ systemctl is-active sysstat-collect.timer$ ls -l /var/log/sysstat/Note the output of the first two lines before changing anything. If the timer is disabled or inactive, turn it on. So that a later package reconfigure or upgrade does not switch it off again, set ENABLED in /etc/default/sysstat to "true" as well (the file's comment allows only true and false; the debconf value sysstat/enable was also false after installation).
$ sudo sed -i 's/^ENABLED="false"/ENABLED="true"/' /etc/default/sysstat$ sudo systemctl enable --now sysstat-collect.timer sysstat-summary.timer sysstatThe timer fires every 10 minutes, so after about 20 minutes check for an saDD file in /var/log/sysstat/. To undo, return to the state you noted with sudo systemctl disable --now sysstat-collect.timer sysstat-summary.timer and ENABLED="false". On Rocky the three units were already enabled; if they are off, use sudo systemctl enable --now sysstat.
[5] Write down the order you will use during an incident. With these installed, memory problems can be traced through the journal as in find what the OOM killer killed, CPU and disks with sar -u, sar -d and iostat -x 1, and individual processes with pidstat 1 and iotop-c.