Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
I
ils-common-video
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
提交
议题看板
打开侧边栏
OpsTeam
ils-common-video
Commits
3d52fc30
提交
3d52fc30
authored
5月 25, 2021
作者:
zw.wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: [tasks] 更改influxdb查询
上级
dc824437
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
15 行增加
和
18 行删除
+15
-18
tasks.py
isc_video_record/tasks.py
+15
-18
没有找到文件。
isc_video_record/tasks.py
浏览文件 @
3d52fc30
...
@@ -72,9 +72,10 @@ class Tasks:
...
@@ -72,9 +72,10 @@ class Tasks:
'camera_index'
:
camera
[
'point_index_code'
]
'camera_index'
:
camera
[
'point_index_code'
]
},
},
'fields'
:
{
'fields'
:
{
'value'
:
online_info
.
get
(
'online'
,
0
)
'value'
:
online_info
.
get
(
'online'
,
0
),
'collect_time'
:
online_info
[
'collectTime'
]
},
},
'time'
:
online_info
[
'collectTime'
]
'time'
:
datetime
.
utcnow
()
})
})
if
len
(
measure_points
):
if
len
(
measure_points
):
influxdb
.
reconnect
()
influxdb
.
reconnect
()
...
@@ -101,26 +102,21 @@ class Tasks:
...
@@ -101,26 +102,21 @@ class Tasks:
'value'
:
0
,
'camera_count'
:
0
}
'value'
:
0
,
'camera_count'
:
0
}
# 获取摄像头在线\离线数量
# 获取摄像头在线\离线数量
collect_time
=
datetime
.
utcnow
()
-
timedelta
(
minutes
=
5
.1
)
collect_time
=
datetime
.
utcnow
()
-
timedelta
(
minutes
=
4
.1
)
query_str
=
'''
query_str
=
'''
select mode(value), count(value)
select * from one_week.isc_camera_status
from one_week.isc_camera_status
group by camera_code
where time >= '{}'
order by time desc limit 1
group by value
'''
'''
.
format
(
collect_time
)
status_res
=
list
(
influxdb
.
query
(
query_str
))
status_res
=
list
(
influxdb
.
query
(
query_str
))
online_count
=
offline_count
=
0
online_count
=
offline_count
=
0
if
status_res
:
for
res
in
status_res
:
status_res
=
status_res
[
0
]
for
status
in
res
:
for
status
in
status_res
:
if
status
[
'value'
]
==
1
:
if
status
[
'mode'
]
==
1
:
online_count
+=
1
online_count
=
status
[
'count'
]
else
:
else
:
offline_count
=
status
[
'count'
]
offline_count
+=
1
collect_time
=
status
[
'time'
]
collect_time
=
status
[
'time'
]
if
isinstance
(
collect_time
,
str
):
collect_time
=
datetime
.
strptime
(
collect_time
,
'
%
Y-
%
m-
%
dT
%
H:
%
M:
%
S.
%
fZ'
)
mobiles
=
None
mobiles
=
None
if
online_count
<=
3
:
if
online_count
<=
3
:
...
@@ -212,4 +208,5 @@ if __name__ == '__main__':
...
@@ -212,4 +208,5 @@ if __name__ == '__main__':
log_init
(
__name__
,
False
)
log_init
(
__name__
,
False
)
t
=
Tasks
()
t
=
Tasks
()
# t.start()
# t.start()
t
.
run_moniter_hour
()
# t.run_moniter_hour()
t
.
run_moniter_online
()
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论