Skip to content

Instantly share code, notes, and snippets.

@mjf
Last active October 19, 2015 07:38
Show Gist options
  • Save mjf/df32c94b52e4231bf8f1 to your computer and use it in GitHub Desktop.
Save mjf/df32c94b52e4231bf8f1 to your computer and use it in GitHub Desktop.
mysqlreportfmt - Format MySQL Report Tool's output
#
# Include this function in your ~/.bashrc file
#
mysqlreport() {
$(which mysqlreport) $@ | mysqlreportfmt | less -c -R
}
#! /bin/sed -f
# mysqlreportfmt - Format MySQL Report Tool's output
# Copyright (C) 2015 Matous Jan Fialka, <http://mjf.cz/>
# Released under the terms of "The MIT License"
/^MySQL / {
s/ //5
s/ //5
s/^/\x1b[44;33;1m /
s/$/ \x1b[0m/
n
}
/^__/{
s/^__//
s/_/ /g
s/$/ /
s/^/\x1b[1;7m/
s/$/\x1b[0m\n/
n
}
/^Data/,$ {
/^[ \t]*$/d
}
/ ON/ {
s/ \(ON\)/ \x1b[32;1m\1\x1b[0m/
}
/ OFF/ {
s/ \(OFF\)/ \x1b[31;1m\1\x1b[0m/
}
/\(%[^:]\+\|Log\|Size\):/ {
s/\(\(%[^:]\+\|Log\|Size\):\)/\x1b[36;1m\1\x1b[0m/g
}
/[+-]Unknown/ {
s/\([+-]\)\(Unknown\)/\x1b[35;1m\1\x1b[0m\x1b[5m\2\x1b[0m/g
}
/^[^ ]\+\( [^ ]\+\)*/ {
s/^\([^ :]\+\( [^ :]\+\)\{,2\}\)/\x1b[33;1m\1\x1b[0m/
s/:\([^ ]\+\)/:\x1b[36;1m\1\x1b[0m/
}
/ of / {
s/ of /\x1b[33;1m&\x1b[0m/
}
@mjf
Copy link
Author

mjf commented Jan 27, 2015

On CentOS/RHEL/Fedora:

yum install mysqlreport

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment