improve daily updates with emojis pointing to warning location

This commit is contained in:
beckerinj
2022-08-17 10:12:28 -04:00
parent ada8169c2e
commit 97f933ee32
2 changed files with 17 additions and 14 deletions
+12 -9
View File
@@ -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* ❌ `,
},
},
{
+5 -5
View File
@@ -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