diff --git a/README.md b/README.md index 4d3fd88..5206868 100644 --- a/README.md +++ b/README.md @@ -1 +1,45 @@ # 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. +1. 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 of 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/`. + +For example: + +```bash +curl \ + --data-urlencode "action=alert" \ + --data-urlencode "text=An alert!" \ + https://example.com/report/$API_KEY +``` \ No newline at end of file diff --git a/db.go b/db.go index 99e7ef4..9d250bf 100644 --- a/db.go +++ b/db.go @@ -36,7 +36,7 @@ func newDB(dbPath string) (*dbal, error) { _ = db.UserInsert(User{ Username: `root`, Admin: true, - }, `rootroot`) + }, `root1234`) return db, nil } diff --git a/templates/sources.html b/templates/sources.html index a458125..143a94d 100644 --- a/templates/sources.html +++ b/templates/sources.html @@ -93,9 +93,6 @@
Alert Timeout (sec)
{{.AlertTimeout}}
- -
Alerted At
-
{{.AlertedAt.Format "2006-01-02 15:04"}}
@@ -128,7 +125,7 @@
  • - +
  • diff --git a/tmpl_gen.go b/tmpl_gen.go index c87b3ea..8eec01d 100644 --- a/tmpl_gen.go +++ b/tmpl_gen.go @@ -189,9 +189,6 @@ var tmpls = `
    Alert Timeout (sec)
    {{.AlertTimeout}}
    - -
    Alerted At
    -
    {{.AlertedAt.Format "2006-01-02 15:04"}}
    @@ -224,7 +221,7 @@ var tmpls = `
  • - +
  • diff --git a/user-handlers.go b/user-handlers.go index 192d8e6..a444e84 100644 --- a/user-handlers.go +++ b/user-handlers.go @@ -110,7 +110,7 @@ func handle_admin(path string, h func(w http.ResponseWriter, r *http.Request)) { // ---------------------------------------------------------------------------- func handleRoot(w http.ResponseWriter, r *http.Request) { - respondRedirect(w, r, "/user/list") + respondRedirect(w, r, "/log/list") } // ----------------------------------------------------------------------------