Commit 50fd600d by trace

增加逻辑: 补全监控数量

parent b972bd14
let version = '1.3.3'
let version = '1.4.0'
let release = `<div><br/>
<br/>1. <br/>
原获取排名链接失效不单独通知<br/>
补全监控数量, 配置添加参数: monitorNumAtLeast, 至少监控多少个APP. 保持自有 APP 比例, 减少关联可能性<br/>
<div/>
<br/>
<br/>
......@@ -48,6 +48,7 @@ let requestTopAppNum = isTest() && 1 || 100
let aliveTime = 9 // 多少点后开始发送邮件
let theDaySendList = [1, 2, 3, 4, 5, 6, 7] // 发送列表的时间(周几)
let aliveInterval = isTest() && 0.1 || 3 // 发送邮件间隔时间
let monitorNumAtLeast = isTest() && 5 || 700 // 监控最低数量 (当补全数据不足时, 也可能少于700)
let start = true // 是否开始爬取监控
let dailyOnlineStartHours = 7
let dailyOnlineEndHours = 9
......@@ -114,6 +115,7 @@ function log(content, useRelease = false) {
if (isTest() || useRelease) {
console.log(`[${new Date().toLocaleString()}]: ${content}`)
}
return content
}
function isTest() {
let testName = ['taketrace']
......@@ -171,7 +173,7 @@ sendEmail(`开始监控-----------------------`)
async function startMonitor() {
log('开始监控')
while (start) {
log(`抓取一圈`)
dingDing(log(`抓取一圈`))
await getConfig()
.then(() => { // 部署通知, 更新说明
if (newDeploy) {
......@@ -185,6 +187,21 @@ async function startMonitor() {
.then(() => { // 动态修改间隔得值
// 自有 app 没到时间不会进入监控
let allN = allNames(monitorNames)
// 将监控数量补全到700
let less = monitorNumAtLeast - allN.length
let logLess = less
for (let key in status) {
if (less == 0 || less < 0) {
break
}
if (!allN.includes(key) && status[key].status) {
log(`push 补全: ${key}`)
allN.push(key)
less--
}
}
log(`补全后监控数量: ${allN.length}, 补全: ${logLess}`)
return allN
})
.then(allN => monitorIfOnline(allN))
......@@ -360,6 +377,7 @@ async function getConfig() {
sleepTime = sec * (config.sleepTime || sleepTime)
requestTimeout = sec * (config.requestTimeout || requestTimeout)
requestTopAppNum = config.requestTopAppNum || requestTopAppNum
monitorNumAtLeast = config.monitorNumAtLeast || monitorNumAtLeast
aliveTime = config.aliveTime || aliveTime
if (Array.isArray(config.theDaySendList)) {
theDaySendList = config.theDaySendList
......
{
"config": {
"monitorNumAtLeast": 700,
"dailyOnlineStartHours": 7,
"dailyOnlineEndHours": 9,
"defaultIntervalTimeForOurApp": 6,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment