Skip to content

Instantly share code, notes, and snippets.

@nicwaller
Created March 21, 2016 19:33
Show Gist options
  • Save nicwaller/39c8f1a6e973b585f8ab to your computer and use it in GitHub Desktop.
Save nicwaller/39c8f1a6e973b585f8ab to your computer and use it in GitHub Desktop.
Output the worst SLOWLOG entry from each Redis instance on a server, in descending order from slowest to fastest.
#!/bin/bash
# Example output:
# ~$ ./slowlog_all.sh
# 1779.2 ms /etc/redis/reports.conf
# 65.934 ms /etc/redis/actions.conf
for file in $(ls -1 /etc/redis/*.conf); do
name=$(basename $file);
port=$(awk '/^port/ {print $2}' $file);
redis-cli -p $port slowlog get 1 2>/dev/null | head -n4 | xargs -n4 echo | awk '{printf $3/1000 " ms "}';
echo $file;
done | sort -rn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment