Skip to content

Commit

Permalink
fix issue 127 by returning a non-zero return value on curl failure
Browse files Browse the repository at this point in the history
  • Loading branch information
scottbessler committed Aug 28, 2012
1 parent a9d8871 commit 54346ec
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions nagios/check_ganglia_metric.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,20 @@ then
done
else
echo "Sample invocation $0 host=localhost.localdomain metric_name=load_one operator=more critical_value=1"
exit 1
exit 3
fi

COMMAND="curl -s ${GANGLIA_URL}?${CHECK_ARGS}"
RESULT=`$COMMAND`
RETURN_VALUE=$?
# if curl fails we should fail
if [ $RETURN_VALUE -ne 0 ]; then
echo "error fetching metric with command: ${COMMAND}"
echo "result: $RESULT"
echo "curl return_value: $RETURN_VALUE"
exit 3
fi

RESULT=`curl -s ${GANGLIA_URL}?${CHECK_ARGS}`
EXIT_CODE=`echo $RESULT | cut -f1 -d'|'`

IFS='|'
Expand All @@ -51,3 +61,7 @@ for x in $EXIT_CODE; do
exit 3;;
esac
done

# If we got no results that is an error in and of itself
echo "UNKNOWN: no result from ganglia"
exit 3

0 comments on commit 54346ec

Please sign in to comment.