日志剖析脚本
脚本如下:
#!/bin/sh
###############################################
# #
# creator: lvnian #
# datetime: 29/04/2019 #
# #
###############################################
scripts_dir=`dirname $0`
function menu() {
clear
echo "*********************MENU OPS*****************"
echo "* *"
echo "* 1、指定时刻段获取日志 *"
echo "* 2、指定URI获取日志 *"
echo "* 3、指定时刻段及URI获取日志 *"
echo "* 4、exit *"
echo "* *"
echo "**********************************************"
read -p "输入编号: " number
}
function time_select(){
echo -e "t请输入你要挑选的时刻段(10:00 - 15:00)nt假如挑选时刻段初始时刻为当时时刻(-15:00):c"
read time
date_time=`head -1 $Logfile |awk -F"[[ / :]" '{print "["$5"/"$6"/"$7}'`
start_time=`echo "${time}" |awk -F"-" '{print $1}'|sed 's/[ t]*$//g' `
if [ -z "${start_time}" ]
then
echo -e "t你没输入挑选的开端时刻,默以为当时时刻`date +%Y%H:%M`:n"
start_time=`date +%H:%M`
fi
start_time=${date_time}:${start_time}
echo ${start_time}
stop_time=`echo $time|awk -F'-' '{print $2}'|sed 's/[ t]*//g' `
if [ -z "${stop_time}" ]
then
echo -e "t输入时刻格局有误!格局如下:n"
sleep 1
time_uri_select
fi
stop_time=${date_time}:${stop_time}
echo ${time} $uri $start_time $stop_time
file=`basename ${Logfile} `
}
function uri_select() {
echo -e "t请输入你选挑选的 URI : c"
read uri
file=`basename ${Logfile} `
}
[1] [2] [3] [4] 黑客接单网