#!/bin/bash
#-*- coding: utf-8 -*-
#Date: 2018/11/20
#Author: Mr.yang
KAFKA_HOST="192.168.0.184:9092" #kafka主机IP+端口
KAFKA_CMD="/database/kafka/bin/kafka-producer-perf-test.sh" #kafka脚本执行路径(根据自己本身环境修改,脚本名无需更改)
PARATER="--num-records 5 --record-size 2 --throughput 10" #参数,可不修改
TOPIC_NAME="monitor" #Topic名称可创建一个测试使用
ps -ef |grep kafka |grep -v grep |grep -v kafka.sh > /dev/null
if [ $? -eq 0 ];then
timeout 10s sh ${KAFKA_CMD} ${PARATER} --topic ${TOPIC_NAME} --producer-props bootstrap.servers=${KAFKA_HOST} > /dev/null
if [ $? -ne 0 ];then
echo 1
else
echo 0
fi
elif [ $? -ne 0 ];then
echo 1
fi