From 97f933ee3237d28eb7fa66503ed73b44774031d7 Mon Sep 17 00:00:00 2001 From: beckerinj Date: Wed, 17 Aug 2022 10:12:28 -0400 Subject: [PATCH] improve daily updates with emojis pointing to warning location --- core/src/plugins/slackNotifier.ts | 21 ++++++++++++--------- core/src/util/slack.ts | 10 +++++----- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/core/src/plugins/slackNotifier.ts b/core/src/plugins/slackNotifier.ts index ce122f7c0..32469be83 100644 --- a/core/src/plugins/slackNotifier.ts +++ b/core/src/plugins/slackNotifier.ts @@ -146,12 +146,15 @@ const slackNotifier = fp((app: FastifyInstance, _: {}, done: () => void) => { .map((server) => { const stats = server.stats!; if (stats) { - const inWarning = - stats.cpu > (server.cpuAlert || CPU_USAGE_NOTIFY_LIMIT) || + const cpuInWarning = + stats.cpu > (server.cpuAlert || CPU_USAGE_NOTIFY_LIMIT); + const memInWarning = stats.mem.usedMemPercentage > - (server.memAlert || MEM_USAGE_NOTIFY_LIMIT) || + (server.memAlert || MEM_USAGE_NOTIFY_LIMIT); + const diskInWarning = stats.disk.usedPercentage > - (server.diskAlert || DISK_USAGE_NOTIFY_LIMIT); + (server.diskAlert || DISK_USAGE_NOTIFY_LIMIT); + const inWarning = cpuInWarning || memInWarning || diskInWarning; return [ { type: "section", @@ -159,13 +162,13 @@ const slackNotifier = fp((app: FastifyInstance, _: {}, done: () => void) => { type: "mrkdwn", text: `*${server.name}*${ server.region ? ` | ${server.region}` : "" - } | *${inWarning ? "WARNING" : "OK"}*\nCPU: *${ + } | *${inWarning ? "WARNING 🚨" : "OK ✅"}*\nCPU: *${ stats.cpu - }%*\nMEM: *${stats.mem.usedMemPercentage}%* (${ + }%*${cpuInWarning ? " 🚨" : ""}\nMEM: *${stats.mem.usedMemPercentage}%* (${ stats.mem.usedMemMb - } MB of ${stats.mem.totalMemMb} MB)\nDISK: *${ + } MB of ${stats.mem.totalMemMb} MB)${memInWarning ? " 🚨" : ""}\nDISK: *${ stats.disk.usedPercentage - }%* (${stats.disk.usedGb} GB of ${stats.disk.totalGb} GB)`, + }%* (${stats.disk.usedGb} GB of ${stats.disk.totalGb} GB)${diskInWarning ? " 🚨" : ""}`, }, }, { @@ -180,7 +183,7 @@ const slackNotifier = fp((app: FastifyInstance, _: {}, done: () => void) => { type: "mrkdwn", text: `*${server.name}*${ server.region ? ` | ${server.region}` : "" - } | *UNREACHABLE*`, + } | *UNREACHABLE* ❌ `, }, }, { diff --git a/core/src/util/slack.ts b/core/src/util/slack.ts index 0f155dc7b..d44400459 100644 --- a/core/src/util/slack.ts +++ b/core/src/util/slack.ts @@ -49,7 +49,7 @@ export async function notifySlackCpu( toNotify?: string[] ) { await notifySlackAdvanced( - `WARNING | ${name}${region ? ` (${region})` : ""} has high CPU usage`, + `WARNING | ${name}${region ? ` (${region})` : ""} has high CPU usage 📈 🚨`, [ HEADER, { @@ -91,7 +91,7 @@ export async function notifySlackMem( toNotify?: string[] ) { await notifySlackAdvanced( - `WARNING | ${name}${region ? ` (${region})` : ""} has high memory usage`, + `WARNING | ${name}${region ? ` (${region})` : ""} has high memory usage 💾 🚨`, [ HEADER, { @@ -135,7 +135,7 @@ export async function notifySlackDisk( toNotify?: string[] ) { await notifySlackAdvanced( - `WARNING | ${name}${region ? ` (${region})` : ""} has high disk usage`, + `WARNING | ${name}${region ? ` (${region})` : ""} has high disk usage 💿 🚨`, [ HEADER, { @@ -176,14 +176,14 @@ export async function notifySlackUnreachable( toNotify?: string[] ) { await notifySlackAdvanced( - `WARNING 🚨 | ${name}${region ? ` (${region})` : ""} is unreachable ❌`, + `WARNING 🚨 | ${name}${region ? ` (${region})` : ""} is unreachable ❌ 🚨`, [ HEADER, { type: "section", text: { type: "mrkdwn", - text: `*${name}*${region ? ` (${region})` : ""} is unreachable ❌`, + text: `*${name}*${region ? ` (${region})` : ""} is unreachable ❌ 🚨`, }, }, toNotify && toNotify.length > 0