v0.0.0-...-0df215e Latest Latest

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

Go to latest
Published: Jan 7, 2016 License: MIT Imports: 33 Imported by: 0




This section is empty.


This section is empty.


func Send

func Send(e *email.Email, addr, username, password string) error

Send an email using the given host and SMTP auth (optional), returns any error thrown by smtp.SendMail. This function merges the To, Cc, and Bcc fields and calls the smtp.SendMail function using the Email.Bytes() output as the message.

func SendMail

func SendMail(addr, username, password string, from string, to []string, msg []byte) error

SendMail connects to the server at addr, switches to TLS if possible, authenticates with the optional mechanism a if possible, and then sends an email from address from, to addresses to, with message msg.


type Alert

type Alert struct {
	Text string
	*Template        `json:"-"`
	Name             string
	Crit             *expr.Expr `json:",omitempty"`
	Warn             *expr.Expr `json:",omitempty"`
	Depends          *expr.Expr `json:",omitempty"`
	Squelch          Squelches  `json:"-"`
	CritNotification *Notifications
	WarnNotification *Notifications
	Unknown          time.Duration
	MaxLogFrequency  time.Duration
	IgnoreUnknown    bool
	UnjoinedOK       bool `json:",omitempty"`
	Log              bool
	RunEvery         int
	// contains filtered or unexported fields

type Attachment

type Attachment struct {
	Data        []byte
	Filename    string
	ContentType string

type ByteSize

type ByteSize float64
const (
	KB ByteSize = 1 << (10 * iota)

func (ByteSize) String

func (b ByteSize) String() string

type Conf

type Conf struct {
	Name             string        // Config file name
	CheckFrequency   time.Duration // Time between alert checks: 5m
	DefaultRunEvery  int           // Default number of check intervals to run each alert: 1
	HTTPListen       string        // Web server listen address: :80
	Hostname         string
	RelayListen      string // OpenTSDB relay listen address: :4242
	SMTPHost         string // SMTP address: ny-mail:25
	SMTPUsername     string // SMTP username
	SMTPPassword     string // SMTP password
	Ping             bool
	PingDuration     time.Duration // Duration from now to stop pinging hosts based on time since the host tag was touched
	EmailFrom        string
	StateFile        string
	LedisDir         string
	RedisHost        string
	TimeAndDate      []int // cities list
	ResponseLimit    int64
	SearchSince      opentsdb.Duration
	UnknownTemplate  *Template
	UnknownThreshold int
	Templates        map[string]*Template
	Alerts           map[string]*Alert
	Notifications    map[string]*Notification `json:"-"`
	RawText          string
	Macros           map[string]*Macro
	Lookups          map[string]*Lookup
	Squelch          Squelches `json:"-"`
	Quiet            bool
	NoSleep          bool
	ShortURLKey      string
	MinGroupSize     int

	TSDBHost             string                    // OpenTSDB relay and query destination: ny-devtsdb04:4242
	TSDBVersion          *opentsdb.Version         // If set to 2.2 , enable passthrough of wildcards and filters, and add support for groupby
	GraphiteHost         string                    // Graphite query host:
	GraphiteHeaders      []string                  // extra http headers when querying graphite.
	LogstashElasticHosts expr.LogstashElasticHosts // CSV Elastic Hosts (All part of the same cluster) that stores logstash documents, i.e http://ny-elastic01:9200
	InfluxConfig         client.Config
	// contains filtered or unexported fields

func New

func New(name, text string) (c *Conf, err error)

func ParseFile

func ParseFile(fname string) (*Conf, error)

func (*Conf) AlertSquelched

func (c *Conf) AlertSquelched(a *Alert) func(opentsdb.TagSet) bool

func (*Conf) Expand

func (c *Conf) Expand(v string, vars map[string]string, ignoreBadExpand bool) string

func (*Conf) Funcs

func (c *Conf) Funcs() map[string]eparse.Func

func (*Conf) GraphiteContext

func (c *Conf) GraphiteContext() graphite.Context

GraphiteContext returns a Graphite context. A nil context is returned if GraphiteHost is not set.

func (c *Conf) MakeLink(path string, v *url.Values) string

func (*Conf) NewExpr

func (c *Conf) NewExpr(s string) *expr.Expr

func (*Conf) Squelched

func (c *Conf) Squelched(a *Alert, tags opentsdb.TagSet) bool

func (*Conf) TSDBContext

func (c *Conf) TSDBContext() opentsdb.Context

TSDBContext returns an OpenTSDB context limited to c.ResponseLimit. A nil context is returned if TSDBHost is not set.

type Entry

type Entry struct {
	Def  string
	Name string

type ExprEntry

type ExprEntry struct {
	AlertKey models.AlertKey
	Values   map[string]string

type ExprLookup

type ExprLookup struct {
	Tags    []string
	Entries []*ExprEntry

TODO: remove this and merge it with Lookup

func (*ExprLookup) Get

func (lookup *ExprLookup) Get(key string, tag opentsdb.TagSet) (value string, ok bool)

type Lookup

type Lookup struct {
	Text    string
	Name    string
	Tags    []string
	Entries []*Entry

func (*Lookup) ToExpr

func (lookup *Lookup) ToExpr() *ExprLookup

type Macro

type Macro struct {
	Text  string
	Pairs []nodePair
	Name  string

type Notification

type Notification struct {
	Text string
	Name         string
	Email        []*mail.Address
	Post, Get    *url.URL
	Body         *ttemplate.Template
	Print        bool
	Next         *Notification
	Timeout      time.Duration
	ContentType  string
	RunOnActions bool
	UseBody      bool
	// contains filtered or unexported fields

func (*Notification) DoEmail

func (n *Notification) DoEmail(subject, body []byte, c *Conf, ak string, attachments ...*Attachment)

func (*Notification) DoGet

func (n *Notification) DoGet(ak string)

func (*Notification) DoPost

func (n *Notification) DoPost(payload []byte, ak string)

func (*Notification) DoPrint

func (n *Notification) DoPrint(payload string)

func (*Notification) GetPayload

func (n *Notification) GetPayload(subject, body string) (payload []byte)

func (*Notification) MarshalJSON

func (n *Notification) MarshalJSON() ([]byte, error)

func (*Notification) Notify

func (n *Notification) Notify(subject, body string, emailsubject, emailbody []byte, c *Conf, ak string, attachments ...*Attachment)

type Notifications

type Notifications struct {
	Notifications map[string]*Notification `json:"-"`
	// Table key -> table
	Lookups map[string]*Lookup

func (*Notifications) Get

func (ns *Notifications) Get(c *Conf, tags opentsdb.TagSet) map[string]*Notification

Get returns the set of notifications based on given tags.

type Squelch

type Squelch map[string]*regexp.Regexp

func (Squelch) Squelched

func (s Squelch) Squelched(tags opentsdb.TagSet) bool

type Squelches

type Squelches struct {
	// contains filtered or unexported fields

func (*Squelches) Add

func (s *Squelches) Add(v string) error

func (*Squelches) Squelched

func (s *Squelches) Squelched(tags opentsdb.TagSet) bool

type Template

type Template struct {
	Text string
	Name    string
	Body    *htemplate.Template `json:"-"`
	Subject *ttemplate.Template `json:"-"`
	// contains filtered or unexported fields

type Vars

type Vars map[string]string


Path Synopsis
Package parse builds parse trees for configurations as defined by conf.
Package parse builds parse trees for configurations as defined by conf.

Jump to

Keyboard shortcuts

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