|
|
@ -451,12 +451,14 @@ class Monitor extends BeanModel {
|
|
|
|
let tls_info_bean = await R.findOne("monitor_tls_info", "monitor_id = ?", [
|
|
|
|
let tls_info_bean = await R.findOne("monitor_tls_info", "monitor_id = ?", [
|
|
|
|
this.id,
|
|
|
|
this.id,
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
if (tls_info_bean == null) {
|
|
|
|
if (tls_info_bean == null) {
|
|
|
|
tls_info_bean = R.dispense("monitor_tls_info");
|
|
|
|
tls_info_bean = R.dispense("monitor_tls_info");
|
|
|
|
tls_info_bean.monitor_id = this.id;
|
|
|
|
tls_info_bean.monitor_id = this.id;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
// Clear sent history if the cert changed.
|
|
|
|
// Clear sent history if the cert changed.
|
|
|
|
|
|
|
|
try {
|
|
|
|
let oldCertInfo = JSON.parse(tls_info_bean.info_json);
|
|
|
|
let oldCertInfo = JSON.parse(tls_info_bean.info_json);
|
|
|
|
|
|
|
|
|
|
|
|
let isValidObjects = oldCertInfo && oldCertInfo.certInfo && checkCertificateResult && checkCertificateResult.certInfo;
|
|
|
|
let isValidObjects = oldCertInfo && oldCertInfo.certInfo && checkCertificateResult && checkCertificateResult.certInfo;
|
|
|
@ -475,6 +477,9 @@ class Monitor extends BeanModel {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
debug("Not valid object");
|
|
|
|
debug("Not valid object");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (e) { }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tls_info_bean.info_json = JSON.stringify(checkCertificateResult);
|
|
|
|
tls_info_bean.info_json = JSON.stringify(checkCertificateResult);
|
|
|
|
await R.store(tls_info_bean);
|
|
|
|
await R.store(tls_info_bean);
|
|
|
@ -690,7 +695,7 @@ class Monitor extends BeanModel {
|
|
|
|
for (let notification of notificationList) {
|
|
|
|
for (let notification of notificationList) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
debug("Sending to " + notification.name);
|
|
|
|
debug("Sending to " + notification.name);
|
|
|
|
await Notification.send(JSON.parse(notification.config), `The certificate of ${this.url} will be expired in ${daysRemaining} days`);
|
|
|
|
await Notification.send(JSON.parse(notification.config), `[${this.name}][${this.url}] Certificate will be expired in ${daysRemaining} days`);
|
|
|
|
sent = true;
|
|
|
|
sent = true;
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
console.error("Cannot send cert notification to " + notification.name);
|
|
|
|
console.error("Cannot send cert notification to " + notification.name);
|
|
|
|