[rabbitmq-discuss] of queues, memory and heartbeats...

Anthony anthony-rabbitmq at hogan.id.au
Tue Dec 8 13:01:33 GMT 2009


For the sake of anyone who tried this script, I realised I fluffed the
logic..

MEMFREEEQN="`egrep "^(MemTotal|MemFree|Buffers|Cached):" /proc/meminfo |\
>         awk '{print $1 " " $2}' |\
>         sed -r 's/^MemTotal:/+/g
>                 s/^(MemFree|Buffers|Cached):/-/g'`"
>
> MEMFREE="$(( ${MEMFREEEQN} ))"
> MEMPCFREE="$(( ( ${MEMFREE} * 100 ) / ${MEMTOTAL} ))"
>

This should do the trick :)

#!/bin/bash

STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
STATE_DEPENDENT=4

MEMTOTAL="`grep "^MemTotal: " /proc/meminfo |\
        awk '{print $2}'`"

MEMUSEDEQN="`egrep "^(MemTotal|MemFree|Buffers|Cached):" /proc/meminfo |\
        awk '{print $1 " " $2}' |\
        sed -r 's/^MemTotal:/+/g
                s/^(MemFree|Buffers|Cached):/-/g'`"

MEMUSED="$(( ${MEMUSEDEQN} ))"
MEMPCUSED="$(( ( ${MEMUSED} * 100 ) / ${MEMTOTAL} ))"
MEMPCFREE="$(( 100 - ${MEMPCUSED} ))"

MEMPCFREECRIT=5
MEMPCFREEWARN=10

if [ ${MEMPCFREE} -gt ${MEMPCFREEWARN} ]; then
        echo "OK: ${MEMUSED} (${MEMPCUSED}%) used, ${MEMPCFREE}% free"
        exit $STATE_OK
elif [ ${MEMPCFREE} -gt ${MEMPCFREECRIT} ]; then
        echo "WARNING: ${MEMUSED} (${MEMPCUSED}%) used, ${MEMPCFREE}% free"
        exit $STATE_WARNING
elif [ ${MEMPCFREE} -le ${MEMPCFREECRIT} ]; then
        echo "CRITICAL: ${MEMUSED} (${MEMPCUSED}%) used, ${MEMPCFREE}% free"
        exit $STATE_CRITICAL
fi

echo "UNKNOWN: Something went awry!"
exit $STATE_UNKNOWN
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20091209/4565e8f3/attachment.htm 


More information about the rabbitmq-discuss mailing list