tl;dr: make sure libpam-systemd is installed (and that UsePAM is enabled in SSHd's configuration).
Today I wanted to add basic monitoring to a VM I run for work, and I set up munin-node for it -- there's already other VMs using it in the environment, so it's just adding that missing one. However, the users plugin gives bogus data: it always says there's 0 users logged in, which is obviously incorrect. A very quick look at the plugin tells me it leverages the who command. And indeed, that command also fails to list any logged-in users -- which is quite puzzling when you do this from an interactive SSH shell.
I looked up the issue in the web, leading me to a few Debian bugs, some of which seemed interesting: things about utmp being removed from some systemd version (because of year-2038 issues it seems), but reading through suggests it should be fixed in the version I have. Looking some more suggests it's systemd's fault for not supporting utmp, which indeed doesn't report the UTMP flag (systemctl --version). However, checking another VM I have shows that the same versions of coreutils (home of who) and systemd (still without UTMP) do work in that one. Meh? I ended up checking the difference in which packages were installed on both systems, and one package catch my eye: libpam-systemd is present on the working VM but not the failing one. Bingo: installing it solves the problem immediately.
The reason why it wasn't installed is because the VM bootstrap code does not install recommended packages, and libpam-systemd is only recommended by openssh-server and systemd-sysv, it's not a dependency.
I also had been bitten by a similar issue with systemctl not working for non-root (for a custom Munin plugin), which was due to missing DBus, because systemd itself only recommends default-dbus-system-bus. That one was easier to solve, because some people actually did mention the issue I saw was likely due to not having dbus properly running on the machine.
[edit] GuiGui reached out because he had similar issues (see his Debian 12 to 13 upgrade notes, section last, lastlog, wtmp), yet had libpam-systemd installed. It turns out he had disabled UsePAM in SSHd's configuration, which unsurprisingly renders installation of libpam-systemd irrelevant. If you're in the same situation, either enable PAM there (with the attached bagage), or use a workaround like he did.