新增OPEN日志监控
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import logging
|
||||
from goojia_utils import ElasticSearchClient, dingutils
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
es206_client = ElasticSearchClient(host='192.168.0.206')
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
# 获取当前时间
|
||||
now = datetime.now()
|
||||
# 计算当前时间以前2分钟的时间
|
||||
two_minutes_ago = now - timedelta(minutes=2)
|
||||
# 将时间转换为时间戳(以毫秒为单位)
|
||||
# 注意:timestamp() 方法返回的是秒,所以我们需要乘以1000来得到毫秒
|
||||
timestamp_milliseconds = int(two_minutes_ago.timestamp() * 1000)
|
||||
|
||||
count = 0
|
||||
for doc in es206_client.scan_by_sql("select code from fangjia_log where code >= 500 and creationDate > " + str(timestamp_milliseconds)):
|
||||
count += 1
|
||||
if count > 2:
|
||||
print('【OPEN日志监控】最近两分钟超过两条错误,请检查日志!')
|
||||
dingutils.send_text('最近两分钟超过两条错误,请检查OPEN日志!', 'ab4231000995a8c90d8d1e91dfd6930c3896dd1c3bbf1f0af19e19004cf6c98c')
|
||||
break
|
||||
Reference in New Issue
Block a user