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
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package senders
|
||||
package notifiers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/statping/statping/notifiers"
|
||||
"github.com/statping/statping/types/failures"
|
||||
"github.com/statping/statping/types/services"
|
||||
"github.com/statping/statping/utils"
|
||||
|
@ -25,13 +24,13 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
var _ notifiers.Notifier = (*commandLine)(nil)
|
||||
var _ Notifier = (*commandLine)(nil)
|
||||
|
||||
type commandLine struct {
|
||||
*notifiers.Notification
|
||||
*Notification
|
||||
}
|
||||
|
||||
var Command = &commandLine{¬ifiers.Notification{
|
||||
var Command = &commandLine{&Notification{
|
||||
Method: "command",
|
||||
Title: "Shell Command",
|
||||
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),
|
||||
Icon: "fas fa-terminal",
|
||||
Host: "/bin/bash",
|
||||
Form: []notifiers.NotificationForm{{
|
||||
Form: []NotificationForm{{
|
||||
Type: "text",
|
||||
Title: "Shell or Bash",
|
||||
Placeholder: "/bin/bash",
|
||||
|
@ -66,7 +65,7 @@ func runCommand(app string, cmd ...string) (string, string, error) {
|
|||
return outStr, errStr, err
|
||||
}
|
||||
|
||||
func (u *commandLine) Select() *notifiers.Notification {
|
||||
func (u *commandLine) Select() *Notification {
|
||||
return u.Notification
|
||||
}
|
||||
|
|
@ -13,14 +13,13 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package senders
|
||||
package notifiers
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/statping/statping/notifiers"
|
||||
"github.com/statping/statping/types/failures"
|
||||
"github.com/statping/statping/types/services"
|
||||
"github.com/statping/statping/utils"
|
||||
|
@ -28,13 +27,13 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
var _ notifiers.Notifier = (*discord)(nil)
|
||||
var _ Notifier = (*discord)(nil)
|
||||
|
||||
type discord struct {
|
||||
*notifiers.Notification
|
||||
*Notification
|
||||
}
|
||||
|
||||
var Discorder = &discord{¬ifiers.Notification{
|
||||
var Discorder = &discord{&Notification{
|
||||
Method: "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>.",
|
||||
|
@ -43,7 +42,7 @@ var Discorder = &discord{¬ifiers.Notification{
|
|||
Delay: time.Duration(5 * time.Second),
|
||||
Host: "https://discordapp.com/api/webhooks/****/*****",
|
||||
Icon: "fab fa-discord",
|
||||
Form: []notifiers.NotificationForm{{
|
||||
Form: []NotificationForm{{
|
||||
Type: "text",
|
||||
Title: "discord webhooker URL",
|
||||
Placeholder: "Insert your Webhook URL here",
|
||||
|
@ -58,7 +57,7 @@ func (u *discord) Send(msg interface{}) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func (u *discord) Select() *notifiers.Notification {
|
||||
func (u *discord) Select() *Notification {
|
||||
return u.Notification
|
||||
}
|
||||
|
|
@ -13,14 +13,13 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package senders
|
||||
package notifiers
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"github.com/go-mail/mail"
|
||||
"github.com/statping/statping/notifiers"
|
||||
"github.com/statping/statping/types/failures"
|
||||
"github.com/statping/statping/types/null"
|
||||
"github.com/statping/statping/types/services"
|
||||
|
@ -29,7 +28,7 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
var _ notifiers.Notifier = (*email)(nil)
|
||||
var _ Notifier = (*email)(nil)
|
||||
|
||||
const (
|
||||
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 {
|
||||
*notifiers.Notification
|
||||
*Notification
|
||||
}
|
||||
|
||||
var Emailer = &email{¬ifiers.Notification{
|
||||
var Emailer = &email{&Notification{
|
||||
Method: "email",
|
||||
Title: "email",
|
||||
Description: "Send emails via SMTP when services are online or offline.",
|
||||
Author: "Hunter Long",
|
||||
AuthorUrl: "https://github.com/hunterlong",
|
||||
Icon: "far fa-envelope",
|
||||
Form: []notifiers.NotificationForm{{
|
||||
Form: []NotificationForm{{
|
||||
Type: "text",
|
||||
Title: "SMTP Host",
|
||||
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
|
||||
}
|
||||
|
|
@ -13,11 +13,10 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package senders
|
||||
package notifiers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/statping/statping/notifiers"
|
||||
"github.com/statping/statping/types/failures"
|
||||
"github.com/statping/statping/types/services"
|
||||
"github.com/statping/statping/utils"
|
||||
|
@ -26,24 +25,24 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
var _ notifiers.Notifier = (*lineNotifier)(nil)
|
||||
var _ Notifier = (*lineNotifier)(nil)
|
||||
|
||||
const (
|
||||
lineNotifyMethod = "line_notify"
|
||||
)
|
||||
|
||||
type lineNotifier struct {
|
||||
*notifiers.Notification
|
||||
*Notification
|
||||
}
|
||||
|
||||
var LineNotify = &lineNotifier{¬ifiers.Notification{
|
||||
var LineNotify = &lineNotifier{&Notification{
|
||||
Method: lineNotifyMethod,
|
||||
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>.",
|
||||
Author: "Kanin Peanviriyakulkit",
|
||||
AuthorUrl: "https://github.com/dogrocker",
|
||||
Icon: "far fa-bell",
|
||||
Form: []notifiers.NotificationForm{{
|
||||
Form: []NotificationForm{{
|
||||
Type: "text",
|
||||
Title: "Access Token",
|
||||
Placeholder: "Insert your Line Notify Access Token here.",
|
||||
|
@ -61,7 +60,7 @@ func (u *lineNotifier) Send(msg interface{}) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func (u *lineNotifier) Select() *notifiers.Notification {
|
||||
func (u *lineNotifier) Select() *Notification {
|
||||
return u.Notification
|
||||
}
|
||||
|
|
@ -13,28 +13,27 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package senders
|
||||
package notifiers
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/statping/statping/notifiers"
|
||||
"github.com/statping/statping/types/failures"
|
||||
"github.com/statping/statping/types/services"
|
||||
"github.com/statping/statping/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
var _ notifiers.Notifier = (*mobilePush)(nil)
|
||||
var _ Notifier = (*mobilePush)(nil)
|
||||
|
||||
const mobileIdentifier = "com.statping"
|
||||
|
||||
type mobilePush struct {
|
||||
*notifiers.Notification
|
||||
*Notification
|
||||
}
|
||||
|
||||
var Mobile = &mobilePush{¬ifiers.Notification{
|
||||
var Mobile = &mobilePush{&Notification{
|
||||
Method: "mobile",
|
||||
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.
|
||||
|
@ -43,7 +42,7 @@ var Mobile = &mobilePush{¬ifiers.Notification{
|
|||
AuthorUrl: "https://github.com/hunterlong",
|
||||
Delay: time.Duration(5 * time.Second),
|
||||
Icon: "fas fa-mobile-alt",
|
||||
Form: []notifiers.NotificationForm{{
|
||||
Form: []NotificationForm{{
|
||||
Type: "text",
|
||||
Title: "Device Identifiers",
|
||||
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
|
||||
}
|
||||
|
|
@ -2,8 +2,6 @@ package notifiers
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/google/martian/log"
|
||||
"github.com/statping/statping/notifiers/senders"
|
||||
"github.com/statping/statping/types/failures"
|
||||
"github.com/statping/statping/types/services"
|
||||
"github.com/statping/statping/utils"
|
||||
|
@ -95,14 +93,14 @@ func startAllNotifiers() {
|
|||
|
||||
func Migrate() error {
|
||||
return AddNotifiers(
|
||||
senders.Command,
|
||||
senders.Discorder,
|
||||
senders.Emailer,
|
||||
senders.LineNotify,
|
||||
senders.Mobile,
|
||||
senders.Slacker,
|
||||
senders.Telegram,
|
||||
senders.Twilio,
|
||||
senders.Webhook,
|
||||
Command,
|
||||
Discorder,
|
||||
Emailer,
|
||||
LineNotify,
|
||||
Mobile,
|
||||
Slacker,
|
||||
Telegram,
|
||||
Twilio,
|
||||
Webhook,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -13,13 +13,12 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package senders
|
||||
package notifiers
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/statping/statping/notifiers"
|
||||
"github.com/statping/statping/types/failures"
|
||||
"github.com/statping/statping/types/services"
|
||||
"github.com/statping/statping/utils"
|
||||
|
@ -28,7 +27,7 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
var _ notifiers.Notifier = (*slack)(nil)
|
||||
var _ Notifier = (*slack)(nil)
|
||||
|
||||
const (
|
||||
slackMethod = "slack"
|
||||
|
@ -38,10 +37,10 @@ const (
|
|||
)
|
||||
|
||||
type slack struct {
|
||||
*notifiers.Notification
|
||||
*Notification
|
||||
}
|
||||
|
||||
var Slacker = &slack{¬ifiers.Notification{
|
||||
var Slacker = &slack{&Notification{
|
||||
Method: slackMethod,
|
||||
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>.",
|
||||
|
@ -50,7 +49,7 @@ var Slacker = &slack{¬ifiers.Notification{
|
|||
Delay: time.Duration(10 * time.Second),
|
||||
Host: "https://webhooksurl.slack.com/***",
|
||||
Icon: "fab fa-slack",
|
||||
Form: []notifiers.NotificationForm{{
|
||||
Form: []NotificationForm{{
|
||||
Type: "text",
|
||||
Title: "Incoming webhooker Url",
|
||||
Placeholder: "Insert your slack Webhook URL here.",
|
||||
|
@ -85,7 +84,7 @@ func (u *slack) Send(msg interface{}) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func (u *slack) Select() *notifiers.Notification {
|
||||
func (u *slack) Select() *Notification {
|
||||
return u.Notification
|
||||
}
|
||||
|
|
@ -13,13 +13,12 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package senders
|
||||
package notifiers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/statping/statping/notifiers"
|
||||
"github.com/statping/statping/types/failures"
|
||||
"github.com/statping/statping/types/services"
|
||||
"github.com/statping/statping/utils"
|
||||
|
@ -28,13 +27,13 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
var _ notifiers.Notifier = (*telegram)(nil)
|
||||
var _ Notifier = (*telegram)(nil)
|
||||
|
||||
type telegram struct {
|
||||
*notifiers.Notification
|
||||
*Notification
|
||||
}
|
||||
|
||||
var Telegram = &telegram{¬ifiers.Notification{
|
||||
var Telegram = &telegram{&Notification{
|
||||
Method: "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.",
|
||||
|
@ -42,7 +41,7 @@ var Telegram = &telegram{¬ifiers.Notification{
|
|||
AuthorUrl: "https://github.com/hunterlong",
|
||||
Icon: "fab fa-telegram-plane",
|
||||
Delay: time.Duration(5 * time.Second),
|
||||
Form: []notifiers.NotificationForm{{
|
||||
Form: []NotificationForm{{
|
||||
Type: "text",
|
||||
Title: "Telegram API Token",
|
||||
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
|
||||
}
|
||||
|
|
@ -13,13 +13,12 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package senders
|
||||
package notifiers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/statping/statping/notifiers"
|
||||
"github.com/statping/statping/types/failures"
|
||||
"github.com/statping/statping/types/services"
|
||||
"github.com/statping/statping/utils"
|
||||
|
@ -28,13 +27,13 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
var _ notifiers.Notifier = (*twilio)(nil)
|
||||
var _ Notifier = (*twilio)(nil)
|
||||
|
||||
type twilio struct {
|
||||
*notifiers.Notification
|
||||
*Notification
|
||||
}
|
||||
|
||||
var Twilio = &twilio{¬ifiers.Notification{
|
||||
var Twilio = &twilio{&Notification{
|
||||
Method: "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>.",
|
||||
|
@ -42,7 +41,7 @@ var Twilio = &twilio{¬ifiers.Notification{
|
|||
AuthorUrl: "https://github.com/hunterlong",
|
||||
Icon: "far fa-comment-alt",
|
||||
Delay: time.Duration(10 * time.Second),
|
||||
Form: []notifiers.NotificationForm{{
|
||||
Form: []NotificationForm{{
|
||||
Type: "text",
|
||||
Title: "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
|
||||
}
|
||||
|
|
@ -13,12 +13,11 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package senders
|
||||
package notifiers
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/statping/statping/notifiers"
|
||||
"github.com/statping/statping/types/failures"
|
||||
"github.com/statping/statping/types/services"
|
||||
"github.com/statping/statping/utils"
|
||||
|
@ -28,17 +27,17 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
var _ notifiers.Notifier = (*webhooker)(nil)
|
||||
var _ Notifier = (*webhooker)(nil)
|
||||
|
||||
const (
|
||||
webhookMethod = "webhook"
|
||||
)
|
||||
|
||||
type webhooker struct {
|
||||
*notifiers.Notification
|
||||
*Notification
|
||||
}
|
||||
|
||||
var Webhook = &webhooker{¬ifiers.Notification{
|
||||
var Webhook = &webhooker{&Notification{
|
||||
Method: webhookMethod,
|
||||
Title: "HTTP webhooker",
|
||||
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",
|
||||
Icon: "fas fa-code-branch",
|
||||
Delay: time.Duration(1 * time.Second),
|
||||
Form: []notifiers.NotificationForm{{
|
||||
Form: []NotificationForm{{
|
||||
Type: "text",
|
||||
Title: "HTTP Endpoint",
|
||||
Placeholder: "http://webhookurl.com/JW2MCP4SKQP",
|
||||
|
@ -90,7 +89,7 @@ func (w *webhooker) Send(msg interface{}) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func (w *webhooker) Select() *notifiers.Notification {
|
||||
func (w *webhooker) Select() *Notification {
|
||||
return w.Notification
|
||||
}
|
||||
|
||||
|
@ -132,7 +131,7 @@ func (w *webhooker) sendHttpWebhook(body string) (*http.Response, error) {
|
|||
}
|
||||
|
||||
func (w *webhooker) OnTest() error {
|
||||
body := replaceBodyText(w.Var2, notifiers.ExampleService, nil)
|
||||
body := replaceBodyText(w.Var2, ExampleService, nil)
|
||||
resp, err := w.sendHttpWebhook(body)
|
||||
if err != nil {
|
||||
return err
|
|
@ -38,7 +38,7 @@ func humanMicro(val int64) string {
|
|||
if val < 10000 {
|
||||
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
|
||||
|
|
|
@ -3,7 +3,6 @@ package services
|
|||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/statping/statping/notifiers"
|
||||
"github.com/statping/statping/types/failures"
|
||||
"github.com/statping/statping/types/hits"
|
||||
"github.com/statping/statping/utils"
|
||||
|
@ -240,10 +239,10 @@ func recordSuccess(s *Service) {
|
|||
log.Error(err)
|
||||
}
|
||||
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.LastLatency = hit.Latency
|
||||
notifiers.OnSuccess(s)
|
||||
//notifiers.OnSuccess(s)
|
||||
s.SuccessNotified = true
|
||||
}
|
||||
|
||||
|
@ -267,7 +266,7 @@ func recordFailure(s *Service, issue string) {
|
|||
s.Online = false
|
||||
s.SuccessNotified = false
|
||||
s.DownText = s.DowntimeText()
|
||||
notifiers.OnFailure(s, fail)
|
||||
//notifiers.OnFailure(s, fail)
|
||||
}
|
||||
|
||||
// Check will run checkHttp for HTTP services and checkTcp for TCP services
|
||||
|
|
Loading…
Reference in New Issue