snmptrapd service cannot be enabled on Ubuntu 22.04
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
net-snmp (Ubuntu) |
Expired
|
Undecided
|
Unassigned |
Bug Description
After installing the snmptrapd package by running:
apt -y install snmptrapd
you can start snmptrapd successfully:
systemctl start snmptrapd
however, you won't be able to enable the service. When you try to do so, you get the error below:
# systemctl enable snmptrapd
Synchronizing state of snmptrapd.service with SysV service script with /lib/systemd/
Executing: /lib/systemd/
The unit files have no installation config (WantedBy=, RequiredBy=, Also=,
Alias= settings in the [Install] section, and DefaultInstance= for template
units). This means they are not meant to be enabled using systemctl.
Possible reasons for having this kind of units are:
• A unit may be statically enabled by being symlinked from another unit's
.wants/ or .requires/ directory.
• A unit's purpose may be to act as a helper for some other unit which has
a requirement dependency on it.
• A unit may be started when needed via activation (socket, path, timer,
D-Bus, udev, scripted systemctl call, ...).
• In case of template units, the unit is meant to be enabled with some
instance name specified.
I believe that this is caused by the missing "[Service]" section in the "/usr/lib/
Example:
# cat /usr/lib/
[Unit]
Description=Simple Network Management Protocol (SNMP) Trap Daemon.
[Service]
Type=notify
User=Debian-snmp
ExecStart=
ExecReload=
[Unit]
Description=Simple Network Management Protocol (SNMP) Trap Daemon.
[Service]
Type=notify
User=Debian-snmp
ExecStart=
ExecReload=
This should've been:
[Unit]
Description=Simple Network Management Protocol (SNMP) Trap Daemon.
[Service]
Type=notify
User=Debian-snmp
ExecStart=
ExecReload=
[Unit]
Description=Simple Network Management Protocol (SNMP) Trap Daemon.
[Service]
Type=notify
User=Debian-snmp
ExecStart=
ExecReload=
[Install]
WantedBy=
More info:
# cat /etc/*release
DISTRIB_ID=Ubuntu
DISTRIB_
DISTRIB_
DISTRIB_
PRETTY_NAME="Ubuntu 22.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.1 LTS (Jammy Jellyfish)"
VERSION_
ID=ubuntu
ID_LIKE=debian
HOME_URL="https:/
SUPPORT_URL="https:/
BUG_REPORT_URL="https:/
PRIVACY_
UBUNTU_
# uname -a
Linux test-xi-ubuntu-22 5.15.0-47-generic #51-Ubuntu SMP Thu Aug 11 07:51:15 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
# dpkg -l | grep snmptrapd
ii libnetsnmptrapd
ii snmptrapd 5.9.1+dfsg-
Hello Ludmil and thanks for this bug report. snmptrapd is socket activated, see the
snmptrapd.socket systemd socket unit. I did a very quick test and it seems to be working:
root@paride-j:~# pgrep snmptrapd
root@paride-j:~# echo foo | nc -u -N -q0 127.0.0.1 162
root@paride-j:~# pgrep snmptrapd
1885
If I misinterpreted your bug report please let us know more context on what you're trying to achieve, otherwise if you agree the service activation is working as intended please change the status of this bug to Invalid. I'm marking it as Incomplete for now. Thanks!