自动生成一下json数据脚本
json数据样例
{"provinceCode": "290","companyName": "test","appId": "10","appName": "apptest","eventTime": "2022-10-17 09:52:","errorType": "prm_mpxed","loadTime": 7}
脚本内容
for x in `seq 1 20`
do
sleep 1
/usr/hdp/current/kafka-broker/bin/kafka-console-producer.sh --broker-list 192.168.10.106:6667 --topic applet-topic <<< "{\"provinceCode\":\"`echo $[$RANDOM%900+100]`\",\"companyName\":\"test\",\"appId\":\"`echo $RANDOM`\",\"appName\":\"apptest\",\"eventTime\":\"`date '+%Y-%m-%d %H:%M:%S'`\",\"errorType\":\"prm_mpxed\",\"loadTime\":${x}`echo $RANDOM`,\"appVersion\":\"${x}.${x}\",\"trmnlStyle\":\"`echo $[RANDOM%2]`\"}"
done
for x in `seq 1 20`
do
sleep 1
/usr/hdp/current/kafka-broker/bin/kafka-console-producer.sh --broker-list 192.168.10.106:6667 --topic applet-topic <<< "{\"provinceCode\":\"`echo $[$RANDOM%900+100]`\",\"companyName\":\"test\",\"appId\":\"`echo $RANDOM`\",\"appName\":\"apptest\",\"eventTime\":\"`date '+%Y-%m-%d %H:%M:%S'`\",\"errorType\":\"prm_mpxjserr\",\"loadTime\":${x}`echo $RANDOM`,\"appVersion\":\"${x}.${x}\",\"trmnlStyle\":\"`echo $[RANDOM%2]`\"}"
done
for x in `seq 1 20`
do
sleep 1
/usr/hdp/current/kafka-broker/bin/kafka-console-producer.sh --broker-list 192.168.10.106:6667 --topic applet-topic <<< "{\"provinceCode\":\"`echo $[$RANDOM%900+100]`\",\"companyName\":\"test\",\"appId\":\"`echo $RANDOM`\",\"appName\":\"apptest\",\"eventTime\":\"`date '+%Y-%m-%d %H:%M:%S'`\",\"errorType\":\"prm_mpxreqreserr\",\"loadTime\":${x}`echo $RANDOM`,\"appVersion\":\"${x}.${x}\",\"trmnlStyle\":\"`echo $[RANDOM%2]`\"}"
done
for x in `seq 1 20`
do
sleep 1
/usr/hdp/current/kafka-broker/bin/kafka-console-producer.sh --broker-list 192.168.10.106:6667 --topic applet-topic <<< "{\"provinceCode\":\"290\",\"companyName\":\"test\",\"appId\":\"123456\",\"appName\":\"apptest\",\"eventTime\":\"`date '+%Y-%m-%d %H:%M:%S'`\",\"errorType\":\"prm_mpxreqreserr\",\"loadTime\":${x}`echo $RANDOM`,\"appVersion\":\"1.1\",\"trmnlStyle\":\"`echo $[RANDOM%2]`\"}"
done
标签:10,发至,--,broker,kafka,topic,json
From: https://www.cnblogs.com/whiteY/p/16803169.html