<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/styles/rss-style.xsl"?>

<rss version="2.0"
 xmlns:blogChannel="http://backend.userland.com/blogChannelModule"
>

<channel>
<title>troglodyne.net</title>
<link>http://troglodyne.net//posts/80f8aa3b-38d5-11ec-8428-f3f45e6785a2?format=xml</link>
<description>troglodyne.net : /posts/80f8aa3b-38d5-11ec-8428-f3f45e6785a2</description>
<language>en</language>
<pubDate>2026-04-15T18:06:34</pubDate>
<lastBuildDate>2026-04-15T18:06:34</lastBuildDate>

<image>
<title>troglodyne.net</title>
<url>/favicon.ico</url>
<link>http://troglodyne.net</link>
<width>32</width>
<height>32</height>
<description>troglodyne.net favicon</description>
</image>
<item>
<title>Detect OOMs via cron</title>
<link>http://troglodyne.net/posts/80f8aa3b-38d5-11ec-8428-f3f45e6785a2</link>
<description><![CDATA[<p>
I recently had a problem with a hypervisor where the dom0 was underprovisioned for RAM, and it OOMKiller'd the hypervisor processes for VMs during scheduled rsync backups.
After nice-ing the processes appropriately to prevent this I decided to implement a simple cron to email me whenever oomkiller fires.
This obviously isn't foolproof, as something <em>could</em> be killed preventing outgoing mails.
It is however unlikely, so this will likely be a good enough solution going forward.
</p>
<pre>
oomdetect.sh
<code class="language-bash">#!/bin/bash

touch /root/ooms.log
FSZ=$(stat --printf "%s" /root/ooms.log)
grep -i oom-killer /var/log/messages >> /root/ooms.log
echo $(uniq < /root/ooms.log) > /root/ooms.log
NEWSZ=$(stat --printf "%s" /root/ooms.log)

if [ $FSZ != $NEWSZ ]
then
	echo "New OOM detected, investigate /var/log/messages:"
	tail -n1 /root/ooms.log
fi
</code>
</pre>
<p>
Pretty simple altogether, just make sure to run it once before you install it to root's crontab.
Don't forget that you can send crons to multiple recipients by making the relevant updates to /etc/aliases for that cron's user and running newaliases.
</p>]]></description>
<author>george</author>
<guid isPermaLink="true">http://troglodyne.net/posts/80f8aa3b-38d5-11ec-8428-f3f45e6785a2</guid>
<pubDate>2021-10-29T16:30:18</pubDate>
<enclosure type="text/html" url="http://troglodyne.net/posts/80f8aa3b-38d5-11ec-8428-f3f45e6785a2" />
</item>
</channel>
</rss>
