#!/bin/bash # Source the nagios shell-script library . utils.sh # Ensure we've been called properly. if [ $# -ne 2 ]; then echo "Usage: ./`basename $0` warn_low critical_low" exit 1; fi # This works ATM for getting the current value of DJI. DJI=$(curl "http://www.marketwatch.com/m/quotes/INDU" 2>&1 | grep "lasttrade number" | sed 's/.*lasttrade number">\$//' | sed 's/<\/span>.*//' | sed 's/,//' | sed 's/\...$//') if [ "${DJI}" == "" ]; then echo "UNKNOWN: Does my curl/sed script not work anymore?"; exit ${STATE_UNKNOWN}; fi if [ ${DJI} -le ${2} ]; then echo "CRITICAL: Last trade at \$${DJI}"; exit ${STATE_CRITICAL}; elif [ ${DJI} -le ${1} ]; then echo "WARNING: Last trade at \$${DJI}"; exit ${STATE_WARNING}; else echo "OK: Last trade at \$${DJI}"; exit ${STATE_OK}; fi