Forked from davewat/gist:b3c5c4a383d1d9d26df33ecbb6ddd668
Created
May 7, 2021 10:12
-
-
Save dpalomar/84ab2ced22739bd47834c0aa34c79ea7 to your computer and use it in GitHub Desktop.
Kafka commands and scripts
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
# Calculate the latest and earliest offsets, and provide the total # of messages in the topic (the difference): | |
#!/bin/bash | |
if [[ $# -eq 0 ]] ; then | |
echo 'provide the name of a topic to get totals against' | |
exit 0 | |
fi | |
latest=`bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic $1 --time -1 --offsets 1 | awk -F ":" '{sum += $3} END {print sum}'` | |
earliest=`bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic $1 --time -2 --offsets 1 | awk -F ":" '{sum2 += $3} END {print sum2}'` | |
total=`expr $latest - $earliest` | |
echo Latest Total $latest | |
echo Earliest Total $earliest | |
echo InQueue Total $total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment