Last active
June 3, 2020 06:03
-
-
Save javierwilson/9235d776beab8ef532c18667adc44740 to your computer and use it in GitHub Desktop.
Runs check, sends output to events API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
rootdir="/usr/local/bin/checks" | |
checkfile=${1//[^a-zA-Z0-9_]/} | |
checkfile="${rootdir}/$checkfile" | |
checkname=${1//[^a-zA-Z0-9_]/} | |
if [ $# -lt 2 ]; then | |
echo "Usage:" | |
script=`basename "$0"` | |
echo "${script} <check_script> <check_name> [arg1] [arg2] [argN]" | |
exit 1 | |
fi | |
if [ ! -f $checkfile ]; then | |
echo "File not found! $checkfile" | |
exit 1 | |
fi | |
shift | |
shift | |
args="$@" | |
output=`$checkfile $args` | |
output=${output//[\"\']/} | |
status="$?" | |
curl -X POST \ | |
-H 'Content-Type: application/json' \ | |
-d "{ | |
\"check\": { | |
\"metadata\": { | |
\"name\": \"${checkname}\" | |
}, | |
\"status\": ${status}, | |
\"output\": \"${output}\" | |
} | |
}" \ | |
http://127.0.0.1:3031/events |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment