Sand Fox (Posts about systemd)https://sandfox.me/tags/systemd.xml2024-03-25T17:50:26ZAnton SmirnovNikolaWhen does journald-native work better?https://sandfox.me/ruby/journald-native.html2016-04-05T01:20:00+03:002016-04-05T01:20:00+03:00Anton Smirnov<div><p>There is already a nice gem called <code class="docutils literal"><span class="pre">systemd-journal</span></code>,
why another one? Well, because there are some edge cases that it does
not cover. I had a trouble with one.</p>
<p><a href="https://sandfox.me/ruby/journald-native.html">Read moreā¦</a> (1 min remaining to read)</p></div>systemd in Zabbixhttps://sandfox.me/linux/systemd-zabbix.html2015-01-17T12:00:00Z2015-01-17T12:00:00ZAnton Smirnov<p>If you use Zabbix to monitor your servers you may want to monitor
systemd services with it especially if you have some custom services.</p>
<p>These simple checks were enough for me:</p>
<div class="code"><pre class="code sh"><a id="rest_code_a284c171b9914ca8bb56be1312287da8-1" name="rest_code_a284c171b9914ca8bb56be1312287da8-1" href="https://sandfox.me/linux/systemd-zabbix.html#rest_code_a284c171b9914ca8bb56be1312287da8-1"></a>systemd.unit.is-active<span class="o">[</span><unit<span class="w"> </span>name><span class="o">]</span><span class="w"> </span><span class="c1"># 1 if unit is active, 0 if inactive</span>
<a id="rest_code_a284c171b9914ca8bb56be1312287da8-2" name="rest_code_a284c171b9914ca8bb56be1312287da8-2" href="https://sandfox.me/linux/systemd-zabbix.html#rest_code_a284c171b9914ca8bb56be1312287da8-2"></a>systemd.unit.is-failed<span class="o">[</span><unit<span class="w"> </span>name><span class="o">]</span><span class="w"> </span><span class="c1"># 1 if unit if in failed state, 0 if not</span>
<a id="rest_code_a284c171b9914ca8bb56be1312287da8-3" name="rest_code_a284c171b9914ca8bb56be1312287da8-3" href="https://sandfox.me/linux/systemd-zabbix.html#rest_code_a284c171b9914ca8bb56be1312287da8-3"></a>systemd.unit.is-enabled<span class="o">[</span><unit<span class="w"> </span>name><span class="o">]</span><span class="w"> </span><span class="c1"># 1 if unit is enabled, 0 if not</span>
</pre></div>
<p>It's very simple. Just place <code class="docutils literal">userparameter_systemd.conf</code> to your zabbix config dir
(usually <code class="docutils literal">/etc/zabbix_agentd.conf.d</code>) with the following content:</p>
<div class="code"><pre class="code ini"><a id="rest_code_275f9459a50b49ea822d589cef9f8690-1" name="rest_code_275f9459a50b49ea822d589cef9f8690-1" href="https://sandfox.me/linux/systemd-zabbix.html#rest_code_275f9459a50b49ea822d589cef9f8690-1"></a><span class="c1"># checks to determine if specified unit is active, failed or enabled</span>
<a id="rest_code_275f9459a50b49ea822d589cef9f8690-2" name="rest_code_275f9459a50b49ea822d589cef9f8690-2" href="https://sandfox.me/linux/systemd-zabbix.html#rest_code_275f9459a50b49ea822d589cef9f8690-2"></a><span class="na">UserParameter</span><span class="o">=</span><span class="s">systemd.unit.is-active[*],systemctl is-active --quiet '$1' && echo 1 || echo 0</span>
<a id="rest_code_275f9459a50b49ea822d589cef9f8690-3" name="rest_code_275f9459a50b49ea822d589cef9f8690-3" href="https://sandfox.me/linux/systemd-zabbix.html#rest_code_275f9459a50b49ea822d589cef9f8690-3"></a><span class="na">UserParameter</span><span class="o">=</span><span class="s">systemd.unit.is-failed[*],systemctl is-failed --quiet '$1' && echo 1 || echo 0</span>
<a id="rest_code_275f9459a50b49ea822d589cef9f8690-4" name="rest_code_275f9459a50b49ea822d589cef9f8690-4" href="https://sandfox.me/linux/systemd-zabbix.html#rest_code_275f9459a50b49ea822d589cef9f8690-4"></a><span class="na">UserParameter</span><span class="o">=</span><span class="s">systemd.unit.is-enabled[*],systemctl is-enabled --quiet '$1' && echo 1 || echo 0</span>
</pre></div>