helpers

package
v0.0.0-...-1f844ef Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: ISC Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const SleepTime = 500

SleepTime is the sleep time of the signal handler loop

Variables

View Source
var Pause = false

Pause state

Functions

func AutoPause

func AutoPause(config *CONFIG)

AutoPause cron

func SendNotification

func SendNotification(notifications chan *Alert, config *CONFIG)

SendNotification send a notification

func SetPause

func SetPause()

SetPause pause the polling

func SetResume

func SetResume()

SetResume resume from pause

func SignalHandler

func SignalHandler()

SignalHandler handle the SIGUSR1 to pause the app

Types

type Alert

type Alert struct {
	Host     string
	Desc     string
	Class    string
	NotesURL string
}

Alert define a event

type CONFIG

type CONFIG struct {
	Server                        string   `toml:"server" default:""`
	Refresh                       int      `toml:"refresh" default:"30"`
	LongRefresh                   int      `toml:"long_refresh" default:"60"`
	HostsPattern                  []string `toml:"hosts_pattern"`
	HostsPatternString            string
	Client                        bool   `default:"false"`
	Debug                         bool   `toml:"debug" default:"false"`
	Popup                         bool   `toml:"popup" default:"true"`
	Warnings                      bool   `toml:"warnings" default:"true"`
	NotificationSnoozeCycle       int    `toml:"notification_snooze_cycle" default:"10"`
	Acknowledged                  int    `toml:"acknowledged" default:"0"`
	NotificationsEnabled          int    `toml:"notifications_enabled" default:"1"`
	InNotificationPeriod          int    `toml:"in_notification_period" default:"1"`
	ScheduledDowntimeDepth        int    `toml:"scheduled_downtime_depth" default:"0"`
	ServiceScheduledDowntimeDepth int    `toml:"service_scheduled_downtime_depth" default:"0"`
	HostScheduledDowntimeDepth    int    `toml:"host_scheduled_downtime_depth" default:"0"`
	ServicePrefix                 string `toml:"service_prefix" default:""`
	HostPrefix                    string `toml:"host_prefix" default:""`
	PausePrefix                   string `toml:"pause_prefix" default:""`
	ErrorPrefix                   string `toml:"error_prefix" default:""`
	OkPrefix                      string `toml:"ok_prefix" default:""`
	FlappingIcon                  string `toml:"flapping_icon" default:""`
	HostsOnly                     bool   `toml:"hosts_only" default:"false"`
	ServicesOnly                  bool   `toml:"services_only" default:"false"`
	NotesURL                      bool   `toml:"notes_url" default:"false"`
	Limit                         int    `toml:"limit" default:"0"`
	GetDuration                   bool   `toml:"get_duration" default:"false"`
	// eg: 0 9 * * *
	AutoStart string `toml:"auto_start" default:""`
	// eg: 0 22 * * *
	AutoStop string `toml:"auto_stop" default:""`
}

CONFIG define the configuration content

func GetConfig

func GetConfig() *CONFIG

GetConfig merge config from file and flag and return `config`

type WaybarOutput

type WaybarOutput struct {
	Text    string `json:"text"`
	Tooltip string `json:"tooltip"`
	Class   string `json:"class"`
	Count   int    `json:"count"`
}

WaybarOutput struct

Jump to

Keyboard shortcuts

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