From 2ebd582fc7552dcb4377aaf50aaa2a48bf87671a Mon Sep 17 00:00:00 2001 From: Marcus Wichelmann Date: Sat, 4 Jun 2022 16:14:41 +0200 Subject: [PATCH] Added README and Dockerfile --- .gitignore | 3 ++- Dockerfile | 11 +++++++++++ README.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ config.sample.yml | 14 -------------- main.go | 2 +- 5 files changed, 59 insertions(+), 16 deletions(-) create mode 100644 Dockerfile create mode 100644 README.md delete mode 100644 config.sample.yml diff --git a/.gitignore b/.gitignore index 5f000e3..0182dd0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /.idea/ -/config.yml \ No newline at end of file +/config.yml +/notdeadyet diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6ef69c6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM golang:1.18-alpine AS base +WORKDIR /app + +FROM base AS build +COPY . . +RUN go build -v -o notdeadyet + +FROM base AS final +COPY --from=build /app/notdeadyet . +EXPOSE 80 +CMD [ "/app/notdeadyet", "--config-file=/config/config.yml" ] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..977b23c --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +# notdeadyet + +This is a simple dead man's switch monitoring daemon written in Go. It watches, if an API endpoint is polled at a regular, configurable interval, and triggers an alarm otherwise. + +For now, only **Pushover** receivers are supported, but more can be added easily. + +## Usage + +### Configuration file + +Take a look at the following sample to write your own `config.yml`: + +```yaml +listen: ':80' # Optional +apps: + - name: Test App + token: djms90x1hqflyggx # Generate a random token yourself + timeout: 1h + repeat_interval: 1h + notify: + - Super Administrator +receivers: + pushover: + - name: Super Administrator + user_key: ... + token: ... + priority: 0 +``` + +### Run + +You can then run the daemon with +``` +./notdeadyet --config-file=config.yml +``` + +or use the provided Docker images and mount your config into `/config/config.yml`. + +### Making requests + +You should configure your monitored applications to make regular `GET` or `POST` requests against `http://SERVER/im-alive/TOKEN` to tell `notdeadyet` that the app is still alive. + +If the monitored app stops making these requests for the duration configured in `timeout`, then the selected receivers will receive a notification. When the app starts making requests again, a notification is sent, that the app is back. + +**Have fun!** \ No newline at end of file diff --git a/config.sample.yml b/config.sample.yml deleted file mode 100644 index 74abf17..0000000 --- a/config.sample.yml +++ /dev/null @@ -1,14 +0,0 @@ -listen: ':8080' -apps: - - name: Test App - token: djms90x1hqflyggx - timeout: 1h - repeat_interval: 1h - notify: - - Super Administrator -receivers: - pushover: - - name: Super Administrator - user_key: ... - token: ... - priority: 0 \ No newline at end of file diff --git a/main.go b/main.go index 369b3ae..2513cfc 100644 --- a/main.go +++ b/main.go @@ -142,7 +142,7 @@ func initWatchers() { } func handleIndex(c *gin.Context) { - c.String(http.StatusOK, "Not Dead Yet? - The dead man switch monitoring daemon.") + c.String(http.StatusOK, "Not Dead Yet? - The dead man's switch monitoring daemon.") } func handleLiveSign(c *gin.Context) {