#!/bin/bash

eval "$(<~/.ssh/.ssh-agent)" >/dev/null

#for arg in $@; do echo "#${arg}#"; done

# This crazy shit is done because of issues with passing quotes in
precmd=`echo $* | sed 's/\-C.*//'`
cmd=`echo "$*" | sed 's/.*\-C[[:space:]]\+//'`

#echo "#${precmd}#${cmd}#"

exec /usr/local/monitoring/nagios/libexec/check_by_ssh $precmd -C "$cmd" 2>&1

exit $?

