0
我試圖瞭解這個gawk的命令一些javascript:的JavaScript在GAWK命令
gawk 'function getip(rec) {
n=split(rec,a,"\"");
split(a[n-1],ip,",");
return ip[1]
}
$10 ~ /302/ && $6 ~ /POST/ && $7 ~ /^\/sso\/[pl]fe\/(rs|ui)\/login/ {
lfe_user_ip=getip($0);
user_path[lfe_user_ip]=user_path[lfe_user_ip]"_login-302"
}
/\/sso\/pfe\/rs\/profile\/customer/ && $6 ~ /PUT/ {
pfe_user_ip=getip($0);
if (user_path[pfe_user_ip] ~ /_login-302/) {
if ($10 ~ /200/) successful_redirect_conversion+=1;
else failed_redirect_conversion+=1;
}
} END {
print successful_redirect_conversion, failed_redirect_conversion
}'
分析日誌線可以像這樣關於awk上面可以是這樣的:
[09/Oct/2017:02:21:39 -0400] 10.222.11.23 10.222.11.23 - GET /sso/lfe/ui/login http-bio-8000-exec-27 5000 200 49929 24 ?templateId=https%253A%2F%2Fwww.cargive.ca%2Fservice%2FpostLoginProcessing.a%3Fredirect%3Ddefault%26rememberMe%3D1&sourceUrl=https%3A//www.cargive.ca/service/postLoginProcessing.a?redirect=default&rememberMe=1&authlvl= "unauthenticated" "10.222.11.23, 10.222.11.23,10.222.11.23"
困惑在JavaScript分割方法和user_path變量