<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0">
<channel>
<title>Fun with ones and zeros - systemd</title>
<description><![CDATA[Barry's notes on computer software and hardware]]></description>
<link>/blog/tags/systemd</link>
<lastBuildDate>Thu, 30 Apr 2026 02:38:13 -0700</lastBuildDate>
<item>
<title>Decrease snmpd logging level on Ubuntu 18.04</title>
<link>/blog/entries/decrease-snmpd-logging-on-ubuntu-18-04</link>
<pubDate>Sun, 01 Mar 2020 08:45:00 -0800</pubDate>
<author>bp@barryp.org (Barry Pederson)</author>
<description><![CDATA[<body><p>I recently updated some servers from Ubuntu 16.04 to 18.04, and found that
the <code>snmpd</code> daemon was generating way too many log entries
in <code>/var/log/syslog</code> - one for every SNMP query coming from our monitoring system.  </p>
<p>In older Ubuntus I had edited <code>/etc/defaults/snmpd</code> to change the <code>SNMPDOPTS</code> line
to have a different <code>-Ls</code> parameter, but it seems that on the new Ubuntu, the
systemd service for snmp doesn't use that <code>defaults</code> file at all.  A comment
on this <a href="https://serverfault.com/questions/310640/reduce-snmpd-logging-verbosity">serverfault question</a>
gave me a clue on how to fix it in systemd - I thought I'd elaborate here.</p>
<p>If you run </p>
<pre><code>systemctl cat snmpd.service</code></pre>
<p>You see the current service file:</p>
<div class="source"><pre><span></span><span class="c1"># /lib/systemd/system/snmpd.service</span>
<span class="k">[Unit]</span>
<span class="na">Description</span><span class="o">=</span><span class="s">Simple Network Management Protocol (SNMP) Daemon.</span>
<span class="na">After</span><span class="o">=</span><span class="s">network.target</span>
<span class="na">ConditionPathExists</span><span class="o">=</span><span class="s">/etc/snmp/snmpd.conf</span>

<span class="k">[Service]</span>
<span class="na">Environment</span><span class="o">=</span><span class="s">"MIBSDIR=/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf:/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp"</span>
<span class="na">Environment</span><span class="o">=</span><span class="s">"MIBS="</span>
<span class="na">Type</span><span class="o">=</span><span class="s">simple</span>
<span class="na">ExecStartPre</span><span class="o">=</span><span class="s">/bin/mkdir -p /var/run/agentx</span>
<span class="na">ExecStart</span><span class="o">=</span><span class="s">/usr/sbin/snmpd -Lsd -Lf /dev/null -u Debian-snmp -g Debian-snmp -I -smux,mteTrigger,mteTriggerConf -f</span>
<span class="na">ExecReload</span><span class="o">=</span><span class="s">/bin/kill -HUP $MAINPID</span>

<span class="k">[Install]</span>
<span class="na">WantedBy</span><span class="o">=</span><span class="s">multi-user.target</span>
</pre></div>
<p>I wanted to override the ExecStart line with something different.  To do that, run</p>
<pre><code>systemctl edit snmpd.service</code></pre>
<p>This brings up your default editor with a <em>blank</em> file.  I entered these new lines:</p>
<div class="source"><pre><span></span><span class="c1"># Override default "-Lsd" paramter to "-LSwd" to decrease logging level</span>
<span class="k">[Service]</span>
<span class="na">ExecStart</span><span class="o">=</span>
<span class="na">ExecStart</span><span class="o">=</span><span class="s">/usr/sbin/snmpd -LSwd -Lf /dev/null -u Debian-snmp -g Debian-snmp -I -smux,mteTrigger,mteTriggerConf -f</span>
</pre></div>
<p>The first <code>ExecStart=</code> line is a bit odd, without it you get an error:</p>
<pre><code>snmpd.service: Service has more than one ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.</code></pre>
<p>so the first line 'clears' the setting before processing your own version.</p>
<p>Save your file (<code>systemctl edit</code> stores it as <code>/etc/systemd/system/snmpd.service.d/override.conf</code>), and then run
<code>service snmpd restart</code> to have take effect. If you re-run <code>systemctl cat snmpd.service</code> you should now see:</p>
<div class="source"><pre><span></span><span class="c1"># /lib/systemd/system/snmpd.service</span>
<span class="k">[Unit]</span>
<span class="na">Description</span><span class="o">=</span><span class="s">Simple Network Management Protocol (SNMP) Daemon.</span>
<span class="na">After</span><span class="o">=</span><span class="s">network.target</span>
<span class="na">ConditionPathExists</span><span class="o">=</span><span class="s">/etc/snmp/snmpd.conf</span>

<span class="k">[Service]</span>
<span class="na">Environment</span><span class="o">=</span><span class="s">"MIBSDIR=/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf:/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp"</span>
<span class="na">Environment</span><span class="o">=</span><span class="s">"MIBS="</span>
<span class="na">Type</span><span class="o">=</span><span class="s">simple</span>
<span class="na">ExecStartPre</span><span class="o">=</span><span class="s">/bin/mkdir -p /var/run/agentx</span>
<span class="na">ExecStart</span><span class="o">=</span><span class="s">/usr/sbin/snmpd -Lsd -Lf /dev/null -u Debian-snmp -g Debian-snmp -I -smux,mteTrigger,mteTriggerConf -f</span>
<span class="na">ExecReload</span><span class="o">=</span><span class="s">/bin/kill -HUP $MAINPID</span>

<span class="k">[Install]</span>
<span class="na">WantedBy</span><span class="o">=</span><span class="s">multi-user.target</span>

<span class="c1"># /etc/systemd/system/snmpd.service.d/override.conf</span>
<span class="c1"># Override default "-Lsd" paramter to "-LSwd" to decrease logging level</span>
<span class="k">[Service]</span>
<span class="na">ExecStart</span><span class="o">=</span>
<span class="na">ExecStart</span><span class="o">=</span><span class="s">/usr/sbin/snmpd -LSwd -Lf /dev/null -u Debian-snmp -g Debian-snmp -I -smux,mteTrigger,mteTriggerConf -f</span>
</pre></div>
<p>Which is a combination of the default service along with your override.</p>
<p>If you have other servers you want to copy your <code>/etc/systemd/system/snmpd.service.d/override.conf</code> file to, you need
to run</p>
<pre><code>systemctl daemon-reload
service snmpd restart</code></pre>
<p>to have it take effect.</p></body>]]></description>
</item>
</channel>
</rss>