mirror of https://github.com/statping/statping
vue
parent
6958f41997
commit
2654822915
|
@ -13,11 +13,10 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
package senders
|
package notifiers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/statping/statping/notifiers"
|
|
||||||
"github.com/statping/statping/types/failures"
|
"github.com/statping/statping/types/failures"
|
||||||
"github.com/statping/statping/types/services"
|
"github.com/statping/statping/types/services"
|
||||||
"github.com/statping/statping/utils"
|
"github.com/statping/statping/utils"
|
||||||
|
@ -25,13 +24,13 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ notifiers.Notifier = (*commandLine)(nil)
|
var _ Notifier = (*commandLine)(nil)
|
||||||
|
|
||||||
type commandLine struct {
|
type commandLine struct {
|
||||||
*notifiers.Notification
|
*Notification
|
||||||
}
|
}
|
||||||
|
|
||||||
var Command = &commandLine{¬ifiers.Notification{
|
var Command = &commandLine{&Notification{
|
||||||
Method: "command",
|
Method: "command",
|
||||||
Title: "Shell Command",
|
Title: "Shell Command",
|
||||||
Description: "Shell Command allows you to run a customized shell/bash Command on the local machine it's running on.",
|
Description: "Shell Command allows you to run a customized shell/bash Command on the local machine it's running on.",
|
||||||
|
@ -40,7 +39,7 @@ var Command = &commandLine{¬ifiers.Notification{
|
||||||
Delay: time.Duration(1 * time.Second),
|
Delay: time.Duration(1 * time.Second),
|
||||||
Icon: "fas fa-terminal",
|
Icon: "fas fa-terminal",
|
||||||
Host: "/bin/bash",
|
Host: "/bin/bash",
|
||||||
Form: []notifiers.NotificationForm{{
|
Form: []NotificationForm{{
|
||||||
Type: "text",
|
Type: "text",
|
||||||
Title: "Shell or Bash",
|
Title: "Shell or Bash",
|
||||||
Placeholder: "/bin/bash",
|
Placeholder: "/bin/bash",
|
||||||
|
@ -66,7 +65,7 @@ func runCommand(app string, cmd ...string) (string, string, error) {
|
||||||
return outStr, errStr, err
|
return outStr, errStr, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *commandLine) Select() *notifiers.Notification {
|
func (u *commandLine) Select() *Notification {
|
||||||
return u.Notification
|
return u.Notification
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,14 +13,13 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
package senders
|
package notifiers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/statping/statping/notifiers"
|
|
||||||
"github.com/statping/statping/types/failures"
|
"github.com/statping/statping/types/failures"
|
||||||
"github.com/statping/statping/types/services"
|
"github.com/statping/statping/types/services"
|
||||||
"github.com/statping/statping/utils"
|
"github.com/statping/statping/utils"
|
||||||
|
@ -28,13 +27,13 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ notifiers.Notifier = (*discord)(nil)
|
var _ Notifier = (*discord)(nil)
|
||||||
|
|
||||||
type discord struct {
|
type discord struct {
|
||||||
*notifiers.Notification
|
*Notification
|
||||||
}
|
}
|
||||||
|
|
||||||
var Discorder = &discord{¬ifiers.Notification{
|
var Discorder = &discord{&Notification{
|
||||||
Method: "discord",
|
Method: "discord",
|
||||||
Title: "discord",
|
Title: "discord",
|
||||||
Description: "Send notifications to your discord channel using discord webhooks. Insert your discord channel Webhook URL to receive notifications. Based on the <a href=\"https://discordapp.com/developers/docs/resources/Webhook\">discord webhooker API</a>.",
|
Description: "Send notifications to your discord channel using discord webhooks. Insert your discord channel Webhook URL to receive notifications. Based on the <a href=\"https://discordapp.com/developers/docs/resources/Webhook\">discord webhooker API</a>.",
|
||||||
|
@ -43,7 +42,7 @@ var Discorder = &discord{¬ifiers.Notification{
|
||||||
Delay: time.Duration(5 * time.Second),
|
Delay: time.Duration(5 * time.Second),
|
||||||
Host: "https://discordapp.com/api/webhooks/****/*****",
|
Host: "https://discordapp.com/api/webhooks/****/*****",
|
||||||
Icon: "fab fa-discord",
|
Icon: "fab fa-discord",
|
||||||
Form: []notifiers.NotificationForm{{
|
Form: []NotificationForm{{
|
||||||
Type: "text",
|
Type: "text",
|
||||||
Title: "discord webhooker URL",
|
Title: "discord webhooker URL",
|
||||||
Placeholder: "Insert your Webhook URL here",
|
Placeholder: "Insert your Webhook URL here",
|
||||||
|
@ -58,7 +57,7 @@ func (u *discord) Send(msg interface{}) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *discord) Select() *notifiers.Notification {
|
func (u *discord) Select() *Notification {
|
||||||
return u.Notification
|
return u.Notification
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,14 +13,13 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
package senders
|
package notifiers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/go-mail/mail"
|
"github.com/go-mail/mail"
|
||||||
"github.com/statping/statping/notifiers"
|
|
||||||
"github.com/statping/statping/types/failures"
|
"github.com/statping/statping/types/failures"
|
||||||
"github.com/statping/statping/types/null"
|
"github.com/statping/statping/types/null"
|
||||||
"github.com/statping/statping/types/services"
|
"github.com/statping/statping/types/services"
|
||||||
|
@ -29,7 +28,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ notifiers.Notifier = (*email)(nil)
|
var _ Notifier = (*email)(nil)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
mainEmailTemplate = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
mainEmailTemplate = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
@ -112,17 +111,17 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
type email struct {
|
type email struct {
|
||||||
*notifiers.Notification
|
*Notification
|
||||||
}
|
}
|
||||||
|
|
||||||
var Emailer = &email{¬ifiers.Notification{
|
var Emailer = &email{&Notification{
|
||||||
Method: "email",
|
Method: "email",
|
||||||
Title: "email",
|
Title: "email",
|
||||||
Description: "Send emails via SMTP when services are online or offline.",
|
Description: "Send emails via SMTP when services are online or offline.",
|
||||||
Author: "Hunter Long",
|
Author: "Hunter Long",
|
||||||
AuthorUrl: "https://github.com/hunterlong",
|
AuthorUrl: "https://github.com/hunterlong",
|
||||||
Icon: "far fa-envelope",
|
Icon: "far fa-envelope",
|
||||||
Form: []notifiers.NotificationForm{{
|
Form: []NotificationForm{{
|
||||||
Type: "text",
|
Type: "text",
|
||||||
Title: "SMTP Host",
|
Title: "SMTP Host",
|
||||||
Placeholder: "Insert your SMTP Host here.",
|
Placeholder: "Insert your SMTP Host here.",
|
||||||
|
@ -211,7 +210,7 @@ func (u *email) OnSuccess(s *services.Service) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *email) Select() *notifiers.Notification {
|
func (u *email) Select() *Notification {
|
||||||
return u.Notification
|
return u.Notification
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,11 +13,10 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
package senders
|
package notifiers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/statping/statping/notifiers"
|
|
||||||
"github.com/statping/statping/types/failures"
|
"github.com/statping/statping/types/failures"
|
||||||
"github.com/statping/statping/types/services"
|
"github.com/statping/statping/types/services"
|
||||||
"github.com/statping/statping/utils"
|
"github.com/statping/statping/utils"
|
||||||
|
@ -26,24 +25,24 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ notifiers.Notifier = (*lineNotifier)(nil)
|
var _ Notifier = (*lineNotifier)(nil)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
lineNotifyMethod = "line_notify"
|
lineNotifyMethod = "line_notify"
|
||||||
)
|
)
|
||||||
|
|
||||||
type lineNotifier struct {
|
type lineNotifier struct {
|
||||||
*notifiers.Notification
|
*Notification
|
||||||
}
|
}
|
||||||
|
|
||||||
var LineNotify = &lineNotifier{¬ifiers.Notification{
|
var LineNotify = &lineNotifier{&Notification{
|
||||||
Method: lineNotifyMethod,
|
Method: lineNotifyMethod,
|
||||||
Title: "LINE Notify",
|
Title: "LINE Notify",
|
||||||
Description: "LINE Notify will send notifications to your LINE Notify account when services are offline or online. Based on the <a href=\"https://notify-bot.line.me/doc/en/\">LINE Notify API</a>.",
|
Description: "LINE Notify will send notifications to your LINE Notify account when services are offline or online. Based on the <a href=\"https://notify-bot.line.me/doc/en/\">LINE Notify API</a>.",
|
||||||
Author: "Kanin Peanviriyakulkit",
|
Author: "Kanin Peanviriyakulkit",
|
||||||
AuthorUrl: "https://github.com/dogrocker",
|
AuthorUrl: "https://github.com/dogrocker",
|
||||||
Icon: "far fa-bell",
|
Icon: "far fa-bell",
|
||||||
Form: []notifiers.NotificationForm{{
|
Form: []NotificationForm{{
|
||||||
Type: "text",
|
Type: "text",
|
||||||
Title: "Access Token",
|
Title: "Access Token",
|
||||||
Placeholder: "Insert your Line Notify Access Token here.",
|
Placeholder: "Insert your Line Notify Access Token here.",
|
||||||
|
@ -61,7 +60,7 @@ func (u *lineNotifier) Send(msg interface{}) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *lineNotifier) Select() *notifiers.Notification {
|
func (u *lineNotifier) Select() *Notification {
|
||||||
return u.Notification
|
return u.Notification
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,28 +13,27 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
package senders
|
package notifiers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/statping/statping/notifiers"
|
|
||||||
"github.com/statping/statping/types/failures"
|
"github.com/statping/statping/types/failures"
|
||||||
"github.com/statping/statping/types/services"
|
"github.com/statping/statping/types/services"
|
||||||
"github.com/statping/statping/utils"
|
"github.com/statping/statping/utils"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ notifiers.Notifier = (*mobilePush)(nil)
|
var _ Notifier = (*mobilePush)(nil)
|
||||||
|
|
||||||
const mobileIdentifier = "com.statping"
|
const mobileIdentifier = "com.statping"
|
||||||
|
|
||||||
type mobilePush struct {
|
type mobilePush struct {
|
||||||
*notifiers.Notification
|
*Notification
|
||||||
}
|
}
|
||||||
|
|
||||||
var Mobile = &mobilePush{¬ifiers.Notification{
|
var Mobile = &mobilePush{&Notification{
|
||||||
Method: "mobile",
|
Method: "mobile",
|
||||||
Title: "Mobile Notifications",
|
Title: "Mobile Notifications",
|
||||||
Description: `Receive push notifications on your Mobile device using the Statping App. You can scan the Authentication QR Code found in Settings to get the Mobile app setup in seconds.
|
Description: `Receive push notifications on your Mobile device using the Statping App. You can scan the Authentication QR Code found in Settings to get the Mobile app setup in seconds.
|
||||||
|
@ -43,7 +42,7 @@ var Mobile = &mobilePush{¬ifiers.Notification{
|
||||||
AuthorUrl: "https://github.com/hunterlong",
|
AuthorUrl: "https://github.com/hunterlong",
|
||||||
Delay: time.Duration(5 * time.Second),
|
Delay: time.Duration(5 * time.Second),
|
||||||
Icon: "fas fa-mobile-alt",
|
Icon: "fas fa-mobile-alt",
|
||||||
Form: []notifiers.NotificationForm{{
|
Form: []NotificationForm{{
|
||||||
Type: "text",
|
Type: "text",
|
||||||
Title: "Device Identifiers",
|
Title: "Device Identifiers",
|
||||||
Placeholder: "A list of your Mobile device push notification ID's.",
|
Placeholder: "A list of your Mobile device push notification ID's.",
|
||||||
|
@ -58,7 +57,7 @@ var Mobile = &mobilePush{¬ifiers.Notification{
|
||||||
}}},
|
}}},
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *mobilePush) Select() *notifiers.Notification {
|
func (u *mobilePush) Select() *Notification {
|
||||||
return u.Notification
|
return u.Notification
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,6 @@ package notifiers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/google/martian/log"
|
|
||||||
"github.com/statping/statping/notifiers/senders"
|
|
||||||
"github.com/statping/statping/types/failures"
|
"github.com/statping/statping/types/failures"
|
||||||
"github.com/statping/statping/types/services"
|
"github.com/statping/statping/types/services"
|
||||||
"github.com/statping/statping/utils"
|
"github.com/statping/statping/utils"
|
||||||
|
@ -95,14 +93,14 @@ func startAllNotifiers() {
|
||||||
|
|
||||||
func Migrate() error {
|
func Migrate() error {
|
||||||
return AddNotifiers(
|
return AddNotifiers(
|
||||||
senders.Command,
|
Command,
|
||||||
senders.Discorder,
|
Discorder,
|
||||||
senders.Emailer,
|
Emailer,
|
||||||
senders.LineNotify,
|
LineNotify,
|
||||||
senders.Mobile,
|
Mobile,
|
||||||
senders.Slacker,
|
Slacker,
|
||||||
senders.Telegram,
|
Telegram,
|
||||||
senders.Twilio,
|
Twilio,
|
||||||
senders.Webhook,
|
Webhook,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,13 +13,12 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
package senders
|
package notifiers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/statping/statping/notifiers"
|
|
||||||
"github.com/statping/statping/types/failures"
|
"github.com/statping/statping/types/failures"
|
||||||
"github.com/statping/statping/types/services"
|
"github.com/statping/statping/types/services"
|
||||||
"github.com/statping/statping/utils"
|
"github.com/statping/statping/utils"
|
||||||
|
@ -28,7 +27,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ notifiers.Notifier = (*slack)(nil)
|
var _ Notifier = (*slack)(nil)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
slackMethod = "slack"
|
slackMethod = "slack"
|
||||||
|
@ -38,10 +37,10 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type slack struct {
|
type slack struct {
|
||||||
*notifiers.Notification
|
*Notification
|
||||||
}
|
}
|
||||||
|
|
||||||
var Slacker = &slack{¬ifiers.Notification{
|
var Slacker = &slack{&Notification{
|
||||||
Method: slackMethod,
|
Method: slackMethod,
|
||||||
Title: "slack",
|
Title: "slack",
|
||||||
Description: "Send notifications to your slack channel when a service is offline. Insert your Incoming webhooker URL for your channel to receive notifications. Based on the <a href=\"https://api.slack.com/incoming-webhooks\">slack API</a>.",
|
Description: "Send notifications to your slack channel when a service is offline. Insert your Incoming webhooker URL for your channel to receive notifications. Based on the <a href=\"https://api.slack.com/incoming-webhooks\">slack API</a>.",
|
||||||
|
@ -50,7 +49,7 @@ var Slacker = &slack{¬ifiers.Notification{
|
||||||
Delay: time.Duration(10 * time.Second),
|
Delay: time.Duration(10 * time.Second),
|
||||||
Host: "https://webhooksurl.slack.com/***",
|
Host: "https://webhooksurl.slack.com/***",
|
||||||
Icon: "fab fa-slack",
|
Icon: "fab fa-slack",
|
||||||
Form: []notifiers.NotificationForm{{
|
Form: []NotificationForm{{
|
||||||
Type: "text",
|
Type: "text",
|
||||||
Title: "Incoming webhooker Url",
|
Title: "Incoming webhooker Url",
|
||||||
Placeholder: "Insert your slack Webhook URL here.",
|
Placeholder: "Insert your slack Webhook URL here.",
|
||||||
|
@ -85,7 +84,7 @@ func (u *slack) Send(msg interface{}) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *slack) Select() *notifiers.Notification {
|
func (u *slack) Select() *Notification {
|
||||||
return u.Notification
|
return u.Notification
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,13 +13,12 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
package senders
|
package notifiers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/statping/statping/notifiers"
|
|
||||||
"github.com/statping/statping/types/failures"
|
"github.com/statping/statping/types/failures"
|
||||||
"github.com/statping/statping/types/services"
|
"github.com/statping/statping/types/services"
|
||||||
"github.com/statping/statping/utils"
|
"github.com/statping/statping/utils"
|
||||||
|
@ -28,13 +27,13 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ notifiers.Notifier = (*telegram)(nil)
|
var _ Notifier = (*telegram)(nil)
|
||||||
|
|
||||||
type telegram struct {
|
type telegram struct {
|
||||||
*notifiers.Notification
|
*Notification
|
||||||
}
|
}
|
||||||
|
|
||||||
var Telegram = &telegram{¬ifiers.Notification{
|
var Telegram = &telegram{&Notification{
|
||||||
Method: "telegram",
|
Method: "telegram",
|
||||||
Title: "Telegram",
|
Title: "Telegram",
|
||||||
Description: "Receive notifications on your Telegram channel when a service has an issue. You must get a Telegram API token from the /botfather. Review the <a target=\"_blank\" href=\"http://techthoughts.info/how-to-create-a-telegram-bot-and-send-messages-via-api\">Telegram API Tutorial</a> to learn how to generate a new API Token.",
|
Description: "Receive notifications on your Telegram channel when a service has an issue. You must get a Telegram API token from the /botfather. Review the <a target=\"_blank\" href=\"http://techthoughts.info/how-to-create-a-telegram-bot-and-send-messages-via-api\">Telegram API Tutorial</a> to learn how to generate a new API Token.",
|
||||||
|
@ -42,7 +41,7 @@ var Telegram = &telegram{¬ifiers.Notification{
|
||||||
AuthorUrl: "https://github.com/hunterlong",
|
AuthorUrl: "https://github.com/hunterlong",
|
||||||
Icon: "fab fa-telegram-plane",
|
Icon: "fab fa-telegram-plane",
|
||||||
Delay: time.Duration(5 * time.Second),
|
Delay: time.Duration(5 * time.Second),
|
||||||
Form: []notifiers.NotificationForm{{
|
Form: []NotificationForm{{
|
||||||
Type: "text",
|
Type: "text",
|
||||||
Title: "Telegram API Token",
|
Title: "Telegram API Token",
|
||||||
Placeholder: "383810182:EEx829dtCeufeQYXG7CUdiQopqdmmxBPO7-s",
|
Placeholder: "383810182:EEx829dtCeufeQYXG7CUdiQopqdmmxBPO7-s",
|
||||||
|
@ -59,7 +58,7 @@ var Telegram = &telegram{¬ifiers.Notification{
|
||||||
}}},
|
}}},
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *telegram) Select() *notifiers.Notification {
|
func (u *telegram) Select() *Notification {
|
||||||
return u.Notification
|
return u.Notification
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,13 +13,12 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
package senders
|
package notifiers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/statping/statping/notifiers"
|
|
||||||
"github.com/statping/statping/types/failures"
|
"github.com/statping/statping/types/failures"
|
||||||
"github.com/statping/statping/types/services"
|
"github.com/statping/statping/types/services"
|
||||||
"github.com/statping/statping/utils"
|
"github.com/statping/statping/utils"
|
||||||
|
@ -28,13 +27,13 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ notifiers.Notifier = (*twilio)(nil)
|
var _ Notifier = (*twilio)(nil)
|
||||||
|
|
||||||
type twilio struct {
|
type twilio struct {
|
||||||
*notifiers.Notification
|
*Notification
|
||||||
}
|
}
|
||||||
|
|
||||||
var Twilio = &twilio{¬ifiers.Notification{
|
var Twilio = &twilio{&Notification{
|
||||||
Method: "twilio",
|
Method: "twilio",
|
||||||
Title: "Twilio",
|
Title: "Twilio",
|
||||||
Description: "Receive SMS text messages directly to your cellphone when a service is offline. You can use a Twilio test account with limits. This notifier uses the <a href=\"https://www.twilio.com/docs/usage/api\">Twilio API</a>.",
|
Description: "Receive SMS text messages directly to your cellphone when a service is offline. You can use a Twilio test account with limits. This notifier uses the <a href=\"https://www.twilio.com/docs/usage/api\">Twilio API</a>.",
|
||||||
|
@ -42,7 +41,7 @@ var Twilio = &twilio{¬ifiers.Notification{
|
||||||
AuthorUrl: "https://github.com/hunterlong",
|
AuthorUrl: "https://github.com/hunterlong",
|
||||||
Icon: "far fa-comment-alt",
|
Icon: "far fa-comment-alt",
|
||||||
Delay: time.Duration(10 * time.Second),
|
Delay: time.Duration(10 * time.Second),
|
||||||
Form: []notifiers.NotificationForm{{
|
Form: []NotificationForm{{
|
||||||
Type: "text",
|
Type: "text",
|
||||||
Title: "Account SID",
|
Title: "Account SID",
|
||||||
Placeholder: "Insert your Twilio Account SID",
|
Placeholder: "Insert your Twilio Account SID",
|
||||||
|
@ -69,7 +68,7 @@ var Twilio = &twilio{¬ifiers.Notification{
|
||||||
}}},
|
}}},
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *twilio) Select() *notifiers.Notification {
|
func (u *twilio) Select() *Notification {
|
||||||
return u.Notification
|
return u.Notification
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,12 +13,11 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
package senders
|
package notifiers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/statping/statping/notifiers"
|
|
||||||
"github.com/statping/statping/types/failures"
|
"github.com/statping/statping/types/failures"
|
||||||
"github.com/statping/statping/types/services"
|
"github.com/statping/statping/types/services"
|
||||||
"github.com/statping/statping/utils"
|
"github.com/statping/statping/utils"
|
||||||
|
@ -28,17 +27,17 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ notifiers.Notifier = (*webhooker)(nil)
|
var _ Notifier = (*webhooker)(nil)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
webhookMethod = "webhook"
|
webhookMethod = "webhook"
|
||||||
)
|
)
|
||||||
|
|
||||||
type webhooker struct {
|
type webhooker struct {
|
||||||
*notifiers.Notification
|
*Notification
|
||||||
}
|
}
|
||||||
|
|
||||||
var Webhook = &webhooker{¬ifiers.Notification{
|
var Webhook = &webhooker{&Notification{
|
||||||
Method: webhookMethod,
|
Method: webhookMethod,
|
||||||
Title: "HTTP webhooker",
|
Title: "HTTP webhooker",
|
||||||
Description: "Send a custom HTTP request to a specific URL with your own body, headers, and parameters.",
|
Description: "Send a custom HTTP request to a specific URL with your own body, headers, and parameters.",
|
||||||
|
@ -46,7 +45,7 @@ var Webhook = &webhooker{¬ifiers.Notification{
|
||||||
AuthorUrl: "https://github.com/hunterlong",
|
AuthorUrl: "https://github.com/hunterlong",
|
||||||
Icon: "fas fa-code-branch",
|
Icon: "fas fa-code-branch",
|
||||||
Delay: time.Duration(1 * time.Second),
|
Delay: time.Duration(1 * time.Second),
|
||||||
Form: []notifiers.NotificationForm{{
|
Form: []NotificationForm{{
|
||||||
Type: "text",
|
Type: "text",
|
||||||
Title: "HTTP Endpoint",
|
Title: "HTTP Endpoint",
|
||||||
Placeholder: "http://webhookurl.com/JW2MCP4SKQP",
|
Placeholder: "http://webhookurl.com/JW2MCP4SKQP",
|
||||||
|
@ -90,7 +89,7 @@ func (w *webhooker) Send(msg interface{}) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *webhooker) Select() *notifiers.Notification {
|
func (w *webhooker) Select() *Notification {
|
||||||
return w.Notification
|
return w.Notification
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +131,7 @@ func (w *webhooker) sendHttpWebhook(body string) (*http.Response, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *webhooker) OnTest() error {
|
func (w *webhooker) OnTest() error {
|
||||||
body := replaceBodyText(w.Var2, notifiers.ExampleService, nil)
|
body := replaceBodyText(w.Var2, ExampleService, nil)
|
||||||
resp, err := w.sendHttpWebhook(body)
|
resp, err := w.sendHttpWebhook(body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
|
@ -38,7 +38,7 @@ func humanMicro(val int64) string {
|
||||||
if val < 10000 {
|
if val < 10000 {
|
||||||
return fmt.Sprintf("%d μs", val)
|
return fmt.Sprintf("%d μs", val)
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%d ms", float64(val)*0.001)
|
return fmt.Sprintf("%v ms", float64(val)*0.001)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsRunning returns true if the service go routine is running
|
// IsRunning returns true if the service go routine is running
|
||||||
|
|
|
@ -3,7 +3,6 @@ package services
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/statping/statping/notifiers"
|
|
||||||
"github.com/statping/statping/types/failures"
|
"github.com/statping/statping/types/failures"
|
||||||
"github.com/statping/statping/types/hits"
|
"github.com/statping/statping/types/hits"
|
||||||
"github.com/statping/statping/utils"
|
"github.com/statping/statping/utils"
|
||||||
|
@ -240,10 +239,10 @@ func recordSuccess(s *Service) {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
log.WithFields(utils.ToFields(hit, s)).Infoln(
|
log.WithFields(utils.ToFields(hit, s)).Infoln(
|
||||||
fmt.Sprintf("Service #%d '%v' Successful Response: %s | Lookup in: %v | Online: %v | Interval: %d seconds", s.Id, s.Name, humanMicro(hit.Latency), humanMicro(hit.PingTime), s.Online, s.Interval))
|
fmt.Sprintf("Service #%d '%v' Successful Response: %v | Lookup in: %v | Online: %v | Interval: %d seconds", s.Id, s.Name, humanMicro(hit.Latency), humanMicro(hit.PingTime), s.Online, s.Interval))
|
||||||
s.LastLookupTime = hit.PingTime
|
s.LastLookupTime = hit.PingTime
|
||||||
s.LastLatency = hit.Latency
|
s.LastLatency = hit.Latency
|
||||||
notifiers.OnSuccess(s)
|
//notifiers.OnSuccess(s)
|
||||||
s.SuccessNotified = true
|
s.SuccessNotified = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +266,7 @@ func recordFailure(s *Service, issue string) {
|
||||||
s.Online = false
|
s.Online = false
|
||||||
s.SuccessNotified = false
|
s.SuccessNotified = false
|
||||||
s.DownText = s.DowntimeText()
|
s.DownText = s.DowntimeText()
|
||||||
notifiers.OnFailure(s, fail)
|
//notifiers.OnFailure(s, fail)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check will run checkHttp for HTTP services and checkTcp for TCP services
|
// Check will run checkHttp for HTTP services and checkTcp for TCP services
|
||||||
|
|
Loading…
Reference in New Issue