mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-22 22:09:38 -05:00
Merge pull request #1749 from daeho-ro/feature/alertnow
Feat: New Notification Type for AlertNow
This commit is contained in:
commit
d362372b05
50
server/notification-providers/alertnow.js
Normal file
50
server/notification-providers/alertnow.js
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
const NotificationProvider = require("./notification-provider");
|
||||||
|
const axios = require("axios");
|
||||||
|
const { setting } = require("../util-server");
|
||||||
|
const { getMonitorRelativeURL, UP, DOWN } = require("../../src/util");
|
||||||
|
|
||||||
|
class AlertNow extends NotificationProvider {
|
||||||
|
|
||||||
|
name = "AlertNow";
|
||||||
|
|
||||||
|
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||||
|
let okMsg = "Sent Successfully.";
|
||||||
|
try {
|
||||||
|
let textMsg = "";
|
||||||
|
let status = "open";
|
||||||
|
let eventType = "ERROR";
|
||||||
|
let eventId = new Date().toISOString().slice(0, 10).replace(/-/g, "");
|
||||||
|
|
||||||
|
if (heartbeatJSON && heartbeatJSON.status === UP) {
|
||||||
|
textMsg = `[${heartbeatJSON.name}] ✅ Application is back online`;
|
||||||
|
status = "close";
|
||||||
|
eventType = "INFO";
|
||||||
|
eventId += `_${heartbeatJSON.name.replace(/\s/g, "")}`;
|
||||||
|
} else if (heartbeatJSON && heartbeatJSON.status === DOWN) {
|
||||||
|
textMsg = `[${heartbeatJSON.name}] 🔴 Application went down`;
|
||||||
|
}
|
||||||
|
|
||||||
|
textMsg += ` - ${msg}`;
|
||||||
|
|
||||||
|
const baseURL = await setting("primaryBaseURL");
|
||||||
|
if (baseURL && monitorJSON) {
|
||||||
|
textMsg += ` >> ${baseURL + getMonitorRelativeURL(monitorJSON.id)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
"summary": textMsg,
|
||||||
|
"status": status,
|
||||||
|
"event_type": eventType,
|
||||||
|
"event_id": eventId,
|
||||||
|
};
|
||||||
|
|
||||||
|
await axios.post(notification.alertNowWebhookURL, data);
|
||||||
|
return okMsg;
|
||||||
|
} catch (error) {
|
||||||
|
this.throwGeneralAxiosError(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = AlertNow;
|
@ -1,40 +1,41 @@
|
|||||||
const { R } = require("redbean-node");
|
const { R } = require("redbean-node");
|
||||||
|
const { log } = require("../src/util");
|
||||||
|
const Alerta = require("./notification-providers/alerta");
|
||||||
|
const AlertNow = require("./notification-providers/alertnow");
|
||||||
|
const AliyunSms = require("./notification-providers/aliyun-sms");
|
||||||
const Apprise = require("./notification-providers/apprise");
|
const Apprise = require("./notification-providers/apprise");
|
||||||
|
const Bark = require("./notification-providers/bark");
|
||||||
|
const ClickSendSMS = require("./notification-providers/clicksendsms");
|
||||||
|
const DingDing = require("./notification-providers/dingding");
|
||||||
const Discord = require("./notification-providers/discord");
|
const Discord = require("./notification-providers/discord");
|
||||||
|
const Feishu = require("./notification-providers/feishu");
|
||||||
|
const GoogleChat = require("./notification-providers/google-chat");
|
||||||
|
const Gorush = require("./notification-providers/gorush");
|
||||||
const Gotify = require("./notification-providers/gotify");
|
const Gotify = require("./notification-providers/gotify");
|
||||||
const Ntfy = require("./notification-providers/ntfy");
|
|
||||||
const Line = require("./notification-providers/line");
|
const Line = require("./notification-providers/line");
|
||||||
const LunaSea = require("./notification-providers/lunasea");
|
const LunaSea = require("./notification-providers/lunasea");
|
||||||
const Mattermost = require("./notification-providers/mattermost");
|
|
||||||
const Matrix = require("./notification-providers/matrix");
|
const Matrix = require("./notification-providers/matrix");
|
||||||
|
const Mattermost = require("./notification-providers/mattermost");
|
||||||
|
const Ntfy = require("./notification-providers/ntfy");
|
||||||
const Octopush = require("./notification-providers/octopush");
|
const Octopush = require("./notification-providers/octopush");
|
||||||
|
const OneBot = require("./notification-providers/onebot");
|
||||||
|
const PagerDuty = require("./notification-providers/pagerduty");
|
||||||
const PromoSMS = require("./notification-providers/promosms");
|
const PromoSMS = require("./notification-providers/promosms");
|
||||||
const ClickSendSMS = require("./notification-providers/clicksendsms");
|
|
||||||
const Pushbullet = require("./notification-providers/pushbullet");
|
const Pushbullet = require("./notification-providers/pushbullet");
|
||||||
|
const PushDeer = require("./notification-providers/pushdeer");
|
||||||
const Pushover = require("./notification-providers/pushover");
|
const Pushover = require("./notification-providers/pushover");
|
||||||
const Pushy = require("./notification-providers/pushy");
|
const Pushy = require("./notification-providers/pushy");
|
||||||
const TechulusPush = require("./notification-providers/techulus-push");
|
|
||||||
const RocketChat = require("./notification-providers/rocket-chat");
|
const RocketChat = require("./notification-providers/rocket-chat");
|
||||||
|
const SerwerSMS = require("./notification-providers/serwersms");
|
||||||
const Signal = require("./notification-providers/signal");
|
const Signal = require("./notification-providers/signal");
|
||||||
const Slack = require("./notification-providers/slack");
|
const Slack = require("./notification-providers/slack");
|
||||||
const SMTP = require("./notification-providers/smtp");
|
const SMTP = require("./notification-providers/smtp");
|
||||||
|
const Stackfield = require("./notification-providers/stackfield");
|
||||||
const Teams = require("./notification-providers/teams");
|
const Teams = require("./notification-providers/teams");
|
||||||
|
const TechulusPush = require("./notification-providers/techulus-push");
|
||||||
const Telegram = require("./notification-providers/telegram");
|
const Telegram = require("./notification-providers/telegram");
|
||||||
const Webhook = require("./notification-providers/webhook");
|
const Webhook = require("./notification-providers/webhook");
|
||||||
const Feishu = require("./notification-providers/feishu");
|
|
||||||
const AliyunSms = require("./notification-providers/aliyun-sms");
|
|
||||||
const DingDing = require("./notification-providers/dingding");
|
|
||||||
const Bark = require("./notification-providers/bark");
|
|
||||||
const { log } = require("../src/util");
|
|
||||||
const SerwerSMS = require("./notification-providers/serwersms");
|
|
||||||
const Stackfield = require("./notification-providers/stackfield");
|
|
||||||
const WeCom = require("./notification-providers/wecom");
|
const WeCom = require("./notification-providers/wecom");
|
||||||
const GoogleChat = require("./notification-providers/google-chat");
|
|
||||||
const PagerDuty = require("./notification-providers/pagerduty");
|
|
||||||
const Gorush = require("./notification-providers/gorush");
|
|
||||||
const Alerta = require("./notification-providers/alerta");
|
|
||||||
const OneBot = require("./notification-providers/onebot");
|
|
||||||
const PushDeer = require("./notification-providers/pushdeer");
|
|
||||||
|
|
||||||
class Notification {
|
class Notification {
|
||||||
|
|
||||||
@ -47,41 +48,42 @@ class Notification {
|
|||||||
this.providerList = {};
|
this.providerList = {};
|
||||||
|
|
||||||
const list = [
|
const list = [
|
||||||
new Apprise(),
|
new Alerta(),
|
||||||
|
new AlertNow(),
|
||||||
new AliyunSms(),
|
new AliyunSms(),
|
||||||
|
new Apprise(),
|
||||||
|
new Bark(),
|
||||||
|
new ClickSendSMS(),
|
||||||
new DingDing(),
|
new DingDing(),
|
||||||
new Discord(),
|
new Discord(),
|
||||||
new Teams(),
|
new Feishu(),
|
||||||
|
new GoogleChat(),
|
||||||
|
new Gorush(),
|
||||||
new Gotify(),
|
new Gotify(),
|
||||||
new Ntfy(),
|
|
||||||
new Line(),
|
new Line(),
|
||||||
new LunaSea(),
|
new LunaSea(),
|
||||||
new Feishu(),
|
|
||||||
new Mattermost(),
|
|
||||||
new Matrix(),
|
new Matrix(),
|
||||||
|
new Mattermost(),
|
||||||
|
new Ntfy(),
|
||||||
new Octopush(),
|
new Octopush(),
|
||||||
|
new OneBot(),
|
||||||
|
new PagerDuty(),
|
||||||
new PromoSMS(),
|
new PromoSMS(),
|
||||||
new ClickSendSMS(),
|
|
||||||
new Pushbullet(),
|
new Pushbullet(),
|
||||||
|
new PushDeer(),
|
||||||
new Pushover(),
|
new Pushover(),
|
||||||
new Pushy(),
|
new Pushy(),
|
||||||
new TechulusPush(),
|
|
||||||
new RocketChat(),
|
new RocketChat(),
|
||||||
|
new SerwerSMS(),
|
||||||
new Signal(),
|
new Signal(),
|
||||||
new Slack(),
|
new Slack(),
|
||||||
new SMTP(),
|
new SMTP(),
|
||||||
|
new Stackfield(),
|
||||||
|
new Teams(),
|
||||||
|
new TechulusPush(),
|
||||||
new Telegram(),
|
new Telegram(),
|
||||||
new Webhook(),
|
new Webhook(),
|
||||||
new Bark(),
|
|
||||||
new SerwerSMS(),
|
|
||||||
new Stackfield(),
|
|
||||||
new WeCom(),
|
new WeCom(),
|
||||||
new GoogleChat(),
|
|
||||||
new PagerDuty(),
|
|
||||||
new Gorush(),
|
|
||||||
new Alerta(),
|
|
||||||
new OneBot(),
|
|
||||||
new PushDeer(),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
for (let item of list) {
|
for (let item of list) {
|
||||||
|
13
src/components/notifications/AlertNow.vue
Normal file
13
src/components/notifications/AlertNow.vue
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<template>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="alertnow-webhook-url" class="form-label">{{ $t("Webhook URL") }}<span style="color: red;"><sup>*</sup></span></label>
|
||||||
|
<input id="alertnow-webhook-url" v-model="$parent.notification.alertNowWebhookURL" type="text" class="form-control" required>
|
||||||
|
|
||||||
|
<div class="form-text">
|
||||||
|
<span style="color: red;"><sup>*</sup></span>{{ $t("Required") }}
|
||||||
|
<i18n-t tag="p" keypath="aboutWebhooks" style="margin-top: 8px;">
|
||||||
|
<a href="https://service.opsnow.com/docs/alertnow/en/user-guide-alertnow-en.html#standard" target="_blank">{{ $t("here") }}</a>
|
||||||
|
</i18n-t>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
@ -1,38 +1,39 @@
|
|||||||
import STMP from "./SMTP.vue";
|
import Alerta from "./Alerta.vue";
|
||||||
import Telegram from "./Telegram.vue";
|
import AlertNow from "./AlertNow.vue";
|
||||||
|
import AliyunSMS from "./AliyunSms.vue";
|
||||||
|
import Apprise from "./Apprise.vue";
|
||||||
|
import Bark from "./Bark.vue";
|
||||||
|
import ClickSendSMS from "./ClickSendSMS.vue";
|
||||||
|
import DingDing from "./DingDing.vue";
|
||||||
import Discord from "./Discord.vue";
|
import Discord from "./Discord.vue";
|
||||||
import Webhook from "./Webhook.vue";
|
import Feishu from "./Feishu.vue";
|
||||||
import Signal from "./Signal.vue";
|
import GoogleChat from "./GoogleChat.vue";
|
||||||
|
import Gorush from "./Gorush.vue";
|
||||||
import Gotify from "./Gotify.vue";
|
import Gotify from "./Gotify.vue";
|
||||||
|
import Line from "./Line.vue";
|
||||||
|
import LunaSea from "./LunaSea.vue";
|
||||||
|
import Matrix from "./Matrix.vue";
|
||||||
|
import Mattermost from "./Mattermost.vue";
|
||||||
import Ntfy from "./Ntfy.vue";
|
import Ntfy from "./Ntfy.vue";
|
||||||
import Slack from "./Slack.vue";
|
import Octopush from "./Octopush.vue";
|
||||||
import RocketChat from "./RocketChat.vue";
|
import OneBot from "./OneBot.vue";
|
||||||
import Teams from "./Teams.vue";
|
import PagerDuty from "./PagerDuty.vue";
|
||||||
|
import PromoSMS from "./PromoSMS.vue";
|
||||||
|
import Pushbullet from "./Pushbullet.vue";
|
||||||
|
import PushDeer from "./PushDeer.vue";
|
||||||
import Pushover from "./Pushover.vue";
|
import Pushover from "./Pushover.vue";
|
||||||
import Pushy from "./Pushy.vue";
|
import Pushy from "./Pushy.vue";
|
||||||
import TechulusPush from "./TechulusPush.vue";
|
import RocketChat from "./RocketChat.vue";
|
||||||
import Octopush from "./Octopush.vue";
|
|
||||||
import PromoSMS from "./PromoSMS.vue";
|
|
||||||
import ClickSendSMS from "./ClickSendSMS.vue";
|
|
||||||
import LunaSea from "./LunaSea.vue";
|
|
||||||
import Feishu from "./Feishu.vue";
|
|
||||||
import Apprise from "./Apprise.vue";
|
|
||||||
import Pushbullet from "./Pushbullet.vue";
|
|
||||||
import Line from "./Line.vue";
|
|
||||||
import Mattermost from "./Mattermost.vue";
|
|
||||||
import Matrix from "./Matrix.vue";
|
|
||||||
import AliyunSMS from "./AliyunSms.vue";
|
|
||||||
import DingDing from "./DingDing.vue";
|
|
||||||
import Bark from "./Bark.vue";
|
|
||||||
import SerwerSMS from "./SerwerSMS.vue";
|
import SerwerSMS from "./SerwerSMS.vue";
|
||||||
|
import Signal from "./Signal.vue";
|
||||||
|
import Slack from "./Slack.vue";
|
||||||
import Stackfield from "./Stackfield.vue";
|
import Stackfield from "./Stackfield.vue";
|
||||||
|
import STMP from "./SMTP.vue";
|
||||||
|
import Teams from "./Teams.vue";
|
||||||
|
import TechulusPush from "./TechulusPush.vue";
|
||||||
|
import Telegram from "./Telegram.vue";
|
||||||
|
import Webhook from "./Webhook.vue";
|
||||||
import WeCom from "./WeCom.vue";
|
import WeCom from "./WeCom.vue";
|
||||||
import GoogleChat from "./GoogleChat.vue";
|
|
||||||
import PagerDuty from "./PagerDuty.vue";
|
|
||||||
import Gorush from "./Gorush.vue";
|
|
||||||
import Alerta from "./Alerta.vue";
|
|
||||||
import OneBot from "./OneBot.vue";
|
|
||||||
import PushDeer from "./PushDeer.vue";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage all notification form.
|
* Manage all notification form.
|
||||||
@ -40,41 +41,42 @@ import PushDeer from "./PushDeer.vue";
|
|||||||
* @type { Record<string, any> }
|
* @type { Record<string, any> }
|
||||||
*/
|
*/
|
||||||
const NotificationFormList = {
|
const NotificationFormList = {
|
||||||
"telegram": Telegram,
|
"alerta": Alerta,
|
||||||
"webhook": Webhook,
|
"AlertNow": AlertNow,
|
||||||
"smtp": STMP,
|
|
||||||
"discord": Discord,
|
|
||||||
"teams": Teams,
|
|
||||||
"signal": Signal,
|
|
||||||
"gotify": Gotify,
|
|
||||||
"ntfy": Ntfy,
|
|
||||||
"slack": Slack,
|
|
||||||
"rocket.chat": RocketChat,
|
|
||||||
"pushover": Pushover,
|
|
||||||
"pushy": Pushy,
|
|
||||||
"PushByTechulus": TechulusPush,
|
|
||||||
"octopush": Octopush,
|
|
||||||
"promosms": PromoSMS,
|
|
||||||
"clicksendsms": ClickSendSMS,
|
|
||||||
"lunasea": LunaSea,
|
|
||||||
"Feishu": Feishu,
|
|
||||||
"AliyunSMS": AliyunSMS,
|
"AliyunSMS": AliyunSMS,
|
||||||
"apprise": Apprise,
|
"apprise": Apprise,
|
||||||
"pushbullet": Pushbullet,
|
|
||||||
"line": Line,
|
|
||||||
"mattermost": Mattermost,
|
|
||||||
"matrix": Matrix,
|
|
||||||
"DingDing": DingDing,
|
|
||||||
"Bark": Bark,
|
"Bark": Bark,
|
||||||
"serwersms": SerwerSMS,
|
"clicksendsms": ClickSendSMS,
|
||||||
"stackfield": Stackfield,
|
"DingDing": DingDing,
|
||||||
"WeCom": WeCom,
|
"discord": Discord,
|
||||||
|
"Feishu": Feishu,
|
||||||
"GoogleChat": GoogleChat,
|
"GoogleChat": GoogleChat,
|
||||||
"PagerDuty": PagerDuty,
|
|
||||||
"gorush": Gorush,
|
"gorush": Gorush,
|
||||||
"alerta": Alerta,
|
"gotify": Gotify,
|
||||||
|
"line": Line,
|
||||||
|
"lunasea": LunaSea,
|
||||||
|
"matrix": Matrix,
|
||||||
|
"mattermost": Mattermost,
|
||||||
|
"ntfy": Ntfy,
|
||||||
|
"octopush": Octopush,
|
||||||
"OneBot": OneBot,
|
"OneBot": OneBot,
|
||||||
|
"PagerDuty": PagerDuty,
|
||||||
|
"promosms": PromoSMS,
|
||||||
|
"pushbullet": Pushbullet,
|
||||||
|
"PushByTechulus": TechulusPush,
|
||||||
"PushDeer": PushDeer,
|
"PushDeer": PushDeer,
|
||||||
|
"pushover": Pushover,
|
||||||
|
"pushy": Pushy,
|
||||||
|
"rocket.chat": RocketChat,
|
||||||
|
"serwersms": SerwerSMS,
|
||||||
|
"signal": Signal,
|
||||||
|
"slack": Slack,
|
||||||
|
"smtp": STMP,
|
||||||
|
"stackfield": Stackfield,
|
||||||
|
"teams": Teams,
|
||||||
|
"telegram": Telegram,
|
||||||
|
"webhook": Webhook,
|
||||||
|
"WeCom": WeCom,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default NotificationFormList;
|
export default NotificationFormList;
|
||||||
|
Loading…
Reference in New Issue
Block a user