Red Hat Bugzilla – Bug 125004
snmpd still logs to old file after logrotate runs
Last modified: 2007-11-30 17:10:43 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040510
Description of problem:
I've noticed this on different Red Hat & Fedora versions.
It seems snmpd would need to be restarted in order to prevent it from
logging to an archived log file after logrotate runs.
The following is what I have done on my servers to remedy the
situation. This will restart snmpd if it is running at the time,
causing it to begin logging to a "new" snmpd.log file.
Modify /etc/logrotate.d/snmpd to appear as...
(Note, this is adding three lines, "postrotate" thru "endscript")
/sbin/service snmpd condrestart 2> /dev/null > /dev/null || true
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Install & enable snmpd
2. Query your machine via snmp
3. Allow logrotate to rotate snmpd logs as usual
4. Query your machine again via snmp
5. Look at log files (/var/log/snmpd.log*)
Actual Results: Originally logs to /var/log/snmpd.log.
After log rotation, continues to log to the same inode, which has
become a different filename (/var/log/snmpd.log.1).
Expected Results: Logging should have gone to the new "snmpd.log"
file after rotation.
-rw-r--r-- 1 root root 169 Jun 1 18:00 snmpd.log.1
-rw-r--r-- 1 root root 0 May 22 00:03 snmpd.log
(Log rotation moved original snmpd.log to snmpd.log.1, then created a
new snmpd.log... meanwhile snmpd continues to write to the
snmpd.log.1 file, because it kept the same inode/filehandle when it
Created attachment 100771 [details]
fixed in net-snmp-5.1.2-11