notifiers

package
v0.90.51 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2020 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &commandLine{&notifications.Notification{
	Method:      "command",
	Title:       "Command",
	Description: "Shell Command allows you to run a customized shell/bash Command on the local machine it's running on.",
	Author:      "Hunter Long",
	AuthorUrl:   "https://github.com/hunterlong",
	Delay:       time.Duration(1 * time.Second),
	Icon:        "fas fa-terminal",
	Host:        "/bin/bash",
	SuccessData: "curl -L http://localhost:8080",
	FailureData: "curl -L http://localhost:8080",
	DataType:    "text",
	Limits:      60,
	Form: []notifications.NotificationForm{{
		Type:        "text",
		Title:       "Executable Path",
		Placeholder: "/usr/bin/curl",
		DbField:     "host",
		SmallText:   "You can use '/bin/sh', '/bin/bash', '/usr/bin/curl' or an absolute path for an application.",
	}}},
}
View Source
var Discorder = &discord{&notifications.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>.",
	Author:      "Hunter Long",
	AuthorUrl:   "https://github.com/hunterlong",
	Delay:       time.Duration(5 * time.Second),
	Host:        "https://discordapp.com/api/webhooks/****/*****",
	Icon:        "fab fa-discord",
	SuccessData: `{"content": "Your service '{{.Service.Name}}' is currently online!"}`,
	FailureData: `{"content": "Your service '{{.Service.Name}}' is currently failing! Reason: {{.Failure.Issue}}"}`,
	DataType:    "json",
	Limits:      60,
	Form: []notifications.NotificationForm{{
		Type:        "text",
		Title:       "discord webhooker URL",
		Placeholder: "Insert your Webhook URL here",
		DbField:     "host",
	}}},
}
View Source
var ExampleService = &services.Service{
	Id:                  1,
	Name:                "Statping",
	Domain:              "https://statping.com",
	Expected:            null.NewNullString("a better response"),
	ExpectedStatus:      200,
	Interval:            60,
	Type:                "http",
	Method:              "get",
	Timeout:             10,
	Order:               2,
	VerifySSL:           null.NewNullBool(true),
	Public:              null.NewNullBool(true),
	GroupId:             0,
	Permalink:           null.NewNullString("statping"),
	Online:              true,
	Latency:             324399,
	PingTime:            18399,
	Online24Hours:       99.2,
	Online7Days:         99.8,
	AvgResponse:         300233,
	FailuresLast24Hours: 4,
	Checkpoint:          utils.Now().Add(-10 * time.Minute),
	SleepDuration:       55,
	LastResponse:        "returning from a response",
	AllowNotifications:  null.NewNullBool(true),
	UserNotified:        false,
	UpdateNotify:        null.NewNullBool(true),
	SuccessNotified:     false,
	LastStatusCode:      200,
	LastLookupTime:      5233,
	LastLatency:         270233,
	LastCheck:           utils.Now().Add(-15 * time.Second),
	LastOnline:          utils.Now().Add(-15 * time.Second),
	LastOffline:         utils.Now().Add(-10 * time.Minute),
	SecondsOnline:       4500,
	SecondsOffline:      300,
	Redirect:            null.NewNullBool(true),
}
View Source
var LineNotify = &lineNotifier{&notifications.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",
	Limits:      60,
	Form: []notifications.NotificationForm{{
		Type:        "text",
		Title:       "Access Token",
		Placeholder: "Insert your Line Notify Access Token here.",
		DbField:     "api_secret",
	}}},
}
View Source
var Mobile = &mobilePush{&notifications.Notification{
	Method: "mobile",
	Title:  "Mobile",
	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.
				 <p align="center"><a href="https://play.google.com/store/apps/details?id=com.statping"><img src="https://img.cjx.io/google-play.svg"></a><a href="https://itunes.apple.com/us/app/apple-store/id1445513219"><img src="https://img.cjx.io/app-store-badge.svg"></a></p>`,
	Author:    "Hunter Long",
	AuthorUrl: "https://github.com/hunterlong",
	Delay:     time.Duration(5 * time.Second),
	Icon:      "fas fa-mobile-alt",
	Limits:    30,
	Form: []notifications.NotificationForm{{
		Type:        "text",
		Title:       "Device Identifiers",
		Placeholder: "A list of your Mobile device push notification ID's.",
		DbField:     "var1",
		IsHidden:    true,
	}, {
		Type:        "number",
		Title:       "Array of device numbers",
		Placeholder: "1 for iphone 2 for android",
		DbField:     "var2",
		IsHidden:    true,
	}}},
}
View Source
var Pushover = &pushover{&notifications.Notification{
	Method:      "pushover",
	Title:       "Pushover",
	Description: "Use Pushover to receive push notifications. You will need to create a <a href=\"https://pushover.net/apps/build\">New Application</a> on Pushover before using this notifier.",
	Author:      "Hunter Long",
	AuthorUrl:   "https://github.com/hunterlong",
	Icon:        "fa dot-circle",
	Delay:       time.Duration(10 * time.Second),
	Limits:      60,
	SuccessData: `Your service '{{.Service.Name}}' is currently online!`,
	FailureData: `Your service '{{.Service.Name}}' is currently offline!`,
	DataType:    "text",
	Form: []notifications.NotificationForm{{
		Type:        "text",
		Title:       "User Token",
		Placeholder: "Insert your device's Pushover Token",
		DbField:     "api_key",
		Required:    true,
	}, {
		Type:        "text",
		Title:       "Application API Key",
		Placeholder: "Create an Application and insert the API Key here",
		DbField:     "api_secret",
		Required:    true,
	},
	}},
}
View Source
var Telegram = &telegram{&notifications.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.",
	Author:      "Hunter Long",
	AuthorUrl:   "https://github.com/hunterlong",
	Icon:        "fab fa-telegram-plane",
	Delay:       time.Duration(5 * time.Second),
	SuccessData: "Your service '{{.Service.Name}}' is currently online!",
	FailureData: "Your service '{{.Service.Name}}' is currently offline!",
	DataType:    "text",
	Limits:      60,
	Form: []notifications.NotificationForm{{
		Type:        "text",
		Title:       "Telegram API Token",
		Placeholder: "383810182:EEx829dtCeufeQYXG7CUdiQopqdmmxBPO7-s",
		SmallText:   "Enter the API Token given to you from the /botfather chat.",
		DbField:     "api_secret",
		Required:    true,
	}, {
		Type:        "text",
		Title:       "Channel or User",
		Placeholder: "@statping_channel",
		SmallText:   "Insert your Telegram Channel or User here.",
		DbField:     "var1",
		Required:    true,
	}}},
}
View Source
var Twilio = &twilio{&notifications.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>.",
	Author:      "Hunter Long",
	AuthorUrl:   "https://github.com/hunterlong",
	Icon:        "far fa-comment-alt",
	Delay:       time.Duration(10 * time.Second),
	SuccessData: "Your service '{{.Service.Name}}' is currently online!",
	FailureData: "Your service '{{.Service.Name}}' is currently offline!",
	DataType:    "text",
	Limits:      15,
	Form: []notifications.NotificationForm{{
		Type:        "text",
		Title:       "Account SID",
		Placeholder: "Insert your Twilio Account SID",
		DbField:     "api_key",
		Required:    true,
	}, {
		Type:        "text",
		Title:       "Account Token",
		Placeholder: "Insert your Twilio Account Token",
		DbField:     "api_secret",
		Required:    true,
	}, {
		Type:        "text",
		Title:       "SMS to Phone Number",
		Placeholder: "18555555555",
		DbField:     "Var1",
		Required:    true,
	}, {
		Type:        "text",
		Title:       "From Phone Number",
		Placeholder: "18555555555",
		DbField:     "Var2",
		Required:    true,
	}}},
}
View Source
var Webhook = &webhooker{&notifications.Notification{
	Method:      webhookMethod,
	Title:       "Webhook",
	Description: "Send a custom HTTP request to a specific URL with your own body, headers, and parameters.",
	Author:      "Hunter Long",
	AuthorUrl:   "https://github.com/hunterlong",
	Icon:        "fas fa-code-branch",
	Delay:       time.Duration(1 * time.Second),
	SuccessData: `{"id": {{.Service.Id}}, "online": true}`,
	FailureData: `{"id": {{.Service.Id}}, "online": false}`,
	DataType:    "json",
	Limits:      180,
	Form: []notifications.NotificationForm{{
		Type:        "text",
		Title:       "HTTP Endpoint",
		Placeholder: "http://webhookurl.com/JW2MCP4SKQP",
		SmallText:   "Insert the URL for your HTTP Requests.",
		DbField:     "Host",
		Required:    true,
	}, {
		Type:        "text",
		Title:       "HTTP Method",
		Placeholder: "POST",
		SmallText:   "Choose a HTTP method for example: GET, POST, DELETE, or PATCH.",
		DbField:     "Var1",
		Required:    true,
	}, {
		Type:        "text",
		Title:       "Content Type",
		Placeholder: `application/json`,
		SmallText:   "Optional content type for example: application/json or text/plain",
		DbField:     "api_key",
	}, {
		Type:        "text",
		Title:       "Header",
		Placeholder: "Authorization=Token12345",
		SmallText:   "Optional Headers for request use format: KEY=Value,Key=Value",
		DbField:     "api_secret",
	},
	}}}

Functions

func Add added in v0.90.11

func Add(notifs ...services.ServiceNotifier)

func InitNotifiers added in v0.90.11

func InitNotifiers()

func ReplaceTemplate added in v0.90.36

func ReplaceTemplate(tmpl string, data replacer) string

func ReplaceVars added in v0.90.16

func ReplaceVars(input string, s *services.Service, f *failures.Failure) string

Types

type PushNotification added in v0.80.2

type PushNotification struct {
	Array []*pushArray `json:"notifications"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL