<?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>linsec.ca blog &#187; hddtemp</title>
	<atom:link href="http://linsec.ca/blog/tag/hddtemp/feed/" rel="self" type="application/rss+xml" />
	<link>http://linsec.ca/blog</link>
	<description>You can have it right, or you can have it now.  But you can&#039;t have it right now.</description>
	<lastBuildDate>Mon, 23 Jan 2012 23:38:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>hddtemp wrapper for Nagios</title>
		<link>http://linsec.ca/blog/2008/02/09/hddtemp-wrapper-for-nagios/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=hddtemp-wrapper-for-nagios</link>
		<comments>http://linsec.ca/blog/2008/02/09/hddtemp-wrapper-for-nagios/#comments</comments>
		<pubDate>Sat, 09 Feb 2008 07:52:50 +0000</pubDate>
		<dc:creator>vdanen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mandriva]]></category>
		<category><![CDATA[hddtemp]]></category>
		<category><![CDATA[nagios]]></category>

		<guid isPermaLink="false">http://linsec.ca/blog/2008/02/09/hddtemp-wrapper-for-nagios/</guid>
		<description><![CDATA[I was bored tonight so I wrote a wrapper for hddtemp for Nagios monitoring. I have a bit of a quirky setup for Nagios where I run the local system checks on remote systems via netcat, ipsvd, and a script to handle the query. This allows me to monitor remote drive space, current users, total [...]]]></description>
			<content:encoded><![CDATA[<p>I was bored tonight so I wrote a wrapper for hddtemp for Nagios monitoring.  I have a bit of a quirky setup for Nagios where I run the local system checks on remote systems via netcat, ipsvd, and a script to handle the query.  This allows me to monitor remote drive space, current users, total processes, and current load.  Using hddtemp, I can now monitor the temperature of the drives in those machines (which also gives me an idea of how hot/cold the server room itself is).</p>
<p>This may need some tweaking to work with other Nagios setups, but shouldn&#8217;t be too hard to adapt.  One of these days I&#8217;ll do a writeup on my Nagios configuration.  Anyways, the wrapper script is as follows.  It could probably be optimized a bit more, but it works well enough.  WordPress doesn&#8217;t handle the indents very well, so keep that in mind.</p>
<pre>
#!/bin/sh

usage() {
    echo "${0} -w [warn] -c [crit] [drives]"
}

if [ "${1}" == "-h" -o "${1}" == "--help" ]; then
    usage
    exit 0
fi
if [ "${1}" == "-w" ]; then
    shift
    warn="${1}"
    shift
else
    usage
    exit 1
fi
if [ "${1}" == "-c" ]; then
    shift
    crit="${1}"
    shift
else
    usage
    exit 1
fi
while [ "${1}" != "" ]; do
    drives="${drives} ${1}"
    shift
done
if [ "${drives}" == "" ]; then
    usage
    exit 1
fi

status=0
smsg=""
htemp=0

for drive in ${drives}; do
    msg=""
    stats=`/usr/local/sbin/hddtemp ${drive}`
    model=`echo ${stats} | cut -d ':' -f 2`
    temp=`echo ${stats} | cut -d ':' -f 3 | cut -d ' ' -f 2`
    dev=`echo ${drive}|cut -d '/' -f 3`

    if [ "${temp}" -ge "${warn}" ]; then
        if [ "${status}" != "2" ]; then
            status=1
        fi
    fi

    if [ "${temp}" -ge "${crit}" ]; then
        status=2
    fi

    if [ "${temp}" -gt "${htemp}" ]; then
        htemp="${temp}"
    fi

    smsg="${smsg}${dev}=${temp}C; "
done

case "${status}" in
    2)
        wmsg="CRITICAL"
        ;;
    1)
        wmsg="WARN"
        ;;
    0)
        wmsg="OK"
        ;;
esac

echo "HDDTEMP ${wmsg} - ${smsg}|hddtemp=${htemp};${warn};${crit};0"
</pre>
<p>The output, in Nagios&#8217; status view looks like:</p>
<pre>
HDDTEMP OK - hda=22C: sda=24C: sdb=24C:
</pre>
<p>It&#8217;s called as &#8220;hddtemp-mon -w 30 -c 35 /dev/hda /dev/sda /dev/sdb&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://linsec.ca/blog/2008/02/09/hddtemp-wrapper-for-nagios/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

