完成上传,未调试

This commit is contained in:
Bujue.Win10 2022-02-17 18:39:45 +08:00
parent 158c5dff20
commit 90c588c09d
1 changed files with 20 additions and 14 deletions

View File

@ -18,31 +18,27 @@ BEGIN{
# #
#connection_check_ok = @/condition set is ok,then execute action set./ #connection_check_ok = @/condition set is ok,then execute action set./
# Get form OS # Get form OS
log2file("{\"event\":\"gateway reboot\"}")
} }
$0~/ dp rept_type:[0-9]+, data:/ { $0~/ dp rept_type:[0-9]+, data:/ {
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,/\{.+\}/) ? substr($0,RSTART,RLENGTH):null; adps = match($0,/\{.+\}/) ? substr($0,RSTART,RLENGTH):null;
# print "atime:"atime,"adps:"adps
aLogJson = "{ \"time\":"atime", \"event\":\"dp report\", \"dps\":"adps"}" aLogJson = "{ \"time\":"atime", \"event\":\"dp report\", \"dps\":"adps"}"
# log2file(aLogJson) # log2file(aLogJson)
} }
$0~/rev id:\w+ cmd:\{.*\} type:0/ { $0~/rev id:\w+ cmd:\{.*\} type:0/ {
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-5) : $0; adps = match($0,/cmd:\{.+\} /) ? substr(substr($0,RSTART,RLENGTH),5,RLENGTH-5) : "unkown";
devMac = match($0,/rev id:\w+/) ? substr(substr($0,RSTART,RLENGTH),8) : null devMac = match($0,/rev id:\w+/) ? substr(substr($0,RSTART,RLENGTH),8) : null
# print $0
if((getline conditionLine) > 0){ if((getline conditionLine) > 0){
isCondition = match(conditionLine,/(no id match|no dp match)/) ? "false" : match(conditionLine,/dp [0-9]+ match/) ? "true" : "unkown" isCondition = match(conditionLine,/(no id match|no dp match)/) ? "false" : match(conditionLine,/dp [0-9]+ match/) ? "true" : "unkown"
# print conditionLine
# print "isCondition:"isCondition
condition = "\"isCondition\":"isCondition condition = "\"isCondition\":"isCondition
if (isCondition=="true"){ if (isCondition=="true"){
# conditionDp = match(conditionLine,/dp [0-9]+ match/) ? substr(conditionLine,RSTART,RLENGTH) : "" conditionDp = match(conditionLine,/\] dp [0-9]+ match/) ? substr(substr(conditionLine,RSTART,RLENGTH),6,RLENGTH-11) : "unkown"
conditionDp = match(conditionLine,/\] dp [0-9]+ match/) ? substr(substr(conditionLine,RSTART,RLENGTH),6,RLENGTH-11) : ""
condition = condition",\"conditionDp\":"conditionDp condition = condition",\"conditionDp\":"conditionDp
} }
}else{ }else{
@ -53,17 +49,22 @@ $0~/rev id:\w+ cmd:\{.*\} type:0/ {
log2file(aLogJson) log2file(aLogJson)
} }
# $0~/dp [0-9]+ match/{
# }
$0~/condition set is ok,then execute action set\./ { $0~/condition set is ok,then execute action set\./ {
# print $0 # print $0
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;
aruleid = match($0,/scene:\w+,/) ? substr(substr($0,RSTART,RLENGTH),7,RLENGTH-7) : "false" aruleid = match($0,/scene:\w+,/) ? substr(substr($0,RSTART,RLENGTH),7,RLENGTH-7) : "false"
log2file("{ \"time\":"atime", \"ruleid\":\""aruleid"\",\"triggerNow\":\"true\"}") log2file("{ \"time\":"atime", \"event\":\"trigger\", \"ruleid\":\""aruleid"\",\"triggerNow\":\"true\"}")
} }
$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) : "unkown";
aLogJson = "{ \"time\":"atime", \"event\":\"action\", \"cmd\":"adps"}"
log2file(aLogJson)
}
END{ END{
} }
@ -79,4 +80,9 @@ function matchRet(reg ,RSTART,RLENGTH){
function log2file(logJson){ function log2file(logJson){
system("echo -e '"logJson"' >> /data/log_dir/mySimpleLog") system("echo -e '"logJson"' >> /data/log_dir/mySimpleLog")
}
function splitAndUpload(){
newFileName = "/data/log_dir/mySimpleLog_"systime()
system("mv /data/log_dir/mySimpleLog "newFileName" && tftp 192.168.1.5 -p -l "newFileName" && rm "newFileName)
} }