Skip to content

Instantly share code, notes, and snippets.

@ijokarumawak
Created December 18, 2013 05:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ijokarumawak/8017869 to your computer and use it in GitHub Desktop.
Save ijokarumawak/8017869 to your computer and use it in GitHub Desktop.
#!/bin/sh
numberOfEvents=$1
fluentdUrl=$2
USAGE="send-events-to-fluentd.sh numberOfEvents fluentdUrl"
if [[ $# -ne 2 ]]; then
echo $USAGE
exit 1
fi
function zeropad() {
if [[ `expr length $1` -eq 1 ]]; then
echo "0$1"
else
echo "$1"
fi
}
for (( i = 0; i < $numberOfEvents; i++ )); do
resultCode=""
case `expr $i % 3` in
(0) resultCode="SUCCESS";;
(1) resultCode="WARN";;
(2) resultCode="ERR";;
esac
sendMonth=`expr $i % 12 + 1`
sendMonth=`zeropad $sendMonth`
sendDay=`expr $i % 29 + 1`
sendDay=`zeropad $sendDay`
sendHour=`expr $i % 24`
sendHour=`zeropad $sendHour`
sendMin=`expr $i % 60`
sendMin=`zeropad $sendMin`
sendDate="2013-$sendMonth-${sendDay}T$sendHour:$sendMin:00.000Z"
curl -X POST -d "json={\"key\":\"event-$i\",\"value\":$i,\"resultCode\":\"$resultCode\",\"date\":\"$sendDate\"}" $fluentdUrl
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment