初版完成

This commit is contained in:
Bujue.Win10 2022-02-18 15:45:57 +08:00
parent 90c588c09d
commit dd822625d6
3 changed files with 26 additions and 17 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
mySimpleLog_*

View File

@ -7,6 +7,7 @@
#############################
BEGIN{
fileSize = 1024*1
# filePath = "/data/log_dir/mySimpleLog"
# system("echo '\n\n\n----------' >> "awk_run_log_path" && date '+%x %X' >> "awk_run_log_path)
@ -15,7 +16,7 @@ BEGIN{
#dp_is_condition = @/dp [0-9]+ match/
#dp_not_condition = @/no id match/
#pattern = @/([0-9]+-[0-9]+ ([0-9]+:){3}[0-9]+)/
#
#connection_check_ok = @/condition set is ok,then execute action set./
# Get form OS
log2file("{\"event\":\"gateway reboot\"}")
@ -27,6 +28,7 @@ $0~/ dp rept_type:[0-9]+, data:/ {
adps = match($0,/\{.+\}/) ? substr($0,RSTART,RLENGTH):null;
aLogJson = "{ \"time\":"atime", \"event\":\"dp report\", \"dps\":"adps"}"
# log2file(aLogJson)
checkFileSize()
}
$0~/rev id:\w+ cmd:\{.*\} type:0/ {
@ -82,7 +84,23 @@ function log2file(logJson){
system("echo -e '"logJson"' >> /data/log_dir/mySimpleLog")
}
function checkFileSize(){
# system("ls -l /data/log_dir/mySimpleLog | awk '{ print $5 }' | cat > /tmp/bujueFileSize")
checkState = system("ls -l /data/log_dir/mySimpleLog | awk '{ if($5 >"fileSize"){exit 0}else{exit 1} }'")
print checkState
if(!checkState){
print "uploading..."
splitAndUpload()
# print "uploaded"
}
}
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)
newFileName = "mySimpleLog_"systime()
ret = system("mv /data/log_dir/mySimpleLog /data/log_dir/"newFileName" && cd /data/log_dir/ && tftp 192.168.1.5 -p -l "newFileName" && rm "newFileName)
if(!ret){
print "upload success!"
}else{
print "upload fail!"
}
}

View File

@ -1,16 +1,6 @@
# 上位机启动tftp并将base目录设为项目根目录
# 远程ssh登录然后执行以下命令
cd /tmp && tftp 192.168.1.5 -g -l logDataClean.awk
# 创建场景
tail -f /tmp/tuya.log | grep '\] Rev MQTT:' | grep '"ruleId":' | awk -f ./logDataClean.awk >> /data/SceneLinkage &
# 触发场景
tail -f /tmp/tuya.log | grep 'condition set is ok,then execute action set. scene:' |awk -f >>
# 子设备上报
# 是否有相关场景( dp \d+ match | no dp match)
# 条件判断(conditions check finish. result:true)
# 条件判断结果(condition set is ok,then execute action set. scene:6DAMVviZamUqanPP, 0x8b26d8)
# 动作执行(in work-queue. execute scene:6DAMVviZamUqanPP begin)([scene_linkage_rule_exe.c)
# 子设备上报
tail -f /tmp/tuya.log | awk -f logDataClean.awk &