Fix probe offline notification template and update probe registration process

This commit is contained in:
Simon Larsen 2024-03-29 17:15:04 +00:00
parent 4335377285
commit 1c3e184566
No known key found for this signature in database
GPG Key ID: AB45983AA9C81CDE
4 changed files with 15 additions and 12 deletions

View File

@ -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 }}

View File

@ -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:

View File

@ -20,6 +20,8 @@ const init: PromiseVoidFunction = async (): Promise<void> => {
await Register.registerProbe();
logger.info('Probe registered');
await Register.reportIfOffline();
} catch (err) {
logger.error('Register probe failed');
logger.error(err);

View File

@ -19,7 +19,7 @@ import ProbeAPIRequest from '../Utils/ProbeAPIRequest';
import OnlineCheck from '../Utils/OnlineCheck';
export default class Register {
public static async reportOfflineStatus(): Promise<void> {
public static async reportIfOffline(): Promise<void> {
const pingMonitoringCheck: boolean =
await OnlineCheck.canProbeMonitorPingMonitors();
const websiteMonitoringCheck: boolean =
@ -41,7 +41,7 @@ export default class Register {
await API.fetch<JSONObject>(
HTTPMethod.POST,
URL.fromString(INGESTOR_URL.toString()).addRoute(
'/probe/response/ingest'
'/probe/status-report/offline'
),
{
...ProbeAPIRequest.getDefaultRequestBody(),