#!/bin/bash

plugins=/usr/local/monitoring/nagios/libexec
port=9666
timeout=60
command=get_mem

if [[ "$#" -ne "4" ]]; then echo "Usage: check_nrpe_mem_wrapper <hostname> <serviceduration> <type> <warn_threshold,crit_threshold>"; exit 3; fi

host="$1"
duration="$2"
type="$3"
warncrit="$4"

out=`${plugins}/check_nrpe -t $timeout -H $host -p $port -c $command -a "$host" "$type" "$warncrit" 2>&1`
stat=$?

out=`echo "$out" | sed 's/^\(.*\)|\(.*\)/\1 for '"$duration"' |\2/'`

echo $out
exit $stat
