Skip to content

Commit facbd78

Browse files
authored
Merge pull request #141 from lisuml/kafka_lag
Add perfdata support
2 parents d42281d + 5457bb8 commit facbd78

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

templates/plugins/check_kafka_lag

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ check_arguments() {
9494
fi
9595
}
9696

97+
# Joins arrays by given delimiter
98+
join_by() {
99+
local IFS="${1}"
100+
shift
101+
echo "${*}"
102+
}
103+
97104
# Main function
98105
main() {
99106
# Dump data of consumer group to a file
@@ -127,6 +134,7 @@ main() {
127134

128135
# Check thresholds
129136
state=${STATE_OK}
137+
perfdata=()
130138
for item in ${lags[@]}
131139
do
132140
topic=$(echo ${item} | awk -F# '{print $1}')
@@ -147,9 +155,14 @@ main() {
147155
echo -n "${topic} topic's lag (${partition}): ${lag} "
148156
state=${STATE_CRITICAL}
149157
fi
158+
perfdata+=("part_${partition}=${lag};${warn};${crit}")
150159
done
151160

152-
[ ${state} -eq ${STATE_OK} ] && echo 'Lag within normal limits'
161+
[ ${state} -eq ${STATE_OK} ] && echo -n 'Lag within normal limits '
162+
163+
# Attach perfdata
164+
echo "| $(join_by ' ' ${perfdata[@]})"
165+
153166
exit ${state}
154167
}
155168

0 commit comments

Comments
 (0)