When I start Net-SNMP from systemd, there is no error message but the daemon does not run:

% sudo systemctl start snmpd

When I start it from the command line, it runs:

% sudo /usr/sbin/snmpd

and answers to SNMP queries.

If I add the debug flags (-LSdd), I see that the daemon launched by systemd is killed immediately after:

Apr  7 15:37:50 localhost snmpd[1298]: NET-SNMP version 5.7.2
Apr  7 15:37:50 localhost snmpd[1298]: Received TERM or STOP signal...  shutting down...

The service file is the default one of the Arch Linux package:

Description=Simple Network Management Protocol (SNMP) Daemon
After=syslog.target network.target

ExecReload=/bin/kill -HUP $MAINPID


If I add RemainAfterExit=yes in the service file, snmpd works but the machine no longer starts properly (no DHCP client, for instance)

The system is an up-to-date Arch Linux, the version of the package is:

Name           : net-snmp
Version        : 5.7.2-3

There is an old Arch Linux bug report apparently for this very bug: https://bugs.archlinux.org/task/32258?string=snmp&project=1&type%5B0%5D=&sev%5B0%5D=&pri%5B0%5D=&due%5B0%5D=&reported%5B0%5D=&cat%5B0%5D=&status%5B0%5D=open&percent%5B0%5D=&opened=&dev=&closed=&duedatefrom=&duedateto=&changedfrom=&changedto=&openedfrom=&openedto=&closedfrom=&closedto=


1 Answer 1


The problem comes from the fork of snmpd during start.

My service file (for Exherbo) forces snmpd to not use fork() (-f) and run the service with Type=simple.

Type=forking is the good way for the default behavior of snmpd, but it is incomplete.

It is highly recommended to specify PIDFile when using Type=forking because systemd is not always able to know which process to monitor after the first process exits.

Just add this:

ExecStart=/usr/sbin/snmpd -p /var/run/snmpd.pid

This change will also fix ExecReload.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.