54 lines
1.1 KiB
Awk
54 lines
1.1 KiB
Awk
#!/bin/awk -f
|
|
|
|
#############################
|
|
# clean data and filter some to rediect to new file
|
|
# Author: Liao
|
|
# modify time: 2021/12/15 17:05 (+8:00)
|
|
#############################
|
|
|
|
BEGIN{
|
|
filePath=/data/log/myJsonLog
|
|
# system("echo '\n\n\n----------' >> "awk_run_log_path" && date '+%x %X' >> "awk_run_log_path)
|
|
|
|
dp_recv_from_device = @/ dp rept_type:[0-9]+, data:{/
|
|
dp_is_condition = @/dp [0-9]+ match/
|
|
dp_not_condition = @/no [0-9]+ 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
|
|
|
|
}
|
|
!a++{
|
|
|
|
}
|
|
$0~dp_recv_from_device{
|
|
matchRet(/[0-9]{1,2}-[0-9]{1,2} ([0-9]{1,2}:){3}[0-9]{1,3}/);
|
|
}
|
|
$0~dp_is_condition{
|
|
|
|
}
|
|
$0~connection_check_ok{
|
|
|
|
}
|
|
|
|
END{
|
|
|
|
}
|
|
|
|
function matchRet(reg ,RSTART,RLENGTH){
|
|
if(match($0,$reg)){ return substr($0,RSTART,RLENGTH) }else{ return "Nothing Matched" }
|
|
}
|
|
|
|
function maker_Json(){
|
|
return {
|
|
"time":matchRet(/[0-9]{1,2}-[0-9]{1,2} ([0-9]{1,2}:){3}[0-9]{1,3}/),
|
|
"event":matchRet(),
|
|
"value":matchRet(),
|
|
"dps":matchRet(/\{.+\}/)
|
|
}
|
|
}
|
|
|
|
function write2file(){
|
|
echo $1 >> $filePath
|
|
} |