This commit is contained in:
Miles Steele 2023-04-06 15:30:38 -05:00
parent 171aff1226
commit 682f8e52a8
1 changed files with 9 additions and 9 deletions

View File

@ -403,9 +403,9 @@ class Monitor extends BeanModel {
data = JSON.stringify(data); data = JSON.stringify(data);
} }
let keyword_found = data.includes(this.keyword); let keywordFound = data.includes(this.keyword);
if (keyword_found == !this.isInvertKeyword()) { if (keywordFound === !this.isInvertKeyword()) {
bean.msg += ", keyword " + (keyword_found ? "is" : "not") + " found"; bean.msg += ", keyword " + (keywordFound ? "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, " ");
@ -413,7 +413,7 @@ class Monitor extends BeanModel {
data = data.substring(0, 47) + "..."; data = data.substring(0, 47) + "...";
} }
throw new Error(bean.msg + ", but keyword is " + throw new Error(bean.msg + ", but keyword is " +
(keyword_found ? "present" : "not") + " in [" + data + "]"); (keywordFound ? "present" : "not") + " in [" + data + "]");
} }
} }
@ -626,14 +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 {
let keyword_found = response.data.toString().includes(this.keyword) let keywordFound = response.data.toString().includes(this.keyword);
if (keyword_found == !this.isInvertKeyword()) { if (keywordFound === !this.isInvertKeyword()) {
bean.status = UP; bean.status = UP;
bean.msg = `${responseData}, keyword [${this.keyword}] ${keyword_found ? "is" : "not"} found`; bean.msg = `${responseData}, keyword [${this.keyword}] ${keywordFound ? "is" : "not"} found`;
} else { } else {
log.debug("monitor:", `GRPC response [${response.data}] + ", but keyword [${this.keyword}] is ${keyword_found ? "present" : "not"} in [" + ${response.data} + "]"`); log.debug("monitor:", `GRPC response [${response.data}] + ", but keyword [${this.keyword}] is ${keywordFound ? "present" : "not"} in [" + ${response.data} + "]"`);
bean.status = DOWN; bean.status = DOWN;
bean.msg = `, but keyword [${this.keyword}] is ${keyword_found ? "present" : "not"} in [" + ${responseData} + "]`; bean.msg = `, but keyword [${this.keyword}] is ${keywordFound ? "present" : "not"} in [" + ${responseData} + "]`;
} }
} }
} else if (this.type === "postgres") { } else if (this.type === "postgres") {