#! /bin/bash # script analyses ALL Kamailio log files # results will be in the /tmp/log_analysis . /usr/src/m2/framework/bash_functions.sh . /usr/src/m2/framework/settings.sh # ---- VARS ----- VERSION="1.1.1" SCRIPT_NAME="Kamailio FS down-up Log Analysis" DIR="/tmp/log_analysis" LOG=$DIR/k RESULT_FILE="$DIR/kamailio_result.log" # ---- MAIN ----- #if grep -qEi 'debian' /etc/*release; then # report "Debian system" 3 # apt-get -y install bc #fi k_start if [ -d $DIR ];then report "$DIR present" 0 else report "$DIR not present" 2 mkdir $DIR if [ -d $DIR ];then report "$DIR created" 4 else report "Failed to create $DIR" 1 exit fi fi rm -fr $RESULT_FILE FILES="/var/log/kamailio/kamailio.log*" for f in $FILES do report "Processing $f file..." 3 cp -fr $f $LOG cat $LOG | zgrep "Freeswitch down\|Freeswitch up" >> $RESULT_FILE done rm -fr $LOG report "Results file in: $RESULT_FILE" 3 echo echo "First 30 lines of log:" echo cat $RESULT_FILE | head -30 echo echo "Last 30 lines of log:" echo cat $RESULT_FILE | tail -30 echo report "Script completed" 3