-
-
Save maiaz/e392b056fd337de23928a240bc67f2e3 to your computer and use it in GitHub Desktop.
.env to speedup ATS stuff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| LPATH="/opt/trafficserver/var/log/trafficserver/" | |
| EPATH="/opt/trafficserver/etc/trafficserver/" | |
| export LL=${LPATH}openmd_transaction.log | |
| export LS=${LPATH}synamedia_transaction.log | |
| export LD=${LPATH}diags.log | |
| export LT=${LPATH}traffic.out | |
| export LE=${LPATH}error.log | |
| export ER=${EPATH}remap.config | |
| export EP=${EPATH}parent.config | |
| export EL=${EPATH}logging.yaml | |
| alias cdl="cd ${LPATH}" | |
| alias cde="cd ${EPATH}" | |
| alias tsctl="/opt/trafficserver/bin/traffic_ctl" | |
| alias atsdbgtags="tsctl config set proxy.config.diags.debug.tags" | |
| alias atsdbgenable="tsctl config set proxy.config.diags.debug.enabled" | |
| alias atsdbgip="tsctl config set proxy.config.diags.debug.client_ip" | |
| alias atsdbginf="tsctl config match debug" | |
| NC=$(tput sgr0) | |
| RED=$(tput setaf 1) | |
| GREEN=$(tput setaf 2) | |
| YELLOW=$(tput setaf 3) | |
| BLUE=$(tput setaf 4) | |
| MAGENTA=$(tput setaf 5) | |
| CYAN=$(tput setaf 6) | |
| WHITE=$(tput setaf 7) | |
| GRAY=$(tput setaf 8) | |
| LRED=$(tput setaf 9) | |
| LGREEN=$(tput setaf 10) | |
| LYELLOW=$(tput setaf 11) | |
| LBLUE=$(tput setaf 12) | |
| LMAGENTA=$(tput setaf 13) | |
| LCYAN=$(tput setaf 14) | |
| LWHITE=$(tput setaf 15) | |
| sky_curl() { | |
| args=() | |
| url="" | |
| for arg in "$@"; do | |
| if [[ -z "$url" && "$arg" =~ ^https?:// ]]; then | |
| url="$arg" | |
| else | |
| args+=("$arg") | |
| fi | |
| done | |
| if [[ -z "$url" ]]; then | |
| echo "No URL found in arguments" >&2 | |
| exit 1 | |
| fi | |
| noscheme="${url#*://}" | |
| scheme="${url%%://*}" | |
| host="${noscheme%%/*}" | |
| pathquery="${noscheme#*/}" | |
| path="/${pathquery%%\?*}" | |
| query="${pathquery#*\?}" | |
| [[ "$pathquery" != *\?* ]] && query="" | |
| TOKENIZED=$(~/TAC_tools/SKY_token/sign.sh $scheme://$host $path | tail -1) | |
| CMD="curl "${args[@]}" $TOKENIZED$query" | |
| echo $CMD | |
| $CMD | |
| } | |
| sh_remap() { | |
| FN=${2:-${EPATH}remap.config} | |
| head -1 ${FN} | |
| grep $1 ${FN} | sed -e "s/@plugin=/\n\t${LYELLOW}@plugin=${NC}/g" | sed -e "s/@pparam=/\n\t\t@${LCYAN}pparam=${NC}/g" | \ | |
| sed -E 's#(https?://[^./[:space:]]+)\.([^./[:space:]]+)#\1.\x1b[32m\2\x1b[0m#g'; | |
| } | |
| sh_parent() { | |
| FN=${2:-${EPATH}parent.config} | |
| head -1 ${FN} | |
| grep $1 ${FN} | sed -e "s/ /\n\t /g" | sed -e "s/[\"\;]/\n\t\t- /g" | sed 's/\(dest_domain\)/\x1b[33m\1\x1b[0m/g'; | |
| } | |
| dbg_tail() { | |
| tail -f ${1:-${LPATH}synamedia_transaction.log} | \ | |
| while read dd oo; do DD=$(date +%DT%T.%N -d @${dd}); echo ${LWHITE}${DD:0:21}${NC} ${oo}; done | \ | |
| sed -u -E \ | |
| -e "s/(shn)=([^ ]+)/${LYELLOW}\1=\2${NC}/g" \ | |
| -e "s/(crc)=([^ ]+)/${GREEN}\1=\2${NC}/g" \ | |
| -e "s/(pssc)=([^ ]+)/${LGREEN}\1=\2${NC}/g" \ | |
| -e "s/(url)=([^ ]+)/\1=${CYAN}\2${NC}/g" \ | |
| -e "s/(url)=([^?]+)\?([^ ]+)/\1=\2${YELLOW}?\3${NC}/g" | |
| } | |
| dbg_pipe() { | |
| while read dd oo; do DD=$(date +%DT%T.%N -d @${dd}); echo ${LWHITE}${DD:0:21}${NC} ${oo}; done | \ | |
| sed -u -E \ | |
| -e "s/(shn)=([^ ]+)/${LYELLOW}\1=\2${NC}/g" \ | |
| -e "s/(crc)=([^ ]+)/${GREEN}\1=\2${NC}/g" \ | |
| -e "s/(pssc)=([^ ]+)/${LGREEN}\1=\2${NC}/g" \ | |
| -e "s/(url)=([^ ]+)/\1=${CYAN}\2${NC}/g" \ | |
| -e "s/(url)=([^?]+)\?([^ ]+)/\1=\2${YELLOW}?\3${NC}/g" | |
| } | |
| dp() { | |
| local -A PRESETS=( | |
| [1]="timestamp,chi,pssc,sssc,ttms,stms,url" | |
| [2]="timestamp,chi,pssc,ttms,shn,crc,url" | |
| [3]="timestamp,chi,shn,url,pssc,ttms,b,sssc,sscl,cfsc,pfsc,crc,stms,cwr" | |
| ) | |
| local mode="${1:-all}" | |
| local fields | |
| if [[ -v PRESETS[$mode] ]]; then | |
| fields="${PRESETS[$mode]}" | |
| elif [[ "$mode" == "all" ]]; then | |
| fields="all" | |
| else | |
| fields="$mode" # treat as raw comma-separated field list | |
| fi | |
| while IFS= read -r line; do | |
| local ts="${line%% *}" | |
| local DD | |
| DD=$(date +%DT%T.%N -d "@${ts}") | |
| local ts_fmt="${BLUE}${DD:0:21}${NC}" | |
| if [[ "$fields" == "all" ]]; then | |
| printf '%s %s\n' "$ts_fmt" "${line#* }" | |
| else | |
| local out="$ts_fmt" | |
| IFS=',' read -ra flist <<< "$fields" | |
| for f in "${flist[@]}"; do | |
| [[ "$f" == "timestamp" ]] && continue | |
| local val | |
| # (?<!\S) = only match at start-of-line or after whitespace | |
| val=$(printf '%s' "$line" | grep -oP "(?<!\S)${f}=\K(\"[^\"]*\"|[^ ]+)") | |
| [[ -n "$val" ]] && out+=" ${f}=${val}" | |
| done | |
| printf '%s\n' "$out" | |
| fi | |
| done | sed -u -E \ | |
| -e "s/(shn)=([^ ]+)/${LYELLOW}\1=\2${NC}/g" \ | |
| -e "s/(crc)=([^ ]+)/${GREEN}\1=\2${NC}/g" \ | |
| -e "s/(pssc)=([^ ]+)/${LGREEN}\1=\2${NC}/g" \ | |
| -e "s/(url)=([^ ]+)/\1=${CYAN}\2${NC}/g" \ | |
| -e "s/(url)=([^?]+)\?([^ ]+)/\1=\2${YELLOW}?\3${NC}/g" | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment