diff --git a/docs/i18n.md b/docs/i18n.md index af3fa72..73ccfbf 100644 --- a/docs/i18n.md +++ b/docs/i18n.md @@ -41,6 +41,7 @@ Copy and update the translation file in the `locales` folder. The translation fi "All Systems are Degraded": "All Systems are Degraded", "All Systems are Down": "All Systems are Down", "All Systems are Operational": "All Systems are Operational", + "All Systems are in Maintenance": "All Systems are in Maintenance", "Back": "Back", "Badge Copied": "Badge Copied", "Badge": "Badge", @@ -91,6 +92,7 @@ Copy and update the translation file in the `locales` folder. The translation fi "Some Systems are not working as expected": "Some Systems are not working as expected", "Some Systems Degraded": "Some Systems Degraded", "Some Systems Down": "Some Systems Down", + "Some Systems in Maintenance": "Some Systems in Maintenance", "Standard": "Standard", "Started %startedAt, lasted for %lastedFor": "Started %startedAt, lasted for %lastedFor", "Started %startedAt, still ongoing": "Started %startedAt, still ongoing", diff --git a/docs/incident-management.md b/docs/incident-management.md index 9bf6fbc..73e4514 100644 --- a/docs/incident-management.md +++ b/docs/incident-management.md @@ -73,7 +73,7 @@ To close an incident, you need to add a message and set the status to `RESOLVED` ## Add Monitors -To add monitors to the incident, you need to add the monitor tag to the incident. This will automatically add the monitor to the incident. You will also get the status of the monitor in the incident. This can be `DEGRADED` or `DOWN`. +To add monitors to the incident, you need to add the monitor tag to the incident. This will automatically add the monitor to the incident. You will also get the status of the monitor in the incident. For any event type, this can be `DEGRADED` or `DOWN`. For maintenance event type, this can also be `MAINTENANCE`. ## Maintenance diff --git a/docs/theme.md b/docs/theme.md index 79ab677..85e488a 100644 --- a/docs/theme.md +++ b/docs/theme.md @@ -75,7 +75,7 @@ Shows the day's impact. Example: If it was down at 10:00 AM and it is 11:00 AM, ## Colors -You can change the colors of UP/DEGRADED/DOWN states of the monitor. You show have a shade of green, yellow, and red respectively. +You can change the colors of UP/DEGRADED/DOWN/MAINTENANCE states of the monitor. By default, it shows a shade of green, yellow, red and blue respectively. --- diff --git a/migrations/20250505082941_add_maintenance_status.js b/migrations/20250505082941_add_maintenance_status.js new file mode 100644 index 0000000..0e6cd22 --- /dev/null +++ b/migrations/20250505082941_add_maintenance_status.js @@ -0,0 +1,19 @@ +/** + * @param { import("knex").Knex } knex + * @returns { Promise } + */ +export function up(knex) { + return knex("site_data") + .where("key", "colors") + .update({ value: knex.jsonInsert("value", "$.MAINTENANCE", "#6699cc") }); +} + +/** + * @param { import("knex").Knex } knex + * @returns { Promise } + */ +export function down(knex) { + return knex("site_data") + .where("key", "colors") + .update({ value: knex.jsonRemove("value", "$.MAINTENANCE") }); +} diff --git a/src/kener.css b/src/kener.css index b4460b6..9aba724 100644 --- a/src/kener.css +++ b/src/kener.css @@ -10,6 +10,7 @@ section { --up-color: #4ead94; --down-color: #ca3038; --degraded-color: #e6ca61; + --maintenance-color: #6679cc; } /*Colors for something UP*/ @@ -82,6 +83,33 @@ section { background: linear-gradient(0deg, var(--degraded-color) 90%, var(--up-color) 1%); } +/*Colors for something in maintenance*/ +.bg-api-maintenance { + background-color: var(--maintenance-color); +} +.text-api-maintenance { + color: var(--maintenance-color); +} + +.bg-api-maintenance-10 { + background: linear-gradient(0deg, var(--maintenance-color) 10%, var(--up-color) 1%); +} +.bg-api-maintenance-20 { + background: linear-gradient(0deg, var(--maintenance-color) 20%, var(--up-color) 1%); +} +.bg-api-maintenance-40 { + background: linear-gradient(0deg, var(--maintenance-color) 40%, var(--up-color) 1%); +} +.bg-api-maintenance-60 { + background: linear-gradient(0deg, var(--maintenance-color) 60%, var(--up-color) 1%); +} +.bg-api-maintenance-80 { + background: linear-gradient(0deg, var(--maintenance-color) 80%, var(--up-color) 1%); +} +.bg-api-maintenance-90 { + background: linear-gradient(0deg, var(--maintenance-color) 90%, var(--up-color) 1%); +} + /*Needed to show markdown properly*/ .prose :where(code):not(:where([class~="not-prose"], [class~="not-prose"] *))::before { content: ""; diff --git a/src/lib/color.js b/src/lib/color.js index ea8060e..19abea4 100644 --- a/src/lib/color.js +++ b/src/lib/color.js @@ -7,6 +7,7 @@ async function StatusColor(status) { UP: site.colors?.UP || "#00dfa2", DEGRADED: site.colors?.DEGRADED || "#e6ca61", DOWN: site.colors?.DOWN || "#ca3038", + MAINTENANCE: site.colors?.MAINTENANCE || "#6679cc", NO_DATA: "#f1f5f8" }; } diff --git a/src/lib/components/manage/themeInfo.svelte b/src/lib/components/manage/themeInfo.svelte index adaf5b5..779cdd0 100644 --- a/src/lib/components/manage/themeInfo.svelte +++ b/src/lib/components/manage/themeInfo.svelte @@ -35,7 +35,8 @@ colorsJ: { UP: "#4ead94", DOWN: "#ca3038", - DEGRADED: "#e6ca61" + DEGRADED: "#e6ca61", + MAINTENANCE: "#6679cc", }, fontJ: { cssSrc: @@ -296,7 +297,7 @@

Status Colors

- Choose the colors for the monitor. You can choose between UP, DEGRADED, and DOWN. + Choose the colors for the monitor. You can choose between UP, DEGRADED, DOWN and MAINTENANCE.

@@ -343,6 +344,20 @@ }} /> +
+ { + themeData.colorsJ.MAINTENANCE = event.detail.hex; + }} + /> +

diff --git a/src/lib/locales/de.json b/src/lib/locales/de.json index b18ef2f..1998c8a 100644 --- a/src/lib/locales/de.json +++ b/src/lib/locales/de.json @@ -12,6 +12,7 @@ "All Systems are Degraded": "Alle Systeme sind eingeschränkt", "All Systems are Down": "Alle Systeme sind ausgefallen", "All Systems are Operational": "Alle Systeme sind betriebsbereit", + "All Systems are in Maintenance": "Alle Systeme sind in Wartung", "Back": "Zurück", "Badge Copied": "Abzeichen kopiert", "Badge": "Abzeichen", @@ -62,6 +63,7 @@ "Some Systems are not working as expected": "Einige Systeme funktionieren nicht wie erwartet", "Some Systems Degraded": "Einige Systeme eingeschränkt", "Some Systems Down": "Einige Systeme ausgefallen", + "Some Systems in Maintenance": "Einige Systeme sind in Wartung", "Standard": "Standard", "Started %startedAt, lasted for %lastedFor": "Begann vor etwa %startedAt und dauerte etwa %lastedFor", "Started %startedAt, still ongoing": "Begann vor etwa %startedAt und dauert noch an", diff --git a/src/lib/locales/dk.json b/src/lib/locales/dk.json index 7db8cfb..40746d7 100644 --- a/src/lib/locales/dk.json +++ b/src/lib/locales/dk.json @@ -12,6 +12,7 @@ "All Systems are Degraded": "Alle Systemer er Forringet", "All Systems are Down": "Alle Systemer er Nede", "All Systems are Operational": "Alle Systemer er Operationelle", + "All Systems are in Maintenance": "Alle systemer er i vedligeholdelse", "Back": "Tilbage", "Badge Copied": "Mærke Kopieret", "Badge": "Mærke", @@ -62,6 +63,7 @@ "Some Systems are not working as expected": "Nogle Systemer fungerer ikke som forventet", "Some Systems Degraded": "Nogle Systemer er Forringet", "Some Systems Down": "Nogle Systemer er Nede", + "Some Systems in Maintenance": "Nogle Systemer er i Vedligeholdelse", "Standard": "Standard", "Started %startedAt, lasted for %lastedFor": "Startede for cirka %startedAt siden, varede i cirka %lastedFor", "Started %startedAt, still ongoing": "Startede for cirka %startedAt siden, stadig igangværende", diff --git a/src/lib/locales/en.json b/src/lib/locales/en.json index c7636e0..20a2216 100644 --- a/src/lib/locales/en.json +++ b/src/lib/locales/en.json @@ -12,6 +12,7 @@ "All Systems are Degraded": "All Systems are Degraded", "All Systems are Down": "All Systems are Down", "All Systems are Operational": "All Systems are Operational", + "All Systems are in Maintenance": "All Systems are in Maintenance", "Back": "Back", "Badge Copied": "Badge Copied", "Badge": "Badge", @@ -62,6 +63,7 @@ "Some Systems are not working as expected": "Some Systems are not working as expected", "Some Systems Degraded": "Some Systems Degraded", "Some Systems Down": "Some Systems Down", + "Some Systems in Maintenance": "Some Systems in Maintenance", "Standard": "Standard", "Started %startedAt, lasted for %lastedFor": "Started %startedAt, lasted for %lastedFor", "Started %startedAt, still ongoing": "Started %startedAt, still ongoing", diff --git a/src/lib/locales/fr.json b/src/lib/locales/fr.json index e0b62a1..c4c8f95 100644 --- a/src/lib/locales/fr.json +++ b/src/lib/locales/fr.json @@ -12,6 +12,7 @@ "All Systems are Degraded": "Tous les systèmes sont dégradés", "All Systems are Down": "Tous les systèmes sont hors ligne", "All Systems are Operational": "Tous les systèmes sont opérationnels", + "All Systems are in Maintenance": "Tous les systèmes sont en maintenance", "Back": "Retour", "Badge Copied": "Badge copié", "Badge": "Badge", @@ -62,6 +63,7 @@ "Some Systems are not working as expected": "Certains systèmes ne fonctionnent pas comme prévu", "Some Systems Degraded": "Certains systèmes sont dégradés", "Some Systems Down": "Certains systèmes sont hors ligne", + "Some Systems in Maintenance": "Certains systèmes sont en maintenance", "Standard": "Standard", "Started %startedAt, lasted for %lastedFor": "Commencé il y a environ %startedAt, a duré environ %lastedFor", "Started %startedAt, still ongoing": "Commencé il y a environ %startedAt, toujours en cours", diff --git a/src/lib/locales/hi.json b/src/lib/locales/hi.json index 7abf45e..9853728 100644 --- a/src/lib/locales/hi.json +++ b/src/lib/locales/hi.json @@ -12,6 +12,7 @@ "All Systems are Degraded": "सभी सिस्टम क्षीण हैं", "All Systems are Down": "सभी सिस्टम डाउन हैं", "All Systems are Operational": "सभी सिस्टम कार्यरत हैं", + "All Systems are in Maintenance": "सभी सिस्टम रखरखाव में हैं", "Back": "वापस", "Badge Copied": "बैज कॉपी किया गया", "Badge": "बैज", @@ -62,6 +63,7 @@ "Some Systems are not working as expected": "कुछ सिस्टम अपेक्षित रूप से काम नहीं कर रहे हैं", "Some Systems Degraded": "कुछ सिस्टम क्षीण हैं", "Some Systems Down": "कुछ सिस्टम डाउन हैं", + "Some Systems in Maintenance": "कुछ सिस्टम रखरखाव में हैं", "Standard": "मानक", "Started %startedAt, lasted for %lastedFor": "%startedAt शुरू हुआ, %lastedFor तक चला", "Started %startedAt, still ongoing": "%startedAt शुरू हुआ, अभी भी जारी है", diff --git a/src/lib/locales/ja.json b/src/lib/locales/ja.json index aa45d80..1d7ff04 100644 --- a/src/lib/locales/ja.json +++ b/src/lib/locales/ja.json @@ -12,6 +12,7 @@ "All Systems are Degraded": "すべてのシステムが劣化しています", "All Systems are Down": "すべてのシステムがダウンしています", "All Systems are Operational": "すべてのシステムが正常に稼働しています", + "All Systems are in Maintenance": "すべてのシステムがメンテナンス中です", "Back": "戻る", "Badge Copied": "バッジがコピーされました", "Badge": "バッジ", @@ -62,6 +63,7 @@ "Some Systems are not working as expected": "一部のシステムが期待通りに動作していません", "Some Systems Degraded": "一部のシステムが劣化しています", "Some Systems Down": "一部のシステムがダウンしています", + "Some Systems in Maintenance": "いくつかのシステムがメンテナンス中です", "Standard": "標準", "Started %startedAt, lasted for %lastedFor": "%startedAt 前に開始し、約 %lastedFor 続きました", "Started %startedAt, still ongoing": "%startedAt 前に開始し、まだ進行中です", diff --git a/src/lib/locales/ko.json b/src/lib/locales/ko.json index 898d1f8..5b3a6d8 100644 --- a/src/lib/locales/ko.json +++ b/src/lib/locales/ko.json @@ -12,6 +12,7 @@ "All Systems are Degraded": "모든 시스템이 성능 저하 상태입니다", "All Systems are Down": "모든 시스템이 중단되었습니다", "All Systems are Operational": "모든 시스템이 정상 작동 중입니다", + "All Systems are in Maintenance": "모든 시스템이 유지보수 중입니다", "Back": "뒤로", "Badge Copied": "배지 복사됨", "Badge": "배지", @@ -62,6 +63,7 @@ "Some Systems are not working as expected": "일부 시스템이 예상대로 작동하지 않습니다", "Some Systems Degraded": "일부 시스템이 성능 저하 상태입니다", "Some Systems Down": "일부 시스템이 중단되었습니다", + "Some Systems in Maintenance": "일부 시스템이 유지보수 중입니다", "Standard": "기본", "Started %startedAt, lasted for %lastedFor": "%startedAt 전에 시작되었으며, %lastedFor 동안 지속되었습니다", "Started %startedAt, still ongoing": "%startedAt 전에 시작되었으며, 아직 진행중입니다", diff --git a/src/lib/locales/nb-NO.json b/src/lib/locales/nb-NO.json index 41183b5..f60489d 100644 --- a/src/lib/locales/nb-NO.json +++ b/src/lib/locales/nb-NO.json @@ -12,6 +12,7 @@ "All Systems are Degraded": "Alle systemer har nedsatt ytelse", "All Systems are Down": "Alle systemer er nede", "All Systems are Operational": "Alle systemer er operative", + "All Systems are in Maintenance": "Alle systemer er til vedlikehold", "Back": "Tilbake", "Badge Copied": "Merke kopiert", "Badge": "Merke", @@ -62,6 +63,7 @@ "Some Systems are not working as expected": "Noen systemer fungerer ikke som forventet", "Some Systems Degraded": "Noen systemer har nedsatt ytelse", "Some Systems Down": "Noen systemer er nede", + "Some Systems in Maintenance": "Noen systemer er til vedlikehold", "Standard": "Standard", "Started %startedAt, lasted for %lastedFor": "Startet %startedAt, varte i %lastedFor", "Started %startedAt, still ongoing": "Startet %startedAt, fortsatt pågår", diff --git a/src/lib/locales/nl.json b/src/lib/locales/nl.json index 2024b12..3d1fae3 100644 --- a/src/lib/locales/nl.json +++ b/src/lib/locales/nl.json @@ -12,6 +12,7 @@ "All Systems are Degraded": "Alle systemen werken met beperkte functionaliteit", "All Systems are Down": "Alle systemen zijn niet bereikbaar", "All Systems are Operational": "Alle systemen zijn operationeel", + "All Systems are in Maintenance": "Alle systemen zijn in onderhoud", "Back": "Terug", "Badge Copied": "Badge gekopieerd", "Badge": "Badge", @@ -62,6 +63,7 @@ "Some Systems are not working as expected": "Sommige systemen werken niet zoals verwacht", "Some Systems Degraded": "Sommige systemen werken met beperkte functionaliteit", "Some Systems Down": "Sommige systemen zijn niet bereikbaar", + "Some Systems in Maintenance": "Sommige systemen zijn in onderhoud", "Standard": "Standaard", "Started %startedAt, lasted for %lastedFor": "Begonnen ongeveer %startedAt geleden, duurde ongeveer %lastedFor", "Started %startedAt, still ongoing": "Begonnen ongeveer %startedAt geleden, nog steeds bezig", diff --git a/src/lib/locales/pl.json b/src/lib/locales/pl.json index 9fc2971..b5283ca 100644 --- a/src/lib/locales/pl.json +++ b/src/lib/locales/pl.json @@ -12,6 +12,7 @@ "All Systems are Degraded": "Wszystkie systemy działają z ograniczeniami", "All Systems are Down": "Wszystkie systemy są niedostępne", "All Systems are Operational": "Wszystkie systemy działają poprawnie", + "All Systems are in Maintenance": "Wszystkie systemy są w konserwacji", "Back": "Wstecz", "Badge Copied": "Odznaka skopiowana", "Badge": "Odznaka", @@ -62,6 +63,7 @@ "Some Systems are not working as expected": "Niektóre systemy nie działają zgodnie z oczekiwaniami", "Some Systems Degraded": "Niektóre systemy działają z ograniczeniami", "Some Systems Down": "Niektóre systemy są niedostępne", + "Some Systems in Maintenance": "Niektóre systemy są w konserwacji", "Standard": "Standardowy", "Started %startedAt, lasted for %lastedFor": "Rozpoczęto %startedAt, trwało %lastedFor", "Started %startedAt, still ongoing": "Rozpoczęto %startedAt, nadal trwa", diff --git a/src/lib/locales/pt-BR.json b/src/lib/locales/pt-BR.json index 4ed26db..c340fd8 100644 --- a/src/lib/locales/pt-BR.json +++ b/src/lib/locales/pt-BR.json @@ -12,6 +12,7 @@ "All Systems are Degraded": "Todos os Sistemas estão com Falhas", "All Systems are Down": "Todos os Sistemas estão Indisponíveis", "All Systems are Operational": "Todos os Sistemas estão Operacionais", + "All Systems are in Maintenance": "Todos os Sistemas estão em Manutenção", "Back": "Voltar", "Badge Copied": "Emblema Copiado", "Badge": "Emblema", @@ -62,6 +63,7 @@ "Some Systems are not working as expected": "Alguns Sistemas não estão funcionando como esperado", "Some Systems Degraded": "Alguns Sistemas estão com Falhas", "Some Systems Down": "Alguns Sistemas estão Indisponíveis", + "Some Systems in Maintenance": "Alguns Sistemas estão em Manutenção", "Standard": "Padrão", "Started %startedAt, lasted for %lastedFor": "Ocorreu faz %startedAt e durou %lastedFor", "Started %startedAt, still ongoing": "Iniciou faz %startedAt, ainda em andamento", diff --git a/src/lib/locales/ru.json b/src/lib/locales/ru.json index 64cf4d6..5264dde 100644 --- a/src/lib/locales/ru.json +++ b/src/lib/locales/ru.json @@ -12,6 +12,7 @@ "All Systems are Degraded": "Все системы работают с ухудшенной производительностью", "All Systems are Down": "Все системы недоступны", "All Systems are Operational": "Все системы работают нормально", + "All Systems are in Maintenance": "Все системы на обслуживании", "Back": "Назад", "Badge Copied": "Значок скопирован", "Badge": "Значок", @@ -62,6 +63,7 @@ "Some Systems are not working as expected": "Некоторые системы работают не так, как ожидалось", "Some Systems Degraded": "Некоторые системы работают с ухудшенной производительностью", "Some Systems Down": "Некоторые системы недоступны", + "Some Systems in Maintenance": "Некоторые системы на обслуживании", "Standard": "Стандартная", "Started %startedAt, lasted for %lastedFor": "Началось около %startedAt назад, длилось около %lastedFor", "Started %startedAt, still ongoing": "Началось около %startedAt назад, все еще продолжается", diff --git a/src/lib/locales/tr.json b/src/lib/locales/tr.json index d454d74..e8b64b7 100644 --- a/src/lib/locales/tr.json +++ b/src/lib/locales/tr.json @@ -12,6 +12,7 @@ "All Systems are Degraded": "Tüm Sistemler Bozuk Durumda", "All Systems are Down": "Tüm Sistemler Çalışmıyor", "All Systems are Operational": "Tüm Sistemler Çalışıyor", + "All Systems are in Maintenance": "Tüm Sistemler Bakımda", "Back": "Geri", "Badge Copied": "Rozet Kopyalandı", "Badge": "Rozet", @@ -62,6 +63,7 @@ "Some Systems are not working as expected": "Bazı Sistemler Beklendiği Gibi Çalışmıyor", "Some Systems Degraded": "Bazı Sistemler Bozuk Durumda", "Some Systems Down": "Bazı Sistemler Çalışmıyor", + "Some Systems in Maintenance": "Bazı Sistemler Bakımda", "Standard": "Standart", "Started %startedAt, lasted for %lastedFor": "%startedAt başladı, %lastedFor sürdü", "Started %startedAt, still ongoing": "%startedAt başladı, devam ediyor", diff --git a/src/lib/locales/vi.json b/src/lib/locales/vi.json index 1e75287..ba4b8fe 100644 --- a/src/lib/locales/vi.json +++ b/src/lib/locales/vi.json @@ -12,6 +12,7 @@ "All Systems are Degraded": "Tất cả hệ thống đang suy giảm hiệu suất", "All Systems are Down": "Tất cả hệ thống đang ngừng hoạt động", "All Systems are Operational": "Tất cả hệ thống đang hoạt động bình thường", + "All Systems are in Maintenance": "Tất cả hệ thống đang bảo trì", "Back": "Quay lại", "Badge Copied": "Huy hiệu đã được sao chép", "Badge": "Huy hiệu", @@ -62,6 +63,7 @@ "Some Systems are not working as expected": "Một số hệ thống không hoạt động như mong đợi", "Some Systems Degraded": "Một số hệ thống đang suy giảm hiệu suất", "Some Systems Down": "Một số hệ thống đang ngừng hoạt động", + "Some Systems in Maintenance": "Một số hệ thống đang bảo trì", "Standard": "Tiêu chuẩn", "Started %startedAt, lasted for %lastedFor": "Bắt đầu khoảng %startedAt trước, kéo dài khoảng %lastedFor", "Started %startedAt, still ongoing": "Bắt đầu khoảng %startedAt trước, vẫn đang diễn ra", diff --git a/src/lib/locales/zh-CN.json b/src/lib/locales/zh-CN.json index 6cc7f33..be69e84 100644 --- a/src/lib/locales/zh-CN.json +++ b/src/lib/locales/zh-CN.json @@ -12,6 +12,7 @@ "All Systems are Degraded": "所有系统性能下降", "All Systems are Down": "所有系统不可用", "All Systems are Operational": "所有系统运行正常", + "All Systems are in Maintenance": "所有系统正在维护", "Back": "返回", "Badge Copied": "徽章已复制", "Badge": "徽章", @@ -62,6 +63,7 @@ "Some Systems are not working as expected": "部分系统运行异常", "Some Systems Degraded": "部分系统性能下降", "Some Systems Down": "部分系统不可用", + "Some Systems in Maintenance": "部分系统正在维护", "Standard": "标准", "Started %startedAt, lasted for %lastedFor": "大约 %startedAt 前开始,持续了约 %lastedFor", "Started %startedAt, still ongoing": "大约 %startedAt 前开始,目前仍在进行中", diff --git a/src/lib/server/constants.js b/src/lib/server/constants.js index 1fd5113..5e5a7e1 100644 --- a/src/lib/server/constants.js +++ b/src/lib/server/constants.js @@ -8,6 +8,7 @@ const SITE = "./config/site.yaml"; const UP = "UP"; const DOWN = "DOWN"; const DEGRADED = "DEGRADED"; +const MAINTENANCE = "MAINTENANCE"; const NO_DATA = "NO_DATA"; const API_TIMEOUT = 10 * 1000; // 10 seconds const AnalyticsProviders = { diff --git a/src/lib/server/controllers/controller.js b/src/lib/server/controllers/controller.js index 6e3474d..083b3f6 100644 --- a/src/lib/server/controllers/controller.js +++ b/src/lib/server/controllers/controller.js @@ -206,6 +206,7 @@ export const SystemDataMessage = async () => { let upsCount = 0; let degradedCount = 0; let downCount = 0; + let maintenanceCount = 0; for (let i = 0; i < monitors.length; i++) { let status = await db.getLatestMonitoringData(monitors[i].tag); if (status) { @@ -215,11 +216,13 @@ export const SystemDataMessage = async () => { degradedCount++; } else if (status.status === "DOWN") { downCount++; + } else if (status.status === "MAINTENANCE") { + maintenanceCount++; } } } - const total = upsCount + degradedCount + downCount; + const total = upsCount + degradedCount + downCount + maintenanceCount; if (total === 0) { return { @@ -227,48 +230,56 @@ export const SystemDataMessage = async () => { upsPercentage: 0, degradedPercentage: 0, downsPercentage: 0, + maintenancePercentage: 0, }; } let upsPercentage = Math.round((upsCount / total) * 100); let degradedPercentage = Math.round((degradedCount / total) * 100); let downsPercentage = Math.round((downCount / total) * 100); + let maintenancePercentage = Math.round((maintenanceCount / total) * 100); let message = ""; // Determine message based on the combination of system states - if (upsCount > 0 && degradedCount === 0 && downCount === 0) { - // UP=1|DOWN=0|DEGRADED=0 + if (upsCount > 0 && degradedCount === 0 && downCount === 0 && maintenanceCount == 0) { + // UP=1|DOWN=0|DEGRADED=0|MAINTENANCE=0 message = "All Systems are Operational"; - } else if (upsCount === 0 && degradedCount > 0 && downCount === 0) { - // UP=0|DOWN=0|DEGRADED=1 + } else if (upsCount === 0 && degradedCount > 0 && downCount === 0 && maintenanceCount == 0) { + // UP=0|DOWN=0|DEGRADED=1|MAINTENANCE=0 message = "All Systems are Degraded"; - } else if (upsCount === 0 && degradedCount === 0 && downCount > 0) { - // UP=0|DOWN=1|DEGRADED=0 + } else if (upsCount === 0 && degradedCount === 0 && downCount > 0 && maintenanceCount == 0) { + // UP=0|DOWN=1|DEGRADED=0|MAINTENANCE=0 message = "All Systems are Down"; + } else if (upsCount === 0 && degradedCount === 0 && downCount === 0 && maintenanceCount > 0) { + message = "All Systems are in Maintenance"; } else if ( - (upsCount > 0 && degradedCount > 0 && downCount > 0) || - (upsCount === 0 && degradedCount > 0 && downCount > 0) + (upsCount > 0 && degradedCount > 0 && downCount > 0 && maintenanceCount > 0) || + (upsCount === 0 && degradedCount > 0 && downCount > 0 && maintenanceCount > 0) ) { - // UP=1|DOWN=1|DEGRADED=1 or UP=0|DOWN=1|DEGRADED=1 + // UP=1|DOWN=1|DEGRADED=1|MAINTENANCE=1 or UP=0|DOWN=1|DEGRADED=1|MAINTENANCE=1 message = "Some Systems are not working as expected"; - } else if (upsCount > 0 && degradedCount === 0 && downCount > 0) { - // UP=1|DOWN=1|DEGRADED=0 + } else if (upsCount > 0 && degradedCount === 0 && downCount > 0 && maintenanceCount == 0) { + // UP=1|DOWN=1|DEGRADED=0|MAINTENANCE=0 message = "Some Systems Down"; - } else if (upsCount > 0 && degradedCount > 0 && downCount === 0) { - // UP=1|DOWN=0|DEGRADED=1 + } else if (upsCount > 0 && degradedCount > 0 && downCount === 0 && maintenanceCount == 0) { + // UP=1|DOWN=0|DEGRADED=1|MAINTENANCE=0 message = "Some Systems Degraded"; + } else if (upsCount > 0 && degradedCount === 0 && downCount === 0 && maintenanceCount > 0) { + // UP=1|DOWN=0|DEGRADED=0|MAINTENANCE=1 + message = "Some Systems in Maintenance"; } //if percentage is not 100 sum, then add remaining to up - if (upsPercentage + degradedPercentage + downsPercentage < 100) { - upsPercentage = 100 - (degradedPercentage + downsPercentage); + if (upsPercentage + degradedPercentage + downsPercentage + maintenancePercentage < 100) { + upsPercentage = 100 - (degradedPercentage + downsPercentage + maintenancePercentage); } return { text: message, upsPercentage, degradedPercentage, downsPercentage, + maintenancePercentage }; }; @@ -722,6 +733,7 @@ export const GetDataGroupByDayAlternative = async (monitor_tag, start, end, time UP: 0, DOWN: 0, DEGRADED: 0, + MAINTENANCE: 0, NO_DATA: 0, }; } @@ -740,6 +752,7 @@ export const GetDataGroupByDayAlternative = async (monitor_tag, start, end, time UP: group.UP, DOWN: group.DOWN, DEGRADED: group.DEGRADED, + MAINTENANCE: group.MAINTENANCE, NO_DATA: group.NO_DATA, })); }; @@ -863,9 +876,9 @@ export const RemoveIncidentMonitor = async (incident_id, monitor_tag) => { }; export const AddIncidentMonitor = async (incident_id, monitor_tag, monitor_impact) => { - //monitor_impact must be DOWN or DEGRADED or NONE - if (!["DOWN", "DEGRADED"].includes(monitor_impact)) { - throw new Error("Monitor impact must be either DOWN, DEGRADED "); + //monitor_impact must be DOWN or DEGRADED or MAINTENANCE or NONE + if (!["DOWN", "DEGRADED", "MAINTENANCE"].includes(monitor_impact)) { + throw new Error("Monitor impact must be either DOWN, DEGRADED, MAINTENANCE"); } //check if monitor exists diff --git a/src/lib/server/controllers/validators.js b/src/lib/server/controllers/validators.js index d8234c0..cd8a9e4 100644 --- a/src/lib/server/controllers/validators.js +++ b/src/lib/server/controllers/validators.js @@ -109,7 +109,7 @@ export function IsValidColors(colors) { return false; } if (typeof colors !== "object") return false; - const validColorKeys = ["UP", "DOWN", "DEGRADED"]; + const validColorKeys = ["UP", "DOWN", "DEGRADED", "MAINTENANCE"]; for (const key of validColorKeys) { if (typeof colors[key] !== "string" || !/^#[0-9A-Fa-f]{6}$/.test(colors[key])) return false; } diff --git a/src/lib/server/cron-minute.js b/src/lib/server/cron-minute.js index 59d201a..e943b7a 100644 --- a/src/lib/server/cron-minute.js +++ b/src/lib/server/cron-minute.js @@ -42,6 +42,10 @@ async function manualIncident(monitor) { for (let i = 0; i < impactArr.length; i++) { const element = impactArr[i]; + if (element.monitor_impact === "MAINTENANCE") { + impact = "MAINTENANCE"; + break; + } if (element.monitor_impact === "DOWN") { impact = "DOWN"; break; diff --git a/src/lib/server/db/seedSiteData.js b/src/lib/server/db/seedSiteData.js index 541a8c7..e342b75 100644 --- a/src/lib/server/db/seedSiteData.js +++ b/src/lib/server/db/seedSiteData.js @@ -92,6 +92,7 @@ const seedSiteData = { UP: "#67ab95", DOWN: "#ca3038", DEGRADED: "#e6ca61", + MAINTENANCE: "#6679cc", }, font: { cssSrc: "", diff --git a/src/lib/server/page.js b/src/lib/server/page.js index 4684988..bcb1e94 100644 --- a/src/lib/server/page.js +++ b/src/lib/server/page.js @@ -125,6 +125,11 @@ const FetchData = async function (site, monitor, localTz, selectedLang, lang, is summaryDuration = getSummaryDuration(dayData.DOWN, selectedLang); summaryStatus = "DOWN"; } + if (dayData.MAINTENANCE > 0) { + cssClass = returnStatusClass(dayData.MAINTENANCE, dayData.total, StatusObj.MAINTENANCE, site.barStyle); + summaryDuration = getSummaryDuration(dayData.MAINTENANCE, selectedLang); + summaryStatus = "MAINTENANCE"; + } if (dayData.NO_DATA === dayData.total) { cssClass = StatusObj.NO_DATA; summaryStatus = NO_DATA; @@ -178,6 +183,11 @@ const FetchData = async function (site, monitor, localTz, selectedLang, lang, is summaryStatus = "DOWN"; summaryColorClass = "api-down"; } + if (!!lastRow && lastRow.status == "MAINTENANCE") { + summaryDuration = getSummaryDuration(getCountOfSimilarStatuesEnd(todayDataDb, "MAINTENANCE"), selectedLang); + summaryStatus = "MAINTENANCE"; + summaryColorClass = "api-maintenance"; + } if (lastRow.status === "NO_DATA") { summaryStatus = NO_DATA; summaryColorClass = "api-nodata"; diff --git a/src/lib/server/tool.js b/src/lib/server/tool.js index e410c49..0931e24 100644 --- a/src/lib/server/tool.js +++ b/src/lib/server/tool.js @@ -149,6 +149,7 @@ const StatusObj = { UP: "api-up", DEGRADED: "api-degraded", DOWN: "api-down", + MAINTENANCE: "api-maintenance", NO_DATA: "api-nodata", }; // @ts-ignore diff --git a/src/routes/(kener)/+layout.svelte b/src/routes/(kener)/+layout.svelte index f9b5883..73e09f3 100644 --- a/src/routes/(kener)/+layout.svelte +++ b/src/routes/(kener)/+layout.svelte @@ -109,7 +109,8 @@ --bg-custom: {data.bgc}; --up-color: {data.site.colors.UP}; --down-color: {data.site.colors.DOWN}; - --degraded-color: {data.site.colors.DEGRADED} + --degraded-color: {data.site.colors.DEGRADED}; + --maintenance-color: {data.site.colors.MAINTENANCE}; " class="kener-theme-{kenerTheme}" > diff --git a/src/routes/(kener)/+page.svelte b/src/routes/(kener)/+page.svelte index 68c7d6c..ef51161 100644 --- a/src/routes/(kener)/+page.svelte +++ b/src/routes/(kener)/+page.svelte @@ -117,6 +117,7 @@

+
{/if} @@ -216,13 +217,13 @@ class="section-legend mx-auto mb-2 flex w-full flex-1 flex-col items-start justify-center bg-transparent md:w-[655px]" id="" > -
-
+
+
{l(data.lang, "Availability per Component")}
-
+
@@ -235,9 +236,14 @@ - + {l(data.lang, "DOWN")} + + + + {l(data.lang, "MAINTENANCE")} +
diff --git a/src/routes/(manage)/manage/(app)/app/events/+page.svelte b/src/routes/(manage)/manage/(app)/app/events/+page.svelte index be8ee11..e3c6cce 100644 --- a/src/routes/(manage)/manage/(app)/app/events/+page.svelte +++ b/src/routes/(manage)/manage/(app)/app/events/+page.svelte @@ -1092,6 +1092,11 @@ Impact + {#if currentIncident.incident_type == "MAINTENANCE"} + + MAINTENANCE + + {/if} DOWN