create entry in mongodb using this script for monitoring data
#!/bin/bash
# call as `sh servlet.sh <node uuid> <node ip> <url> [servlet type]`
# exmaple sh servlet.sh 595e341fd7391071d21ce1b5 20.20.1.73 /servlet/acme/ CompareServer-0
header="Content-Type: application/json"
enc=$(gshuf -i 0-1000 -n 1) #generate random number (in unix use shuf , remove prefix g)
dec=$(gshuf -i 10-600 -n 1)
now=$(gdate +%s%3N) #generate current time in miliseconds ( in unix use date, remove prefix g )
uuid=$1 #first argument
ip=$2 #second argument
url_less=${3%/} #remove trailing slash, if any
url=${url_less#/} #remove leading slash, if any
srv=${4:-BlindServer-0} #optional 4th argument, if not provided than set default value BlindServer-0
post_data=$(cat <<EOF
{
"ip_address": "$ip",
"baffleShield_id": "$uuid:$srv",
"num_records_1": $enc,
"num_records_2": $dec,
"epoch_time": $now
}
EOF
)
echo "$post_data"
echo "http://127.0.0.1:8553/monitor/$url/$uuid"
curl -k -X POST -H "$header" -d "$post_data" "http://127.0.0.1:8553/monitor/$url/$uuid"