conf

package
v0.0.0-...-7afe134 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2014 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Send

func Send(e *email.Email, addr 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 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.

Types

type Alert

type Alert struct {
	Def string
	Vars
	*Template        `json:"-"`
	Name             string
	Crit             *expr.Expr `json:",omitempty"`
	Warn             *expr.Expr `json:",omitempty"`
	Squelch          Squelches  `json:"-"`
	CritNotification *Notifications
	WarnNotification *Notifications
	Unknown          time.Duration
	IgnoreUnknown    bool
	Macros           []string `json:"-"`
	UnjoinedOK       bool     `json:",omitempty"`
	// contains filtered or unexported fields
}

type AlertTemplateStrings

type AlertTemplateStrings struct {
	Templates   map[string]string
	Alerts      map[string]string
	Assocations map[string]string
}

type Attachment

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

type ByteSize

type ByteSize float64
const (
	KB ByteSize = 1 << (10 * iota)
	MB
	GB
	TB
	PB
	EB
	ZB
	YB
)

func (ByteSize) String

func (b ByteSize) String() string

type Conf

type Conf struct {
	Vars
	Name            string        // Config file name
	CheckFrequency  time.Duration // Time between alert checks: 5m
	WebDir          string        // Static content web directory: web
	TsdbHost        string        // OpenTSDB relay and query destination: ny-devtsdb04:4242
	HttpListen      string        // Web server listen address: :80
	RelayListen     string        // OpenTSDB relay listen address: :4242
	SmtpHost        string        // SMTP address: ny-mail:25
	Ping            bool
	EmailFrom       string
	StateFile       string
	TimeAndDate     []int // timeanddate.com cities list
	ResponseLimit   int64
	UnknownTemplate *Template
	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
	// 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) AlertTemplateStrings

func (c *Conf) AlertTemplateStrings() (*AlertTemplateStrings, error)

func (*Conf) Expand

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

func (*Conf) GetLookups

func (c *Conf) GetLookups() map[string]*expr.Lookup

GetLookups converts all lookup tables to maps for use by the expr package.

func (*Conf) Squelched

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

type Entry

type Entry struct {
	*expr.Entry
	Def  string
	Name string
}

type Lookup

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

func (*Lookup) ToExpr

func (lookup *Lookup) ToExpr() *expr.Lookup

type Macro

type Macro struct {
	Def    string
	Pairs  []nodePair
	Name   string
	Macros []string
}

type Notification

type Notification struct {
	Def string
	Vars
	Name      string
	Email     []*mail.Address
	Post, Get *url.URL
	Body      *ttemplate.Template
	Print     bool
	Next      *Notification
	Timeout   time.Duration
	// 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()

func (*Notification) DoPost

func (n *Notification) DoPost(subject []byte)

func (*Notification) DoPrint

func (n *Notification) DoPrint(subject []byte)

func (*Notification) MarshalJSON

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

func (*Notification) Notify

func (n *Notification) Notify(subject, body []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 {
	Def string
	Vars
	Name    string
	Body    *htemplate.Template `json:"-"`
	Subject *ttemplate.Template `json:"-"`
	// contains filtered or unexported fields
}

type Vars

type Vars map[string]string

Directories

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