For the sake of anyone who tried this script, I realised I fluffed the logic..<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<span style="font-family: courier new,monospace;">MEMFREEEQN="`egrep "^(MemTotal|MemFree|Buffers|Cached):" /proc/meminfo |\</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> awk '{print $1 " " $2}' |\</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> sed -r 's/^MemTotal:/+/g</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> s/^(MemFree|Buffers|Cached):/-/g'`"</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">MEMFREE="$(( ${MEMFREEEQN} ))"</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">MEMPCFREE="$(( ( ${MEMFREE} * 100 ) / ${MEMTOTAL} ))"</span><br style="font-family: courier new,monospace;"></blockquote><div><br>This should do the trick :)<br>
<br>
</div></div><font size="1"><span style="font-family: courier new,monospace;">#!/bin/bash</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">STATE_OK=0</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">STATE_WARNING=1</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">STATE_CRITICAL=2</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">STATE_UNKNOWN=3</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">STATE_DEPENDENT=4</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">MEMTOTAL="`grep "^MemTotal: " /proc/meminfo |\</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> awk '{print $2}'`"</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">MEMUSEDEQN="`egrep "^(MemTotal|MemFree|Buffers|Cached):" /proc/meminfo |\</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> awk '{print $1 " " $2}' |\</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> sed -r 's/^MemTotal:/+/g</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> s/^(MemFree|Buffers|Cached):/-/g'`"</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">MEMUSED="$(( ${MEMUSEDEQN} ))"</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">MEMPCUSED="$(( ( ${MEMUSED} * 100 ) / ${MEMTOTAL} ))"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">MEMPCFREE="$(( 100 - ${MEMPCUSED} ))"</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">MEMPCFREECRIT=5</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">MEMPCFREEWARN=10</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">if [ ${MEMPCFREE} -gt ${MEMPCFREEWARN} ]; then</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> echo "OK: ${MEMUSED} (${MEMPCUSED}%) used, ${MEMPCFREE}% free"</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> exit $STATE_OK</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">elif [ ${MEMPCFREE} -gt ${MEMPCFREECRIT} ]; then</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> echo "WARNING: ${MEMUSED} (${MEMPCUSED}%) used, ${MEMPCFREE}% free"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> exit $STATE_WARNING</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">elif [ ${MEMPCFREE} -le ${MEMPCFREECRIT} ]; then</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> echo "CRITICAL: ${MEMUSED} (${MEMPCUSED}%) used, ${MEMPCFREE}% free"</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> exit $STATE_CRITICAL</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">fi</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">echo "UNKNOWN: Something went awry!"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">exit $STATE_UNKNOWN</span><br>
<br></font><br>