Minor Cleanup+
parent
715b0e54cc
commit
4857ce846e
|
@ -226,4 +226,19 @@ module.exports = function(s,config){
|
|||
break;
|
||||
}
|
||||
}
|
||||
s.createTimeout = function(timeoutVar,timeoutLength,defaultLength,multiplier,callback){
|
||||
var theTimeout
|
||||
if(!multiplier)multiplier = 1000 * 60
|
||||
if(!timeoutLength || timeoutLength === ''){
|
||||
theTimeout = defaultLength
|
||||
}else{
|
||||
theTimeout = parseFloat(timeoutLength) * multiplier
|
||||
}
|
||||
clearTimeout(timeoutVar)
|
||||
timeoutVar = setTimeout(function(){
|
||||
clearTimeout(timeoutVar)
|
||||
delete(timeoutVar)
|
||||
if(callback)callback()
|
||||
},theTimeout)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -300,7 +300,7 @@ module.exports = function(s,config,lang){
|
|||
})
|
||||
|
||||
if(filter.webhook && currentConfig.detector_webhook === '1'){
|
||||
var detector_webhook_url = addEventDetailsToString(currentConfig.detector_webhook_url)
|
||||
var detector_webhook_url = addEventDetailsToString(d,currentConfig.detector_webhook_url)
|
||||
request({url:detector_webhook_url,method:'GET',encoding:null},function(err,data){
|
||||
if(err){
|
||||
s.userLog(d,{type:lang["Event Webhook Error"],msg:{error:err,data:data}})
|
||||
|
@ -309,8 +309,8 @@ module.exports = function(s,config,lang){
|
|||
}
|
||||
|
||||
if(filter.command && currentConfig.detector_command_enable === '1' && !s.group[d.ke].mon[d.id].detector_command){
|
||||
s.createMonitorTimeout('detector_command',currentConfig.detector_command_timeout,10)
|
||||
var detector_command = addEventDetailsToString(currentConfig.detector_command)
|
||||
s.createTimeout(s.group[d.ke].mon[d.id].detector_command,currentConfig.detector_command_timeout,10)
|
||||
var detector_command = addEventDetailsToString(d,currentConfig.detector_command)
|
||||
exec(detector_command,{detached: true})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1552,19 +1552,4 @@ module.exports = function(s,config,lang){
|
|||
}
|
||||
})
|
||||
}
|
||||
s.createMonitorTimeout = function(nameOftTimeout,timeoutLength,defaultLength,multiplier,callback){
|
||||
var theTimeout
|
||||
if(!multiplier)multiplier = 1000 * 60
|
||||
if(!timeoutLength || timeoutLength === ''){
|
||||
theTimeout = defaultLength
|
||||
}else{
|
||||
theTimeout = parseFloat(timeoutLength) * multiplier
|
||||
}
|
||||
clearTimeout(s.group[d.ke].mon[d.id][nameOftTimeout])
|
||||
s.group[d.ke].mon[d.id][nameOftTimeout] = setTimeout(function(){
|
||||
clearTimeout(s.group[d.ke].mon[d.id][nameOftTimeout])
|
||||
delete(s.group[d.ke].mon[d.id][nameOftTimeout])
|
||||
if(callback)callback()
|
||||
},theTimeout)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue