#!/bin/bash
startTime="2019-06-05 00:00:00"
endTime="2022-02-01 00:00:00"
#lis=(qs sh jsfw pl hzj mhs mch xh sbq nxdq dwk xs nss)
lis=(hzj)
allDbCount=0
for db in ${lis[@]};do
dbCount=0
`taos -s "show ${db}.stables" >> /home/${db}.txt`
`sed -i '1,7d' /home/${db}.txt`
`sed -i '$d' /home/${db}.txt`
`sed -i '$d' /home/${db}.txt`
stbList=`cat /home/${db}.txt | awk -F' ' '{print $1}'`
echo "===== dbName: ${db} ====="
for stb in ${stbList[@]};do
(taos -s "select count(*) from ${db}.${stb} where point_time >= \'${startTime}\' and point_time < \'${endTime}\' >> /home/${db}_${stb}.txt")
`sed -i '1d' /home/${db}_${stb}.txt`
count=`cat /home/${db}_${stb}.txt`
echo "===== stbName: ${stb} , stbCount: ${count} ====="
export dbCount=`expr ${dbCount} + ${count}`
`rm -rf /home/${db}_${stb}.txt`
done
echo "===== dbName: ${db} , dbCount: ${dbCount} ====="
export allDbCount=`expr ${allDbCount} + ${dbCount}`
`rm -rf /home/${db}.txt`
done
echo "===== allDbCount: ${allDbCount} ====="