Documentation
¶
Overview ¶
Package webwatch provides the Webwatch tool.
Webwatch checks HTTP/HTTPS URLs and sends mail if there's a problem.
See https://github.com/cvilsmeier/webwatch for more info..
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type CheckResult ¶
A CheckResult contains the result of checking a number of URLs for their reachability.
func (CheckResult) IsDifferent ¶
func (cr CheckResult) IsDifferent(other CheckResult) bool
IsDifferent returns true if cr differs from other.
type Checker ¶
type Checker interface { // Check checks URLs and returns a CheckResult. Check() CheckResult }
A Checker checks URLs and returns a CheckResult.
func NewChecker ¶
NewChecker creates a new Checker that checks a list of URLs.
type Config ¶
type Config struct { Urls []string `json:"urls"` Checks Interval `json:"checks"` Reports Interval `json:"reports"` Limit Interval `json:"limit"` Mail MailConfig `json:"mail"` }
Config holds the configuration data found in the config.json file.
func LoadConfig ¶
LoadConfig loads the JSON configuration file and converts it to a Config structure. LoadConfig returns an error if the fil cannot be loaded or parsed.
type Interval ¶
Interval is a time.Duration that can be marshalled to and unmarshalled from JSON.
func (Interval) MarshalJSON ¶
MarshalJSON converts a JSON value to an Interval.
func (Interval) String ¶
String() returns a string representation of this Interval, see https://golang.org/pkg/time/#Duration.String for more info.
func (*Interval) UnmarshalJSON ¶
UnmarshalJSON converts an Interval to JSON.
type Loop ¶
type Loop struct {
// contains filtered or unexported fields
}
Loop is the main loop.
type MailConfig ¶
type MailConfig struct { Subject string `json:"subject"` From string `json:"from"` To string `json:"to"` Host string `json:"host"` Username string `json:"username"` Password string `json:"password"` }
MailConfig holds the mail configuration found in the config.json file.
type Mailer ¶
type Mailer interface { // SendRestarted sends a 'restarted' mail. SendRestarted(now time.Time) // SendReport sends a 'OK' or 'ERR' mail. SendReport(now time.Time, ok bool, text string) }
A Mailer sends emails.
func NewMailer ¶
func NewMailer(config MailConfig) Mailer
NewMailer creates Mailer with a configuration.