Skip to content

Instantly share code, notes, and snippets.

@DominikAngerer
Forked from mikepenz/multitail.md
Last active August 29, 2015 14:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DominikAngerer/d818ab2c4fa5027f3b1f to your computer and use it in GitHub Desktop.
Save DominikAngerer/d818ab2c4fa5027f3b1f to your computer and use it in GitHub Desktop.
#!/bin/sh
DEFAULT_ = '/usr/local/tomcat/logs/catalina.out'
DEV_ = '/usr/local/tomcat_dev/logs/catalina.out'
DEV = '/usr/local/tomcatdev/logs/catalina.out'
TEST_ = '/usr/local/tomcat_test/logs/catalina.out'
TEST = '/usr/local/tomcattest/logs/catalina.out'
echo "############################################################"
echo "############################################################"
echo "apt-get update"
echo "############################################################"
echo "############################################################"
apt-get update # To get the latest package lists
echo "############################################################"
echo "############################################################"
echo "install multitail"
echo "############################################################"
echo "############################################################"
apt-get install multitail -y
echo "############################################################"
echo "############################################################"
echo "############################################################"
echo "############################################################"
echo "create multitail configuration"
multitailconfig='#Possible colors: red, green, yellow, blue, magenta, cyan and white.
# Pick default screen
defaultcscheme:log
# Default colorscheme for tomcat logs
colorscheme:log
cs_re:green:.*INFO.*
cs_re:yellow:.*WARN.*
cs_re:magenta:.*SEVERE.*
cs_re:red:.*FATAL.*
cs_re:red:.*ERROR.*
cs_re:blue:.*DEBUG.*
# /var/log/messages & .../syslog
colorscheme:syslog
cs_re:red:.*kernel.*
cs_re:magenta:.*sshd.*
cs_re:red:.*iptables.*
cs_re:red:.*sensorsd.*
cs_re:yellow:.*nagios.*
cs_re:yellow:.*null.*
cs_re:yellow:.*login.*
cs_re:yellow:.*bsd.*
cs_re:green:.*named.*
cs_re:green:.*MINUTE MARK.*
cs_re:green:.*last message repeated.*
cs_re:green:.*logger.*
cs_re:blue:.*ntpd.*
# postfix log
colorscheme:postfix
cs_re:red:.*reject.*
cs_re:blue:.*cleanup.*
cs_re:blue:.*smtpd.*
cs_re:green:.*to=.*
cs_re:yellow:.*from=.*
cs_re:magenta:.*status=deferred.*
cs_re:magenta:.*spamd.*
cs_re:red:.*warning.*
cs_re:red:.*bounced.*
#snort log
colorscheme:snort
cs_re:green:.*Priority: 3.*
cs_re:yellow:.*Priority: 2.*
cs_re:red:.*Priority: 1.*
# Default colorschemes
scheme:postfix:/var/log/maillog
scheme:syslog:/var/log/messages
scheme:snort:/var/log/snort/alert
# wether to abbreviate filesizes to xKB/MB/GB
abbreviate_filesize:on
# Turn off mail check
check_mail:0
# timestring format for statusline
statusline_ts_format:%m/%d/%Y %H:%M
statusline_attrs:blue,white,reverse
# enable things with the xterm title bar
# %f changed file
# %h hostname
# %l system load
# %m "New mail" or nothing
# %u username
# %t date + time
titlebar:%u@%h %f (%t) [%l]'
if [ ! -f ~/.multitailrc ]; then
touch ~/.multitailrc
echo "-- created file ~/.multitailrc (was missing)"
fi
echo "$multitailconfig" > ~/.multitailrc
echo "############################################################"
echo "############################################################"
echo "Create bash alias 'log' for a faster usage"
bashaliases='#!/bin/bash
function logoutput() {
if [[ -z "$1" ]]; then
echo "please add at least one log file"
return;
fi
if [ $1 = "tom" ]; then
multitail -CS log --mergeall $DEFAULT_
return
fi
if [ $1 = "tomdev" ]; then
if [ -f "$DEV_" ]; then
multitail -CS log --mergeall $DEV_
return
elif [ -f "$DEV" ]; then
multitail -CS log --mergeall $DEV_
return
else
echo "tomcat dev does not exist"
return
fi
fi
if [ $1 = "tomtest" ]; then
if [ -f "$TEST_" ]; then
multitail -CS log --mergeall $TEST_
return
elif [ -f "$TEST" ]; then
multitail -CS log --mergeall $TEST
return
else
echo "tomcat test does not exist"
return
fi
fi
multitail -CS log --mergeall $1 $2 $3 $4 $5 $6 $7 $8 $9
}
alias log=logoutput'
if [ ! -f ~/.bash_tail_aliases ]; then
touch ~/.bash_tail_aliases
echo "-- created file ~/.bash_tail_aliases (was missing)"
fi
echo "$bashaliases" > ~/.bash_tail_aliases
echo "############################################################"
echo "############################################################"
echo "Add the bash_tail_aliases reference to bash (if not exists)"
bashrc_content='if [ -f ~/.bash_tail_aliases ]; then
. ~/.bash_tail_aliases
fi'
if grep -q "bash_tail_aliases" ~/.bashrc; then
echo "-- bash_tail_aliases was already set"
else
echo "$bashrc_content" >> ~/.bashrc
echo "-- added bash_tail_aliases (was missing)"
fi
echo "############################################################"
echo "############################################################"
echo "Make sure to reload your bash after you've added those lines with: source ~/.bashrc"
echo "############################################################"
echo "############################################################"
echo "Everything set. Awesome. Try to call 'log', 'log tom', 'log tomtest', 'log tomdev', 'log ...logfiles'"
echo "############################################################"
echo "############################################################"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment