Przeglądaj źródła

Merge branch 'feature/server/recovery-notifications' of hostbbq/hostbbq-monitoring into master

tunefish 2 lat temu
rodzic
commit
f85bb2b368

+ 2 - 2
server/src/ctrl/http-check-controller.class.ts

@@ -121,7 +121,7 @@ export class HttpCheckController {
             if (lastErrors.length > conf.notifyThreshold) {
               Logger.debug(`[DEBUG] Sending [RECOVERY] FCM Notification for`, conf.title);
               await FCMController.instance.sendNotificationToTopic(defaults.fcmTopics.services, {
-                title: `[RECOVERY] ${conf.title} since ${moment(now).format('HH:mm')}`,
+                title: `[RECOVERY] ${moment(now).format('HH:mm')} ${conf.title}: [OK]`,
                 body: `HTTP Check '${conf.title}' has recovered to [OK].`
               });
             }
@@ -168,7 +168,7 @@ export class HttpCheckController {
           const lastCheck = lastErrors[0];
           const lastError = lastCheck.data[0];
           await FCMController.instance.sendNotificationToTopic(defaults.fcmTopics.services, {
-            title: `[CRIT] ${conf.title} failed at ${moment(lastCheck.time).format('HH:mm')}`,
+            title: `[CRIT] ${moment(lastCheck.time).format('HH:mm')} ${conf.title} failed`,
             body:
               `HTTP Check '${conf.title}' has failed over ${conf.notifyThreshold} times in a row.\n` +
               `Last error status was: (${lastError.status}) ${lastError.message}`

+ 3 - 2
server/src/ctrl/server-connector.class.ts

@@ -1,4 +1,5 @@
 import axios, { AxiosError } from 'axios';
+import moment from 'moment';
 
 import defaults from '../../../common/defaults.module';
 import { Logger } from '../../../common/util/logger.class';
@@ -61,7 +62,7 @@ export class ServerConnector {
         // notify [RECOVERY]
         try {
           await FCMController.instance.sendNotificationToTopic(defaults.fcmTopics.serverData, {
-            title: `[RECOVERY] Server '${server.title}': daemon OK`,
+            title: `[RECOVERY] ${moment().format('HH:mm')} Server '${server.title}': [OK]`,
             body: `[RECOVERY] Server '${server.title}': daemon OK`
           });
         } catch (err) {
@@ -77,7 +78,7 @@ export class ServerConnector {
           try {
             server.errors = (server.errors ?? 0) + 1;
             await FCMController.instance.sendNotificationToTopic(defaults.fcmTopics.serverData, {
-              title: `[WARN] Server '${server.title}': daemon unreachable (${err.code})`,
+              title: `[WARN] ${moment().format('HH:mm')} Server '${server.title}': daemon unreachable (${err.code})`,
               body: new String(err).toString()
             });
           } catch (err) {