Created
December 18, 2013 05:54
-
-
Save ijokarumawak/8017869 to your computer and use it in GitHub Desktop.
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/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