Bug 718183

Summary: Provide native systemd unit file
Product: [Fedora] Fedora Reporter: Jóhann B. Guðmundsson <johannbg>
Component: net-snmpAssignee: Jan Safranek <jsafrane>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 16CC: jsafrane
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: net-snmp-5.7-6.fc16 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-08-22 11:02:43 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 713562    
Description Flags
Native systemd service file for snmp
Native systemd service file for snmptrap none

Description Jóhann B. Guðmundsson 2011-07-01 06:12:10 EDT
Description of problem:


Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
Actual results:

Expected results:

Additional info:
Comment 1 Jóhann B. Guðmundsson 2011-07-01 06:12:59 EDT
Created attachment 510838 [details]
Native systemd service file for snmp
Comment 3 Jan Safranek 2011-08-03 08:20:14 EDT
*** Bug 695584 has been marked as a duplicate of this bug. ***
Comment 4 Jan Safranek 2011-08-04 08:38:16 EDT
This turns out to be more complicated than simple .service file. Snmpd daemonizes itself in a way it confuses systemd. There can be (very short) time after main process exits and the .pid file is created by a forked child -> systemd assumes the service died and kills it.

I'll try to rewrite snmpd not to fork and to send notification to systemd after  initialization (via sd_notify). This will take some time though, especially passing it upstream.
Comment 5 Jóhann B. Guðmundsson 2011-08-04 09:05:03 EDT

I'm unable to duplicate this both snmpd and snmptrapd service start and stop cleanly. 

Does this happen in some oddball cases just wondering if those service files wont suffice until the fix is brought in via update.
Comment 6 Jóhann B. Guðmundsson 2011-08-04 09:13:49 EDT
Would switching to Type=oneshot suffice as a workaround for this as in.. 

# snmpd.service 

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

ExecStart=/usr/sbin/snmpd -LS0-6d -Lf /dev/null -p /var/run/snmpd.pid


# snmptrapd.service

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

ExecStart=/usr/sbin/snmptrapd -Lsd -p /var/run/snmptrapd.pid


Remembert to restart the daemon when testing this as in 

systemctl daemon-reload
systemctl stop snmpd.service snmptrapd.service 
systemctl start snmpd.service snmptrapd.service
systemctl status snmpd.service snmptrapd.service
Comment 7 Jan Safranek 2011-08-04 09:40:28 EDT
Problem is the snmpd service. It forks twice to detach from terminal as usual daemons do. But instead of the grand-parent to wait until everything initializes in the children (and return proper exit code), snmpd grand-parent exits immediately. The .pid file is written by the child of the second fork. And now we have a race - if systemd processes the parent process SIGCHLD *before* the child creates the pid file, systemd assumes the daemon is dead and kills everything.

This happens only sometimes and it took me some time to find out what is going on, systemd could log something on higher log level...

Anyway, as a workaround, I can use snmpd -f (= do not fork) and service type 'simple', but if there is some service depending on snmpd (like subagents), it could get started before snmpd creates its listening sockets, so I am adding support for 'notify' service type. The code is simple, still it requires some testing and pushing upstream....
Comment 8 Fedora Update System 2011-08-09 08:20:38 EDT
net-snmp-5.7-5.fc16 has been submitted as an update for Fedora 16.
Comment 9 Jan Safranek 2011-08-09 08:27:22 EDT
Please test carefully... I've checked systemd integration into upstream git and patched F16 and rawhide packages. New Net-SNMP version will be released after F16 is out, so Fedora is a bit ahead, but it has always been on the bleeding edge :).
Comment 10 Fedora Update System 2011-08-09 17:53:23 EDT
Package net-snmp-5.7-5.fc16:
* should fix your issue,
* was pushed to the Fedora 16 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing net-snmp-5.7-5.fc16'
as soon as you are able to.
Please go to the following url:
then log in and leave karma (feedback).
Comment 11 Jóhann B. Guðmundsson 2011-08-10 19:01:39 EDT
Note that you forgot to drop the legacy sysv init script or package the legacy sysv init script in a separate sub package as stated by the guidelines ( follow links in comment 2 for details )
Comment 12 Jan Safranek 2011-08-11 04:39:54 EDT
Damn guidelines :). Thanks for heads up.
Comment 13 Fedora Update System 2011-08-11 04:58:59 EDT
net-snmp-5.7-6.fc16 has been submitted as an update for Fedora 16.
Comment 14 Fedora Update System 2011-08-12 00:22:41 EDT
Package net-snmp-5.7-6.fc16:
* should fix your issue,
* was pushed to the Fedora 16 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing net-snmp-5.7-6.fc16'
as soon as you are able to.
Please go to the following url:
then log in and leave karma (feedback).
Comment 15 Fedora Update System 2011-08-22 11:02:33 EDT
net-snmp-5.7-6.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.