ASR Router Memory

EDIT:  This is no longer needed and they have updated the original script with my notes and it now works

I use check_nwc_health to check all of our cisco devices(switches and routers) hardware health, memory, cpu and more.  This check works great except for memory checks on ASR routers.  By design, there is a memory pool on ASR routers that is always 100% full.  I wrote quick script to run just for ASR Router Memory checks:

Nagios Command:

$USER1$/check_asr_memory $HOSTADDRESS$ $ARG1$ $ARG2$ $ARG3$ $ARG4$

ARG1=Community, ARG2=memory-usage, ARG3=Warning percent, ARG4=Critical ercent

check_asr_memory:

#!/bin/bash

# Perform the check_nwc_health memory_usage command against Cisco ASR router
#data=”CRITICAL – mempool lsmpi_io usage is 99.99%, mempool Processor usage is 34.38% | ‘Processor_usage’=4.3%;80;90 ‘lsmpi_io_usage’=99.99%;80;90″
data=`/usr/local/nagios/libexec/check_nwc_health –hostname $1 –community $2 –mode $3 –warning $4 –critical $5`

# Separate into variables the input from check_nwc_health
data=${data##*’Processor_usage’=}
data=${data%% *}
IFS=’;’ read p w c <<< “$data”
d=${p%%}
d=${d%.*}

# Echo variables for testing
#echo “p=$p, d=$d, w=$w, c=$c”

# Do comparisons and write output to Nagios
if [ $d -ge $c ] # Is percent greater than or equal to critical level
then
echo “CRITICAL – mempool Processor usage is $p | ‘Processor_usage’=$p;$w;$c”
exit 2
elif [ $d -ge $w ] # Is percent greater than or equal to warning level
then
echo “WARNING – mempool Processor usage is $p | ‘Processor_usage’=$p;$w;$c”
exit 1
else
echo “OK – mempool Processor usage is $p | ‘Processor_usage’=$p;$w;$c”
exit 0
fi