@ -18,10 +18,10 @@ const apicache = require("../modules/apicache");
const { UptimeKumaServer } = require ( "../uptime-kuma-server" ) ;
const { UptimeKumaServer } = require ( "../uptime-kuma-server" ) ;
const { CacheableDnsHttpAgent } = require ( "../cacheable-dns-http-agent" ) ;
const { CacheableDnsHttpAgent } = require ( "../cacheable-dns-http-agent" ) ;
const { DockerHost } = require ( "../docker" ) ;
const { DockerHost } = require ( "../docker" ) ;
const { UptimeCacheList } = require ( "../uptime-cache-list" ) ;
const Gamedig = require ( "gamedig" ) ;
const Gamedig = require ( "gamedig" ) ;
const jsonata = require ( "jsonata" ) ;
const jsonata = require ( "jsonata" ) ;
const jwt = require ( "jsonwebtoken" ) ;
const jwt = require ( "jsonwebtoken" ) ;
const { UptimeCalculator } = require ( "../uptime-calculator" ) ;
/ * *
/ * *
* status :
* status :
@ -33,9 +33,12 @@ const jwt = require("jsonwebtoken");
class Monitor extends BeanModel {
class Monitor extends BeanModel {
/ * *
/ * *
* Return an object that ready to parse to JSON for public
* Return an object that ready to parse to JSON for public Only show
* Only show necessary data to public
* necessary data to public
* @ returns { Object }
* @ param { boolean } showTags Include tags in JSON
* @ param { boolean } certExpiry Include certificate expiry info in
* JSON
* @ returns { object } Object ready to parse
* /
* /
async toPublicJSON ( showTags = false , certExpiry = false ) {
async toPublicJSON ( showTags = false , certExpiry = false ) {
let obj = {
let obj = {
@ -64,7 +67,9 @@ class Monitor extends BeanModel {
/ * *
/ * *
* Return an object that ready to parse to JSON
* Return an object that ready to parse to JSON
* @ returns { Object }
* @ param { boolean } includeSensitiveData Include sensitive data in
* JSON
* @ returns { object } Object ready to parse
* /
* /
async toJSON ( includeSensitiveData = true ) {
async toJSON ( includeSensitiveData = true ) {
@ -183,7 +188,7 @@ class Monitor extends BeanModel {
/ * *
/ * *
* Checks if the monitor is active based on itself and its parents
* Checks if the monitor is active based on itself and its parents
* @ returns { Promise < Boolean > }
* @ returns { Promise < boolean > } Is the monitor active ?
* /
* /
async isActive ( ) {
async isActive ( ) {
const parentActive = await Monitor . isParentActive ( this . id ) ;
const parentActive = await Monitor . isParentActive ( this . id ) ;
@ -193,7 +198,8 @@ class Monitor extends BeanModel {
/ * *
/ * *
* Get all tags applied to this monitor
* Get all tags applied to this monitor
* @ returns { Promise < LooseObject < any > [ ] > }
* @ returns { Promise < LooseObject < any > [ ] > } List of tags on the
* monitor
* /
* /
async getTags ( ) {
async getTags ( ) {
return await R . getAll ( "SELECT mt.*, tag.name, tag.color FROM monitor_tag mt JOIN tag ON mt.tag_id = tag.id WHERE mt.monitor_id = ? ORDER BY tag.name" , [ this . id ] ) ;
return await R . getAll ( "SELECT mt.*, tag.name, tag.color FROM monitor_tag mt JOIN tag ON mt.tag_id = tag.id WHERE mt.monitor_id = ? ORDER BY tag.name" , [ this . id ] ) ;
@ -202,7 +208,8 @@ class Monitor extends BeanModel {
/ * *
/ * *
* Gets certificate expiry for this monitor
* Gets certificate expiry for this monitor
* @ param { number } monitorID ID of monitor to send
* @ param { number } monitorID ID of monitor to send
* @ returns { Promise < LooseObject < any >> }
* @ returns { Promise < LooseObject < any >> } Certificate expiry info for
* monitor
* /
* /
async getCertExpiry ( monitorID ) {
async getCertExpiry ( monitorID ) {
let tlsInfoBean = await R . findOne ( "monitor_tls_info" , "monitor_id = ?" , [
let tlsInfoBean = await R . findOne ( "monitor_tls_info" , "monitor_id = ?" , [
@ -227,7 +234,9 @@ class Monitor extends BeanModel {
/ * *
/ * *
* Encode user and password to Base64 encoding
* Encode user and password to Base64 encoding
* for HTTP "basic" auth , as per RFC - 7617
* for HTTP "basic" auth , as per RFC - 7617
* @ returns { string }
* @ param { string } user Username to encode
* @ param { string } pass Password to encode
* @ returns { string } Encoded username : password
* /
* /
encodeBase64 ( user , pass ) {
encodeBase64 ( user , pass ) {
return Buffer . from ( user + ":" + pass ) . toString ( "base64" ) ;
return Buffer . from ( user + ":" + pass ) . toString ( "base64" ) ;
@ -235,7 +244,7 @@ class Monitor extends BeanModel {
/ * *
/ * *
* Is the TLS expiry notification enabled ?
* Is the TLS expiry notification enabled ?
* @ returns { boolean }
* @ returns { boolean } Enabled ?
* /
* /
isEnabledExpiryNotification ( ) {
isEnabledExpiryNotification ( ) {
return Boolean ( this . expiryNotification ) ;
return Boolean ( this . expiryNotification ) ;
@ -243,7 +252,7 @@ class Monitor extends BeanModel {
/ * *
/ * *
* Parse to boolean
* Parse to boolean
* @ returns { boolean }
* @ returns { boolean } Should TLS errors be ignored ?
* /
* /
getIgnoreTls ( ) {
getIgnoreTls ( ) {
return Boolean ( this . ignoreTls ) ;
return Boolean ( this . ignoreTls ) ;
@ -251,7 +260,7 @@ class Monitor extends BeanModel {
/ * *
/ * *
* Parse to boolean
* Parse to boolean
* @ returns { boolean }
* @ returns { boolean } Is the monitor in upside down mode ?
* /
* /
isUpsideDown ( ) {
isUpsideDown ( ) {
return Boolean ( this . upsideDown ) ;
return Boolean ( this . upsideDown ) ;
@ -259,7 +268,7 @@ class Monitor extends BeanModel {
/ * *
/ * *
* Parse to boolean
* Parse to boolean
* @ returns { boolean }
* @ returns { boolean } Invert keyword match ?
* /
* /
isInvertKeyword ( ) {
isInvertKeyword ( ) {
return Boolean ( this . invertKeyword ) ;
return Boolean ( this . invertKeyword ) ;
@ -267,7 +276,7 @@ class Monitor extends BeanModel {
/ * *
/ * *
* Parse to boolean
* Parse to boolean
* @ returns { boolean }
* @ returns { boolean } Enable TLS for gRPC ?
* /
* /
getGrpcEnableTls ( ) {
getGrpcEnableTls ( ) {
return Boolean ( this . grpcEnableTls ) ;
return Boolean ( this . grpcEnableTls ) ;
@ -275,12 +284,15 @@ class Monitor extends BeanModel {
/ * *
/ * *
* Get accepted status codes
* Get accepted status codes
* @ returns { Object }
* @ returns { object } Accepted status codes
* /
* /
getAcceptedStatuscodes ( ) {
getAcceptedStatuscodes ( ) {
return JSON . parse ( this . accepted _statuscodes _json ) ;
return JSON . parse ( this . accepted _statuscodes _json ) ;
}
}
/ * *
*
* /
getGameDigGivenPortOnly ( ) {
getGameDigGivenPortOnly ( ) {
return Boolean ( this . gamedigGivenPortOnly ) ;
return Boolean ( this . gamedigGivenPortOnly ) ;
}
}
@ -288,6 +300,7 @@ class Monitor extends BeanModel {
/ * *
/ * *
* Start monitor
* Start monitor
* @ param { Server } io Socket server instance
* @ param { Server } io Socket server instance
* @ returns { void }
* /
* /
start ( io ) {
start ( io ) {
let previousBeat = null ;
let previousBeat = null ;
@ -332,13 +345,6 @@ class Monitor extends BeanModel {
bean . status = flipStatus ( bean . status ) ;
bean . status = flipStatus ( bean . status ) ;
}
}
// Duration
if ( ! isFirstBeat ) {
bean . duration = dayjs ( bean . time ) . diff ( dayjs ( previousBeat . time ) , "second" ) ;
} else {
bean . duration = 0 ;
}
try {
try {
if ( await Monitor . isUnderMaintenance ( this . id ) ) {
if ( await Monitor . isUnderMaintenance ( this . id ) ) {
bean . msg = "Monitor under maintenance" ;
bean . msg = "Monitor under maintenance" ;
@ -957,11 +963,17 @@ class Monitor extends BeanModel {
log . warn ( "monitor" , ` Monitor # ${ this . id } ' ${ this . name } ': Failing: ${ bean . msg } | Interval: ${ beatInterval } seconds | Type: ${ this . type } | Down Count: ${ bean . downCount } | Resend Interval: ${ this . resendInterval } ` ) ;
log . warn ( "monitor" , ` Monitor # ${ this . id } ' ${ this . name } ': Failing: ${ bean . msg } | Interval: ${ beatInterval } seconds | Type: ${ this . type } | Down Count: ${ bean . downCount } | Resend Interval: ${ this . resendInterval } ` ) ;
}
}
// Calculate uptime
let uptimeCalculator = await UptimeCalculator . getUptimeCalculator ( this . id ) ;
let endTimeDayjs = await uptimeCalculator . update ( bean . status , parseFloat ( bean . ping ) ) ;
bean . end _time = R . isoDateTimeMillis ( endTimeDayjs ) ;
// Send to frontend
log . debug ( "monitor" , ` [ ${ this . name } ] Send to socket ` ) ;
log . debug ( "monitor" , ` [ ${ this . name } ] Send to socket ` ) ;
UptimeCacheList . clearCache ( this . id ) ;
io . to ( this . user _id ) . emit ( "heartbeat" , bean . toJSON ( ) ) ;
io . to ( this . user _id ) . emit ( "heartbeat" , bean . toJSON ( ) ) ;
Monitor . sendStats ( io , this . id , this . user _id ) ;
Monitor . sendStats ( io , this . id , this . user _id ) ;
// Store to database
log . debug ( "monitor" , ` [ ${ this . name } ] Store ` ) ;
log . debug ( "monitor" , ` [ ${ this . name } ] Store ` ) ;
await R . store ( bean ) ;
await R . store ( bean ) ;
@ -979,7 +991,10 @@ class Monitor extends BeanModel {
} ;
} ;
/** Get a heartbeat and handle errors */
/ * *
* Get a heartbeat and handle errors7
* @ returns { void }
* /
const safeBeat = async ( ) => {
const safeBeat = async ( ) => {
try {
try {
await beat ( ) ;
await beat ( ) ;
@ -1007,10 +1022,10 @@ class Monitor extends BeanModel {
/ * *
/ * *
* Make a request using axios
* Make a request using axios
* @ param { O bject} options Options for Axios
* @ param { o bject} options Options for Axios
* @ param { boolean } finalCall Should this be the final call i . e
* @ param { boolean } finalCall Should this be the final call i . e
* don ' t retry on fa l iure
* don ' t retry on fa il ure
* @ returns { O bject} Axios response
* @ returns { o bject} Axios response
* /
* /
async makeAxiosRequest ( options , finalCall = false ) {
async makeAxiosRequest ( options , finalCall = false ) {
try {
try {
@ -1045,7 +1060,10 @@ class Monitor extends BeanModel {
}
}
}
}
/** Stop monitor */
/ * *
* Stop monitor
* @ returns { void }
* /
stop ( ) {
stop ( ) {
clearTimeout ( this . heartbeatInterval ) ;
clearTimeout ( this . heartbeatInterval ) ;
this . isStop = true ;
this . isStop = true ;
@ -1055,7 +1073,7 @@ class Monitor extends BeanModel {
/ * *
/ * *
* Get prometheus instance
* Get prometheus instance
* @ returns { Prometheus | undefined }
* @ returns { Prometheus | undefined } Current prometheus instance
* /
* /
getPrometheus ( ) {
getPrometheus ( ) {
return this . prometheus ;
return this . prometheus ;
@ -1065,7 +1083,7 @@ class Monitor extends BeanModel {
* Helper Method :
* Helper Method :
* returns URL object for further usage
* returns URL object for further usage
* returns null if url is invalid
* returns null if url is invalid
* @ returns { ( null | URL ) }
* @ returns { ( null | URL ) } Monitor URL
* /
* /
getUrl ( ) {
getUrl ( ) {
try {
try {
@ -1077,8 +1095,8 @@ class Monitor extends BeanModel {
/ * *
/ * *
* Store TLS info to database
* Store TLS info to database
* @ param checkCertificateResult
* @ param { object } checkCertificateResult Certificate to update
* @ returns { Promise < Object > }
* @ returns { Promise < object > } Updated certificate
* /
* /
async updateTlsInfo ( checkCertificateResult ) {
async updateTlsInfo ( checkCertificateResult ) {
let tlsInfoBean = await R . findOne ( "monitor_tls_info" , "monitor_id = ?" , [
let tlsInfoBean = await R . findOne ( "monitor_tls_info" , "monitor_id = ?" , [
@ -1125,47 +1143,41 @@ class Monitor extends BeanModel {
* @ param { Server } io Socket server instance
* @ param { Server } io Socket server instance
* @ param { number } monitorID ID of monitor to send
* @ param { number } monitorID ID of monitor to send
* @ param { number } userID ID of user to send to
* @ param { number } userID ID of user to send to
* @ returns { void }
* /
* /
static async sendStats ( io , monitorID , userID ) {
static async sendStats ( io , monitorID , userID ) {
const hasClients = getTotalClientInRoom ( io , userID ) > 0 ;
const hasClients = getTotalClientInRoom ( io , userID ) > 0 ;
let uptimeCalculator = await UptimeCalculator . getUptimeCalculator ( monitorID ) ;
if ( hasClients ) {
if ( hasClients ) {
await Monitor . sendAvgPing ( 24 , io , monitorID , userID ) ;
// Send 24 hour average ping
await Monitor . sendUptime ( 24 , io , monitorID , userID ) ;
let data24h = await uptimeCalculator . get24Hour ( ) ;
await Monitor . sendUptime ( 24 * 30 , io , monitorID , userID ) ;
io . to ( userID ) . emit ( "avgPing" , monitorID , ( data24h . avgPing ) ? data24h . avgPing . toFixed ( 2 ) : null ) ;
// Send 24 hour uptime
io . to ( userID ) . emit ( "uptime" , monitorID , 24 , data24h . uptime ) ;
// Send 30 day uptime
let data30d = await uptimeCalculator . get30Day ( ) ;
io . to ( userID ) . emit ( "uptime" , monitorID , 720 , data30d . uptime ) ;
// Send 1-year uptime
let data1y = await uptimeCalculator . get1Year ( ) ;
io . to ( userID ) . emit ( "uptime" , monitorID , "1y" , data1y . uptime ) ;
// Send Cert Info
await Monitor . sendCertInfo ( io , monitorID , userID ) ;
await Monitor . sendCertInfo ( io , monitorID , userID ) ;
} else {
} else {
log . debug ( "monitor" , "No clients in the room, no need to send stats" ) ;
log . debug ( "monitor" , "No clients in the room, no need to send stats" ) ;
}
}
}
}
/ * *
* Send the average ping to user
* @ param { number } duration Hours
* /
static async sendAvgPing ( duration , io , monitorID , userID ) {
const timeLogger = new TimeLogger ( ) ;
let avgPing = parseInt ( await R . getCell ( `
SELECT AVG ( ping )
FROM heartbeat
WHERE time > DATETIME ( 'now' , ? || ' hours' )
AND ping IS NOT NULL
AND monitor _id = ? ` , [
- duration ,
monitorID ,
] ) ) ;
timeLogger . print ( ` [Monitor: ${ monitorID } ] avgPing ` ) ;
io . to ( userID ) . emit ( "avgPing" , monitorID , avgPing ) ;
}
/ * *
/ * *
* Send certificate information to client
* Send certificate information to client
* @ param { Server } io Socket server instance
* @ param { Server } io Socket server instance
* @ param { number } monitorID ID of monitor to send
* @ param { number } monitorID ID of monitor to send
* @ param { number } userID ID of user to send to
* @ param { number } userID ID of user to send to
* @ returns { void }
* /
* /
static async sendCertInfo ( io , monitorID , userID ) {
static async sendCertInfo ( io , monitorID , userID ) {
let tlsInfo = await R . findOne ( "monitor_tls_info" , "monitor_id = ?" , [
let tlsInfo = await R . findOne ( "monitor_tls_info" , "monitor_id = ?" , [
@ -1176,98 +1188,6 @@ class Monitor extends BeanModel {
}
}
}
}
/ * *
* Uptime with calculation
* Calculation based on :
* https : //www.uptrends.com/support/kb/reporting/calculation-of-uptime-and-downtime
* @ param { number } duration Hours
* @ param { number } monitorID ID of monitor to calculate
* /
static async calcUptime ( duration , monitorID , forceNoCache = false ) {
if ( ! forceNoCache ) {
let cachedUptime = UptimeCacheList . getUptime ( monitorID , duration ) ;
if ( cachedUptime != null ) {
return cachedUptime ;
}
}
const timeLogger = new TimeLogger ( ) ;
const startTime = R . isoDateTime ( dayjs . utc ( ) . subtract ( duration , "hour" ) ) ;
// Handle if heartbeat duration longer than the target duration
// e.g. If the last beat's duration is bigger that the 24hrs window, it will use the duration between the (beat time - window margin) (THEN case in SQL)
let result = await R . getRow ( `
SELECT
-- SUM all duration , also trim off the beat out of time window
SUM (
CASE
WHEN ( JULIANDAY ( \ ` time \` ) - JULIANDAY(?)) * 86400 < duration
THEN ( JULIANDAY ( \ ` time \` ) - JULIANDAY(?)) * 86400
ELSE duration
END
) AS total _duration ,
-- SUM all uptime duration , also trim off the beat out of time window
SUM (
CASE
WHEN ( status = 1 OR status = 3 )
THEN
CASE
WHEN ( JULIANDAY ( \ ` time \` ) - JULIANDAY(?)) * 86400 < duration
THEN ( JULIANDAY ( \ ` time \` ) - JULIANDAY(?)) * 86400
ELSE duration
END
END
) AS uptime _duration
FROM heartbeat
WHERE time > ?
AND monitor _id = ?
` , [
startTime , startTime , startTime , startTime , startTime ,
monitorID ,
] ) ;
timeLogger . print ( ` [Monitor: ${ monitorID } ][ ${ duration } ] sendUptime ` ) ;
let totalDuration = result . total _duration ;
let uptimeDuration = result . uptime _duration ;
let uptime = 0 ;
if ( totalDuration > 0 ) {
uptime = uptimeDuration / totalDuration ;
if ( uptime < 0 ) {
uptime = 0 ;
}
} else {
// Handle new monitor with only one beat, because the beat's duration = 0
let status = parseInt ( await R . getCell ( "SELECT `status` FROM heartbeat WHERE monitor_id = ?" , [ monitorID ] ) ) ;
if ( status === UP ) {
uptime = 1 ;
}
}
// Cache
UptimeCacheList . addUptime ( monitorID , duration , uptime ) ;
return uptime ;
}
/ * *
* Send Uptime
* @ param { number } duration Hours
* @ param { Server } io Socket server instance
* @ param { number } monitorID ID of monitor to send
* @ param { number } userID ID of user to send to
* /
static async sendUptime ( duration , io , monitorID , userID ) {
const uptime = await this . calcUptime ( duration , monitorID ) ;
io . to ( userID ) . emit ( "uptime" , monitorID , duration , uptime ) ;
}
/ * *
/ * *
* Has status of monitor changed since last beat ?
* Has status of monitor changed since last beat ?
* @ param { boolean } isFirstBeat Is this the first beat of this monitor ?
* @ param { boolean } isFirstBeat Is this the first beat of this monitor ?
@ -1336,6 +1256,7 @@ class Monitor extends BeanModel {
* @ param { boolean } isFirstBeat Is this beat the first of this monitor ?
* @ param { boolean } isFirstBeat Is this beat the first of this monitor ?
* @ param { Monitor } monitor The monitor to send a notificaton about
* @ param { Monitor } monitor The monitor to send a notificaton about
* @ param { Bean } bean Status information about monitor
* @ param { Bean } bean Status information about monitor
* @ returns { void }
* /
* /
static async sendNotification ( isFirstBeat , monitor , bean ) {
static async sendNotification ( isFirstBeat , monitor , bean ) {
if ( ! isFirstBeat || bean . status === DOWN ) {
if ( ! isFirstBeat || bean . status === DOWN ) {
@ -1376,7 +1297,7 @@ class Monitor extends BeanModel {
/ * *
/ * *
* Get list of notification providers for a given monitor
* Get list of notification providers for a given monitor
* @ param { Monitor } monitor Monitor to get notification providers for
* @ param { Monitor } monitor Monitor to get notification providers for
* @ returns { Promise < LooseObject < any > [ ] > }
* @ returns { Promise < LooseObject < any > [ ] > } List of notifications
* /
* /
static async getNotificationList ( monitor ) {
static async getNotificationList ( monitor ) {
let notificationList = await R . getAll ( "SELECT notification.* FROM notification, monitor_notification WHERE monitor_id = ? AND monitor_notification.notification_id = notification.id " , [
let notificationList = await R . getAll ( "SELECT notification.* FROM notification, monitor_notification WHERE monitor_id = ? AND monitor_notification.notification_id = notification.id " , [
@ -1387,7 +1308,8 @@ class Monitor extends BeanModel {
/ * *
/ * *
* checks certificate chain for expiring certificates
* checks certificate chain for expiring certificates
* @ param { Object } tlsInfoObject Information about certificate
* @ param { object } tlsInfoObject Information about certificate
* @ returns { void }
* /
* /
async checkCertExpiryNotifications ( tlsInfoObject ) {
async checkCertExpiryNotifications ( tlsInfoObject ) {
if ( tlsInfoObject && tlsInfoObject . certInfo && tlsInfoObject . certInfo . daysRemaining ) {
if ( tlsInfoObject && tlsInfoObject . certInfo && tlsInfoObject . certInfo . daysRemaining ) {
@ -1474,7 +1396,7 @@ class Monitor extends BeanModel {
/ * *
/ * *
* Get the status of the previous heartbeat
* Get the status of the previous heartbeat
* @ param { number } monitorID ID of monitor to check
* @ param { number } monitorID ID of monitor to check
* @ returns { Promise < LooseObject < any >> }
* @ returns { Promise < LooseObject < any >> } Previous heartbeat
* /
* /
static async getPreviousHeartbeat ( monitorID ) {
static async getPreviousHeartbeat ( monitorID ) {
return await R . getRow ( `
return await R . getRow ( `
@ -1488,7 +1410,7 @@ class Monitor extends BeanModel {
/ * *
/ * *
* Check if monitor is under maintenance
* Check if monitor is under maintenance
* @ param { number } monitorID ID of monitor to check
* @ param { number } monitorID ID of monitor to check
* @ returns { Promise < boolean > }
* @ returns { Promise < boolean > } Is the monitor under maintenance
* /
* /
static async isUnderMaintenance ( monitorID ) {
static async isUnderMaintenance ( monitorID ) {
const maintenanceIDList = await R . getCol ( `
const maintenanceIDList = await R . getCol ( `
@ -1511,7 +1433,11 @@ class Monitor extends BeanModel {
return false ;
return false ;
}
}
/** Make sure monitor interval is between bounds */
/ * *
* Make sure monitor interval is between bounds
* @ returns { void }
* @ throws Interval is outside of range
* /
validate ( ) {
validate ( ) {
if ( this . interval > MAX _INTERVAL _SECOND ) {
if ( this . interval > MAX _INTERVAL _SECOND ) {
throw new Error ( ` Interval cannot be more than ${ MAX _INTERVAL _SECOND } seconds ` ) ;
throw new Error ( ` Interval cannot be more than ${ MAX _INTERVAL _SECOND } seconds ` ) ;
@ -1524,7 +1450,7 @@ class Monitor extends BeanModel {
/ * *
/ * *
* Gets Parent of the monitor
* Gets Parent of the monitor
* @ param { number } monitorID ID of monitor to get
* @ param { number } monitorID ID of monitor to get
* @ returns { Promise < LooseObject < any >> }
* @ returns { Promise < LooseObject < any >> } Parent
* /
* /
static async getParent ( monitorID ) {
static async getParent ( monitorID ) {
return await R . getRow ( `
return await R . getRow ( `
@ -1540,7 +1466,7 @@ class Monitor extends BeanModel {
/ * *
/ * *
* Gets all Children of the monitor
* Gets all Children of the monitor
* @ param { number } monitorID ID of monitor to get
* @ param { number } monitorID ID of monitor to get
* @ returns { Promise < LooseObject < any >> }
* @ returns { Promise < LooseObject < any >> } Children
* /
* /
static async getChildren ( monitorID ) {
static async getChildren ( monitorID ) {
return await R . getAll ( `
return await R . getAll ( `
@ -1553,7 +1479,7 @@ class Monitor extends BeanModel {
/ * *
/ * *
* Gets Full Path - Name ( Groups and Name )
* Gets Full Path - Name ( Groups and Name )
* @ returns { Promise < String > }
* @ returns { Promise < string > } Full path name of this monitor
* /
* /
async getPathName ( ) {
async getPathName ( ) {
let path = this . name ;
let path = this . name ;
@ -1574,7 +1500,7 @@ class Monitor extends BeanModel {
/ * *
/ * *
* Gets recursive all child ids
* Gets recursive all child ids
* @ param { number } monitorID ID of the monitor to get
* @ param { number } monitorID ID of the monitor to get
* @ returns { Promise < Array > }
* @ returns { Promise < Array > } IDs of all children
* /
* /
static async getAllChildrenIDs ( monitorID ) {
static async getAllChildrenIDs ( monitorID ) {
const childs = await Monitor . getChildren ( monitorID ) ;
const childs = await Monitor . getChildren ( monitorID ) ;
@ -1607,7 +1533,7 @@ class Monitor extends BeanModel {
/ * *
/ * *
* Checks recursive if parent ( ancestors ) are active
* Checks recursive if parent ( ancestors ) are active
* @ param { number } monitorID ID of the monitor to get
* @ param { number } monitorID ID of the monitor to get
* @ returns { Promise < Boolean > }
* @ returns { Promise < boolean > } Is the parent monitor active ?
* /
* /
static async isParentActive ( monitorID ) {
static async isParentActive ( monitorID ) {
const parent = await Monitor . getParent ( monitorID ) ;
const parent = await Monitor . getParent ( monitorID ) ;