am

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2019 License: MIT Imports: 19 Imported by: 0

README

am

Simple alerts and monitoring server.

Server Installation

The server (cmd/amserver) compiles to a dependency-free binary. Associated files will be created or read from the working directory.

Log and Alert Scripts

The server will call two scripts for log or alert events. These scripts need to be executable and exist in the working directory. They need to be called log-action and alert-action. They are called with two arguments:

  1. The name of the source reporting the log or alert.
  2. The associated text.
Running

Run the server with a listen address:

amserver -listen example.com:443

If the port is 443, then the server will serve over https and automatically acquire a certificate from letsencrypt.

Default User Account

By default, an account is created with username root and password root1234.

Source Usage

Sources can perform three actions: ping, log, or alert. Actions are sent as standard HTTP POST requests to the URL https://example.com/report/<APIKey>.

For example:

curl \
    --data-urlencode "action=alert" \
    --data-urlencode "text=An alert!" \
    https://example.com/report/$API_KEY

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main

func Main()

Types

type Entry

type Entry struct {
	LogID    int64
	SourceID string
	TS       time.Time
	Alert    bool
	Text     string
}

type EntryListRow

type EntryListRow struct {
	LogID      int64
	SourceID   string
	SourceName string
	TS         time.Time
	Alert      bool
	Text       string
}

type LogListArgs

type LogListArgs struct {
	BeforeID int64
	Alert    *bool
	SourceID string
	Limit    int64
}

type Source

type Source struct {
	SourceID     string
	Name         string
	APIKey       string
	Description  string
	LastSeenAt   time.Time
	AlertTimeout int64     // In seconds.
	AlertedAt    time.Time // Timeout alert time.
}

func (Source) RequiresAlertForTimeout

func (s Source) RequiresAlertForTimeout() bool

func (Source) TimedOut

func (s Source) TimedOut() bool

type User

type User struct {
	Username string
	Admin    bool
}

Directories

Path Synopsis
cmd
am

Jump to

Keyboard shortcuts

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