|
|
@ -84,6 +84,7 @@ class Monitor extends BeanModel {
|
|
|
|
retryInterval: this.retryInterval,
|
|
|
|
retryInterval: this.retryInterval,
|
|
|
|
resendInterval: this.resendInterval,
|
|
|
|
resendInterval: this.resendInterval,
|
|
|
|
keyword: this.keyword,
|
|
|
|
keyword: this.keyword,
|
|
|
|
|
|
|
|
invertKeyword: this.isInvertKeyword(),
|
|
|
|
expiryNotification: this.isEnabledExpiryNotification(),
|
|
|
|
expiryNotification: this.isEnabledExpiryNotification(),
|
|
|
|
ignoreTls: this.getIgnoreTls(),
|
|
|
|
ignoreTls: this.getIgnoreTls(),
|
|
|
|
upsideDown: this.isUpsideDown(),
|
|
|
|
upsideDown: this.isUpsideDown(),
|
|
|
@ -183,6 +184,14 @@ class Monitor extends BeanModel {
|
|
|
|
return Boolean(this.upsideDown);
|
|
|
|
return Boolean(this.upsideDown);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Parse to boolean
|
|
|
|
|
|
|
|
* @returns {boolean}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
isInvertKeyword() {
|
|
|
|
|
|
|
|
return Boolean(this.invertKeyword);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Parse to boolean
|
|
|
|
* Parse to boolean
|
|
|
|
* @returns {boolean}
|
|
|
|
* @returns {boolean}
|
|
|
@ -394,15 +403,17 @@ class Monitor extends BeanModel {
|
|
|
|
data = JSON.stringify(data);
|
|
|
|
data = JSON.stringify(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (data.includes(this.keyword)) {
|
|
|
|
let keyword_found = data.includes(this.keyword);
|
|
|
|
bean.msg += ", keyword is found";
|
|
|
|
if (keyword_found == !this.isInvertKeyword()) {
|
|
|
|
|
|
|
|
bean.msg += ", keyword " + (keyword_found ? "is" : "not") + " found";
|
|
|
|
bean.status = UP;
|
|
|
|
bean.status = UP;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
data = data.replace(/<[^>]*>?|[\n\r]|\s+/gm, " ");
|
|
|
|
data = data.replace(/<[^>]*>?|[\n\r]|\s+/gm, " ");
|
|
|
|
if (data.length > 50) {
|
|
|
|
if (data.length > 50) {
|
|
|
|
data = data.substring(0, 47) + "...";
|
|
|
|
data = data.substring(0, 47) + "...";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
throw new Error(bean.msg + ", but keyword is not in [" + data + "]");
|
|
|
|
throw new Error(bean.msg + ", but keyword is " +
|
|
|
|
|
|
|
|
(keyword_found ? "present" : "not") + " in [" + data + "]");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -603,7 +614,6 @@ class Monitor extends BeanModel {
|
|
|
|
grpcEnableTls: this.grpcEnableTls,
|
|
|
|
grpcEnableTls: this.grpcEnableTls,
|
|
|
|
grpcMethod: this.grpcMethod,
|
|
|
|
grpcMethod: this.grpcMethod,
|
|
|
|
grpcBody: this.grpcBody,
|
|
|
|
grpcBody: this.grpcBody,
|
|
|
|
keyword: this.keyword
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
const response = await grpcQuery(options);
|
|
|
|
const response = await grpcQuery(options);
|
|
|
|
bean.ping = dayjs().valueOf() - startTime;
|
|
|
|
bean.ping = dayjs().valueOf() - startTime;
|
|
|
@ -616,13 +626,14 @@ class Monitor extends BeanModel {
|
|
|
|
bean.status = DOWN;
|
|
|
|
bean.status = DOWN;
|
|
|
|
bean.msg = `Error in send gRPC ${response.code} ${response.errorMessage}`;
|
|
|
|
bean.msg = `Error in send gRPC ${response.code} ${response.errorMessage}`;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (response.data.toString().includes(this.keyword)) {
|
|
|
|
let keyword_found = response.data.toString().includes(this.keyword)
|
|
|
|
|
|
|
|
if (keyword_found == !this.isInvertKeyword()) {
|
|
|
|
bean.status = UP;
|
|
|
|
bean.status = UP;
|
|
|
|
bean.msg = `${responseData}, keyword [${this.keyword}] is found`;
|
|
|
|
bean.msg = `${responseData}, keyword [${this.keyword}] ${keyword_found ? "is" : "not"} found`;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
log.debug("monitor:", `GRPC response [${response.data}] + ", but keyword [${this.keyword}] is not in [" + ${response.data} + "]"`);
|
|
|
|
log.debug("monitor:", `GRPC response [${response.data}] + ", but keyword [${this.keyword}] is ${keyword_found ? "present" : "not"} in [" + ${response.data} + "]"`);
|
|
|
|
bean.status = DOWN;
|
|
|
|
bean.status = DOWN;
|
|
|
|
bean.msg = `, but keyword [${this.keyword}] is not in [" + ${responseData} + "]`;
|
|
|
|
bean.msg = `, but keyword [${this.keyword}] is ${keyword_found ? "present" : "not"} in [" + ${responseData} + "]`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (this.type === "postgres") {
|
|
|
|
} else if (this.type === "postgres") {
|
|
|
|