Skip to content

Instantly share code, notes, and snippets.

@manojVivek
Created October 21, 2016 14:47
Show Gist options
  • Save manojVivek/494f77d60057e60baed304b252b23255 to your computer and use it in GitHub Desktop.
Save manojVivek/494f77d60057e60baed304b252b23255 to your computer and use it in GitHub Desktop.
A simple elementary script to monitor the request count for each source ips at seconds granularity by grepping the haproxy-info log
#!/bin/bash
COLUMNS=300
export COLUMNS
source_ips=( "10.0.0.1" "10.0.0.2" "10.0.0.3")
header=("Time" ${source_ips[@]})
for value in "${header[@]}"; do
printf "%-8s\n" "${value}"
done | column -x
for i in $(seq -w 1 60);
do
results=()
results+=("$1$i")
for ip in ${source_ips[*]};
do
results+=(`grep "$1$i" $2 | grep $ip | wc -l`)
done
for value in "${results[@]}"; do
printf "%-8s\n" "${value}"
done | column -x
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment