<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Rasila Garage &#187; unix</title>
	<atom:link href="http://rasilagarage.com/tag/unix/feed/" rel="self" type="application/rss+xml" />
	<link>http://rasilagarage.com</link>
	<description>Tuomas Rasila's blog about software and entrepreneurship</description>
	<lastBuildDate>Sun, 07 Mar 2010 09:11:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How to write a simple bot that updates status to Laconi.ca</title>
		<link>http://rasilagarage.com/2009/01/how-to-write-a-simple-bot-that-updates-to-laconica/</link>
		<comments>http://rasilagarage.com/2009/01/how-to-write-a-simple-bot-that-updates-to-laconica/#comments</comments>
		<pubDate>Sun, 25 Jan 2009 10:36:43 +0000</pubDate>
		<dc:creator>Tuomas Rasila</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[laconi.ca]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://rasilagarage.com/?p=73</guid>
		<description><![CDATA[In my last post I wrote about Laconi.ca and mentioned that we have many bots updating Laconi.ca too. The bots are made active when some condition has met. Example: Make server running out of disk space to post an update to Laconi.ca This is actually quite useful. Sure, you can tell every service to send [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_91" class="wp-caption alignleft" style="width: 220px"><a href="http://rasilagarage.com/wp-content/uploads/2009/01/419970_front_rack_server.jpg"><img class="size-full wp-image-91 " title="Rack server" src="http://rasilagarage.com/wp-content/uploads/2009/01/419970_front_rack_server.jpg" alt="Full disk is a lousy reason to wake up in a middle of the night" width="210" height="158" /></a><p class="wp-caption-text">Full disk is a lousy reason to wake up in a middle of the night</p></div>
<p>In my <a href="http://rasilagarage.com/2009/01/laconica-an-open-source-twitter-clone-behind-a-password-and-your-firewall/">last post</a> I wrote about Laconi.ca and mentioned that we have many bots updating Laconi.ca too. The bots are made active when some condition has met.</p>
<p><strong>Example: Make server running out of disk space to post an update to Laconi.ca</strong></p>
<p>This is actually quite useful. Sure, you can tell every service to send an email when something not wanted is happening but then you will have to read that mailbox too. Sending email to someone else doesn’t solve the problem. Hmm, updating to Laconi.ca doesn’t solve the problem either but it makes servers easier follow and to subscribe.</p>
<p>So here is a simple shell script:</p>
<p><span id="more-73"></span></p>
<p><code>#!/bin/sh<br />
fs=`mount|egrep '^/dev'|grep -iv cdrom| awk '{print $3}'`<br />
typeset -i thresh="96"<br />
typeset -i warn="98"<br />
for i in $fs<br />
do<br />
skip=0<br />
typeset -i used=`df -k $i|tail -n 1|awk '{print $5}'|cut -d "%" -f 1`<br />
if [ "$used" -ge "$warn" ]; then<br />
laconica.sh "1.2.3.4 server CRITICAL: filesystem $i is $used% full"<br />
fi<br />
if [ "$used" -ge "$thresh" -a "$used" -le "$warn" ]; then<br />
laconica.sh "1.2.3.4 server WARNING: filesystem $i is $used %full"<br />
fi<br />
done</code></p>
<p>I didn’t want to use cURL directly to talk to Laconi.ca so I downloaded laconica.sh from http://downloads.guillermoamaral.com/misc/laconica. Sure it uses cURL, but if I change a password no I can change it to this wrapper instead.</p>
<p>I saved the script as diskfull.sh. So lets first chmod it and then try it:</p>
<p><code>chmod 755 diskfull.sh<br />
./diskfull.sh</code></p>
<p>Laconi.ca gets an update as follows:</p>
<div id="attachment_75" class="wp-caption alignnone" style="width: 310px"><a href="http://rasilagarage.com/wp-content/uploads/2009/01/picture-3.png"><img class="size-medium wp-image-75" title="Laconi.ca bot in action" src="http://rasilagarage.com/wp-content/uploads/2009/01/picture-3-300x49.png" alt="Screenshot of Laconi.ca" width="300" height="49" /></a><p class="wp-caption-text">Screenshot of Laconi.ca</p></div>
<p>You would need schedule Cron to run the script. To do so, edit the /etc/crontab and add the following line:</p>
<p><code>31 8  * * *     root    /opt/diskfull.sh</code></p>
<p>This line will run it daily on 08:31 as root. You might want to change it. If you are not familiar with Cron <a href="http://guerrillatech.wordpress.com/2008/01/25/howto-use-cron-to-schedule-tasks/" onclick="pageTracker._trackPageview('/outgoing/guerrillatech.wordpress.com/2008/01/25/howto-use-cron-to-schedule-tasks/?referer=');">here is some help</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://rasilagarage.com/2009/01/how-to-write-a-simple-bot-that-updates-to-laconica/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
