action为toggle的情况

This commit is contained in:
Bujue.Win10 2022-03-04 17:14:12 +08:00
parent 5df3bb2449
commit ebea1ced99
1 changed files with 23 additions and 2 deletions

View File

@ -56,7 +56,20 @@ $0~/condition set is ok,then execute action set\./ {
$0~/action<[0-9]+> is dp cmd:/ { $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; 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"}" aLogJson = "{ \"time\":"atime", \"event\":\"action\", \"cmd\":"adps"}"
log2file(aLogJson) log2file(aLogJson)
@ -83,7 +96,7 @@ function splitAndUpload(){
newFileName = "mySimpleLog_"systime() newFileName = "mySimpleLog_"systime()
print "uploading..." 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){ if(!ret){
print "upload success!" print "upload success!"
uploadCount++ 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(){ function notify2python(){
# system("curl http://"upload_ip"/api") # system("curl http://"upload_ip"/api")
} }