/ Published in: Bash
Expand |
Embed | Plain Text
#!/bin/bash # # Show multiple logs with matching colorthemes, @2012 XtreamIT # # Written by Jonas Persson <[email protected]> # Dependencies: Multitail <http://www.vanheusden.com/multitail/> # Usage: multiLog [path] # For future remote logging feature try: multitail -l 'ssh user@host1 "tail -f /path/to/log/file"' -l 'ssh user@host2 "tail -f /path/to/log/file"' # Variables path=$1 exe_str="" # Functions function getColorScheme() { case ${1#*.} in "access.log") colortheme="-cS apache";; "error.log") colortheme="-cS apache_error";; *) colortheme="-cS syslog";; esac echo $colortheme # Use echo to return string cause bash by defaul only can return intigers } # Main if [ $# -ne 1 ] ; then echo "Usage - $0 <path></path>" exit 1 fi if [ -d $path ] ; then cd $path for log_file in * ; do colortheme=$(getColorScheme $log_file) exe_str="$exe_str $colortheme $log_file" done multitail $exe_str else echo "Path not valid" exit 1 fi exit 0
You need to login to post a comment.
