remove alertThreshold
This commit is contained in:
1 parent
a7b0ce4d8f
commit
2fb6cb0b6f
7 files changed
+17
-60
No files matched your search
@@ -269,10 +269,10 @@ class SuperSimpleQueueHelper {
|
||||
|
||||
// Check if countdown has reached zero for any threshold
|
||||
const shouldNotifyThreshold =
|
||||
(breaches.cpu && (monitor.cpuAlertThreshold ?? monitor.alertThreshold) <= 0) ||
|
||||
(breaches.memory && (monitor.memoryAlertThreshold ?? monitor.alertThreshold) <= 0) ||
|
||||
(breaches.disk && (monitor.diskAlertThreshold ?? monitor.alertThreshold) <= 0) ||
|
||||
(breaches.temp && (monitor.tempAlertThreshold ?? monitor.alertThreshold) <= 0);
|
||||
(breaches.cpu && (monitor.cpuAlertThreshold ?? 100) <= 0) ||
|
||||
(breaches.memory && (monitor.memoryAlertThreshold ?? 100) <= 0) ||
|
||||
(breaches.disk && (monitor.diskAlertThreshold ?? 100) <= 0) ||
|
||||
(breaches.temp && (monitor.tempAlertThreshold ?? 100) <= 0);
|
||||
|
||||
// Decision logic for hardware
|
||||
if (statusChanged && monitor.status === "down") {
|
||||
|
||||
@@ -88,12 +88,12 @@ export const buildHardwareAlerts = (
|
||||
const thresholdKey = alertThresholdKeyMap[type];
|
||||
// Iterate over each alert type to see if any need to be decremented
|
||||
if (alerts[type] === true) {
|
||||
const nextValue = ((monitor[thresholdKey] ?? monitor.alertThreshold) as number) - 1;
|
||||
const nextValue = ((monitor[thresholdKey] ?? 100) as number) - 1;
|
||||
monitor[thresholdKey] = nextValue; // Decrement threshold if an alert is triggered
|
||||
|
||||
if (monitor[thresholdKey] <= 0) {
|
||||
// If threshold drops below 0, reset and send notification
|
||||
monitor[thresholdKey] = monitor.alertThreshold;
|
||||
monitor[thresholdKey] = 100;
|
||||
|
||||
const formatAlert = {
|
||||
cpu: () => `Your current CPU usage (${(cpuUsage * 100).toFixed(0)}%) is above your threshold (${(cpuThreshold * 100).toFixed(0)}%)`,
|
||||
@@ -136,17 +136,17 @@ export const shouldSendHardwareAlert = (monitor: Monitor, networkResponse: Monit
|
||||
const { cpu: { usage_percent: cpuUsage = -1 } = {}, memory: { usage_percent: memoryUsage = -1 } = {}, disk = [] } = metrics;
|
||||
|
||||
const cpuBreach = cpuThreshold !== -1 && cpuUsage > cpuThreshold;
|
||||
if (cpuBreach && ((monitor.cpuAlertThreshold ?? monitor.alertThreshold) as number) - 1 <= 0) {
|
||||
if (cpuBreach && ((monitor.cpuAlertThreshold ?? 100) as number) - 1 <= 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const memoryBreach = memoryThreshold !== -1 && memoryUsage > memoryThreshold;
|
||||
if (memoryBreach && ((monitor.memoryAlertThreshold ?? monitor.alertThreshold) as number) - 1 <= 0) {
|
||||
if (memoryBreach && ((monitor.memoryAlertThreshold ?? 100) as number) - 1 <= 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const diskBreach = disk?.some((d) => diskThreshold !== -1 && typeof d?.usage_percent === "number" && d?.usage_percent > diskThreshold);
|
||||
if (diskBreach && ((monitor.diskAlertThreshold ?? monitor.alertThreshold) as number) - 1 <= 0) {
|
||||
if (diskBreach && ((monitor.diskAlertThreshold ?? 100) as number) - 1 <= 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user