From 1c3e1845664b0a6596c6878f28fec80b66f07774 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Fri, 29 Mar 2024 17:15:04 +0000 Subject: [PATCH] Fix probe offline notification template and update probe registration process --- .../Notification/Templates/ProbeOffline.hbs | 2 +- Ingestor/API/Probe.ts | 19 ++++++++++--------- Probe/Index.ts | 2 ++ Probe/Services/Register.ts | 4 ++-- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/App/FeatureSet/Notification/Templates/ProbeOffline.hbs b/App/FeatureSet/Notification/Templates/ProbeOffline.hbs index f27290493a..42f4bd1c26 100644 --- a/App/FeatureSet/Notification/Templates/ProbeOffline.hbs +++ b/App/FeatureSet/Notification/Templates/ProbeOffline.hbs @@ -15,7 +15,7 @@ {{> DetailBoxField title="Global Probe: " text="This is a global probe." }} {{/if}} {{> DetailBoxField title="Probe ID: " text=probeId }} -{{#if podId}} +{{#if hostname}} {{> DetailBoxField title="Hostname: " text=hostname }} {{/if}} {{> DetailBoxField title="Issue: " text=issue }} diff --git a/Ingestor/API/Probe.ts b/Ingestor/API/Probe.ts index e2920a638d..e71762540e 100644 --- a/Ingestor/API/Probe.ts +++ b/Ingestor/API/Probe.ts @@ -66,6 +66,9 @@ router.post( ] as boolean; } + isWebsiteCheckOffline = true; + isPingCheckOffline = true; + if (isWebsiteCheckOffline || isPingCheckOffline) { // email probe owner. const probeId: ObjectID = new ObjectID( @@ -160,18 +163,15 @@ router.post( 'This email is sent to you because you are listed as an owner of the project that this probe is associated with. To change this email, please visit the Project Dashboard > Settings > Teams and Members > Owners.'; } - const issue: string = ''; + let issue: string = ''; if (isWebsiteCheckOffline) { - issue.concat( - 'This probe cannot reach out to monitor websites' - ); + issue += 'This probe cannot reach out to monitor websites'; } if (isPingCheckOffline) { - issue.concat( - 'This probe cannot reach out to ping other servers / hostnames or IP addresses.' - ); + issue += + 'This probe cannot reach out to ping other servers / hostnames or IP addresses.'; } // now send an email to all the emailsToNotify @@ -180,10 +180,11 @@ router.post( { toEmail: email, templateType: EmailTemplateType.ProbeOffline, - subject: 'Probe Offline Notification', + subject: + 'ACTION REQUIRED: Probe Offline Notification', vars: { probeName: probe.name || '', - description: probe.description || '', + probeDescription: probe.description || '', projectId: probe.projectId?.toString() || '', probeId: probe.id?.toString() || '', hostname: diff --git a/Probe/Index.ts b/Probe/Index.ts index 50d2a42b9c..511890d267 100644 --- a/Probe/Index.ts +++ b/Probe/Index.ts @@ -20,6 +20,8 @@ const init: PromiseVoidFunction = async (): Promise => { await Register.registerProbe(); logger.info('Probe registered'); + + await Register.reportIfOffline(); } catch (err) { logger.error('Register probe failed'); logger.error(err); diff --git a/Probe/Services/Register.ts b/Probe/Services/Register.ts index 5673140b99..061934abfe 100644 --- a/Probe/Services/Register.ts +++ b/Probe/Services/Register.ts @@ -19,7 +19,7 @@ import ProbeAPIRequest from '../Utils/ProbeAPIRequest'; import OnlineCheck from '../Utils/OnlineCheck'; export default class Register { - public static async reportOfflineStatus(): Promise { + public static async reportIfOffline(): Promise { const pingMonitoringCheck: boolean = await OnlineCheck.canProbeMonitorPingMonitors(); const websiteMonitoringCheck: boolean = @@ -41,7 +41,7 @@ export default class Register { await API.fetch( HTTPMethod.POST, URL.fromString(INGESTOR_URL.toString()).addRoute( - '/probe/response/ingest' + '/probe/status-report/offline' ), { ...ProbeAPIRequest.getDefaultRequestBody(),