From ebea1ced99c6e5657afd6ff8a6ddf44c996777d7 Mon Sep 17 00:00:00 2001 From: "Bujue.Win10" Date: Fri, 4 Mar 2022 17:14:12 +0800 Subject: [PATCH] =?UTF-8?q?action=E4=B8=BAtoggle=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logDataClean.awk | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/logDataClean.awk b/logDataClean.awk index e37bce7..d1335ce 100644 --- a/logDataClean.awk +++ b/logDataClean.awk @@ -56,7 +56,20 @@ $0~/condition set is ok,then execute action set\./ { $0~/action<[0-9]+> is dp cmd:/ { atime = match($0,/[0-9]{1,2}-[0-9]{1,2} ([0-9]{1,2}:){3}[0-9]{1,3}/) ? substr($0,RSTART,RLENGTH) : null; - adps = match($0,/cmd:\{\".+\}/) ? substr(substr($0,RSTART,RLENGTH),5,RLENGTH-4) : ""$0; + adps = match($0,/cmd:\{\".+\}\}/) ? substr(substr($0,RSTART,RLENGTH),5,RLENGTH-4) : ""$0; + + aLogJson = "{ \"time\":"atime", \"event\":\"action\", \"cmd\":"adps"}" + log2file(aLogJson) +} + +$0~/action<[0-9]+> is toggle./ { + atime = match($0,/[0-9]{1,2}-[0-9]{1,2} ([0-9]{1,2}:){3}[0-9]{1,3}/) ? substr($0,RSTART,RLENGTH) : null; + + if((getline conditionLine) > 0){ + adps = match(conditionLine,/toggle action: \{.*\}\}/) ? substr(substr($0,RSTART,RLENGTH),16,RLENGTH-15) : "\"not substr cmd\"" + }else{ + print "no more line" + } aLogJson = "{ \"time\":"atime", \"event\":\"action\", \"cmd\":"adps"}" log2file(aLogJson) @@ -83,7 +96,7 @@ function splitAndUpload(){ newFileName = "mySimpleLog_"systime() print "uploading..." - ret = system("mv /data/log_dir/mySimpleLog /data/log_dir/"newFileName" && cd /data/log_dir/ && tftp "upload_ip" -p -l "newFileName" > /dev/null && rm "newFileName) + ret = system("mv /data/log_dir/mySimpleLog /data/log_dir/"newFileName" && cd /data/log_dir/ && tftp "upload_ip" -pr "newFileName" > /dev/null && rm /data/log_dir/"newFileName"") if(!ret){ print "upload success!" uploadCount++ @@ -92,6 +105,14 @@ function splitAndUpload(){ } } +function doMoreLine(){ + if((getline conditionLine) > 0){ + adps = match(conditionLine,/toggle action: \{.*\}\}/) ? substr(substr($0,RSTART,RLENGTH),16,RLENGTH-15) : "\"unkown\"" + }else{ + print "no more line" + } +} + function notify2python(){ # system("curl http://"upload_ip"/api") } \ No newline at end of file