@ -3,7 +3,7 @@ const dayjs = require("dayjs");
const axios = require ( "axios" ) ;
const { Prometheus } = require ( "../prometheus" ) ;
const { log , UP , DOWN , PENDING , MAINTENANCE , flipStatus , MAX _INTERVAL _SECOND , MIN _INTERVAL _SECOND ,
SQL _DATETIME _FORMAT , isDev , sleep , getRandomInt
SQL _DATETIME _FORMAT
} = require ( "../../src/util" ) ;
const { tcping , ping , checkCertificate , checkStatusCode , getTotalClientInRoom , setting , mssqlQuery , postgresQuery , mysqlQuery , mqttAsync , setSetting , httpNtlm , radius , grpcQuery ,
redisPingAsync , mongodbPing , kafkaProducerAsync , getOidcTokenClientCredentials , rootCertificatesFingerprints , axiosAbortSignal
@ -343,16 +343,6 @@ class Monitor extends BeanModel {
}
}
// Evil
if ( isDev ) {
if ( process . env . EVIL _RANDOM _MONITOR _SLEEP === "SURE" ) {
if ( getRandomInt ( 0 , 100 ) === 0 ) {
log . debug ( "evil" , ` [ ${ this . name } ] Evil mode: Random sleep: ` + beatInterval * 10000 ) ;
await sleep ( beatInterval * 10000 ) ;
}
}
}
// Expose here for prometheus update
// undefined if not https
let tlsInfo = undefined ;
@ -492,7 +482,7 @@ class Monitor extends BeanModel {
validateStatus : ( status ) => {
return checkStatusCode ( status , this . getAcceptedStatuscodes ( ) ) ;
} ,
signal : axiosAbortSignal ( this . timeout * 1000 ) ,
signal : axiosAbortSignal ( ( this . timeout + 10 ) * 1000 ) ,
} ;
if ( bodyValue ) {
@ -905,7 +895,11 @@ class Monitor extends BeanModel {
} catch ( error ) {
bean . msg = error . message ;
if ( error ? . name === "CanceledError" ) {
bean . msg = ` timeout by AbortSignal ( ${ this . timeout } s) ` ;
} else {
bean . msg = error . message ;
}
// If UP come in here, it must be upside down mode
// Just reset the retries
@ -1001,7 +995,6 @@ class Monitor extends BeanModel {
log . debug ( "monitor" , ` [ ${ this . name } ] Next heartbeat in: ${ intervalRemainingMs } ms ` ) ;
this . heartbeatInterval = setTimeout ( safeBeat , intervalRemainingMs ) ;
this . lastScheduleBeatTime = dayjs ( ) ;
} else {
log . info ( "monitor" , ` [ ${ this . name } ] isStop = true, no next check. ` ) ;
}
@ -1014,9 +1007,7 @@ class Monitor extends BeanModel {
* /
const safeBeat = async ( ) => {
try {
this . lastStartBeatTime = dayjs ( ) ;
await beat ( ) ;
this . lastEndBeatTime = dayjs ( ) ;
} catch ( e ) {
console . trace ( e ) ;
UptimeKumaServer . errorLog ( e , false ) ;
@ -1025,9 +1016,6 @@ class Monitor extends BeanModel {
if ( ! this . isStop ) {
log . info ( "monitor" , "Try to restart the monitor" ) ;
this . heartbeatInterval = setTimeout ( safeBeat , this . interval * 1000 ) ;
this . lastScheduleBeatTime = dayjs ( ) ;
} else {
log . info ( "monitor" , "isStop = true, no next check." ) ;
}
}
} ;