Giter Site home page Giter Site logo

flamingzombies's Introduction

Flaming Zombies

A simple yet extendable, lightweight monitoring daemon.

  • Made for the command line.
  • Configured with flat files.
  • Complete documentation in man pages.
  • Few dependencies.
  • Stateless¹.
  • Easily extended, and customised.
  • Liberal 2-clause BSD license.
1. State of course exists, but it isn't persisted between restarts.

THIS IS STILL A WORK IN PROGRESS... but it's ready to test.


Flaming Zombies ties together three components with three distinct responsibilities; tasks, notifiers and gates.

  • tasks check whether a condition is true or false, like if a host responds to pings?
  • notifiers raise alerts.
  • gates control when a notifier may execute.
sequenceDiagram
    task->>+notifier: new measurement
    notifier->>gate: are you open?
    gate->>+notifier: no
    task->>+notifier: new measurement
    notifier->>gate: are you open?
    gate->>+notifier: yes
    notifier->>Human: notification sent

You're expected to have many tasks. Each task can have one or more notifiers. Each notifier can have one or more gates.

And that is the basis of Flaming Zombies.

Documentation

The complete documentation is available in the man pages. You can read them in your shell before they're installed using using the command:

curl https://raw.githubusercontent.com/jonhiggs/flamingzombies/main/man/man1/fz.1 | man /dev/stdin

Building

Before you can build fz and fzctl, you'll need to have Go installed on your system.

To build, run:

go build ./cmd/fzctl/fzctl.go
go build ./cmd/fz/fz.go

That will produce the binaries for your system. The plugins are at ./libexec and the man pages are at ./man. Adapting the OpenBSD installation instructions should get you a long way to installing it on most UNIX-like system. You may find an init script for your operating system at ./scripts. If you end up writing one, I would appreciate it if you could share it back.

Installation

Installation is intended to be very simple. Eventually, I'd like to provide installation packages, but until then a manual process will need to suffice.

OpenBSD

The below sequence of commands will install the daemon on OpenBSD:

## fz
wget https://github.com/jonhiggs/flamingzombies/releases/download/${VERSION}/fz_openbsd_${ARCH} \
    -O /usr/local/bin/fz

chown root:wheel /usr/local/bin/fz
chmod 755 /usr/local/bin/fz

## fzctl
wget https://github.com/jonhiggs/flamingzombies/releases/download/${VERSION}/fzctl_openbsd_${ARCH} \
    -O /usr/local/bin/fzctl

chown root:wheel /usr/local/bin/fzctl
chmod 755 /usr/local/bin/fzctl

## rc script
wget https://raw.githubusercontent.com/jonhiggs/flamingzombies/main/scripts/openbsd_rc \
    -O /etc/rc.d/flamingzombies

chown root:wheel /etc/rc.d/flamingzombies
chmod 755 /etc/rc.d/flamingzombies

## plugins
wget https://github.com/jonhiggs/flamingzombies/releases/download/${VERSION}/plugins.tar.gz \
    -O /tmp/plugins.tar.gz

tar -C /usr/local/libexec -zxvf /tmp/plugins.tar.gz
rm /tmp/plugins.tar.gz

## man pages
for m in man1/fz.1 man1/fzctl.1 man5/flamingzombies.toml.5 man7/fz-gates.7 man7/fz-notifiers.7 man7/fz-tasks.7; do
    wget https://raw.githubusercontent.com/jonhiggs/flamingzombies/main/man/$f \
        -O /usr/local/man/$f
done

## config
# create a configuration at /etc/flamingzombies.toml
# see the flamingzombies.toml(5) man page.

## enable the daemon
rcctl enable flamingzombies
rcctl set flamingzombies logger daemon.info

Alpine Linux

The below sequence of commands will install the daemon on Alpine Linux:

## fz
wget https://github.com/jonhiggs/flamingzombies/releases/download/${VERSION}/fz_linux_${ARCH} \
    -O /usr/local/bin/fz

chown root:root /usr/local/bin/fz
chmod 755 /usr/local/bin/fz

## fzctl
wget https://github.com/jonhiggs/flamingzombies/releases/download/${VERSION}/fzctl_linux_${ARCH} \
    -O /usr/local/bin/fzctl

chown root:root /usr/local/bin/fzctl
chmod 755 /usr/local/bin/fzctl

## rc script
wget https://raw.githubusercontent.com/jonhiggs/flamingzombies/main/scripts/openrc \
    -O /etc/init.d/flamingzombies

chown root:root /etc/init.d/flamingzombies
chmod 755 /etc/init.d/flamingzombies

## plugins
wget https://github.com/jonhiggs/flamingzombies/releases/download/${VERSION}/plugins.tar.gz \
    -O /tmp/plugins.tar.gz

mkdir -p /usr/local/libexec
tar -C /usr/local/libexec -zxvf /tmp/plugins.tar.gz
rm /tmp/plugins.tar.gz

## man pages
for i in $(seq 1 7); do
    mkdir -p "/usr/local/man/man$i"
done

for m in man1/fz.1 man1/fzctl.1 man5/flamingzombies.toml.5 man7/fz-gates.7 man7/fz-notifiers.7 man7/fz-tasks.7; do
    wget https://raw.githubusercontent.com/jonhiggs/flamingzombies/main/man/$f \
        -O /usr/local/man/$f
done

## config
# create a configuration at /etc/flamingzombies.toml
# see the flamingzombies.toml(5) man page.

## enable the daemon
rc-update add flamingzombies
service flamingzombies start

flamingzombies's People

Contributors

jonhiggs avatar

Watchers

 avatar

flamingzombies's Issues

Defer notifications

Add support to defer a notification allowing it some time to auto-resolve before notifying.

task to check that directory contains new files

From a directory of backup files, make sure that the newest one is at newer than n seconds.

If the directory doesn't exist, return 3.
If the glob doesn't match anything, return 1.
If none of the matching files are new enough, return 1.

fz task plugin

Add a task plugin to detect if an fz daemon has experienced any errors for any of its tasks.

Add grace to the timeouts

Adding grace time to the timeouts makes managing the timeout in the tasks easier; you don't have to deduct any time from ${TIMEOUT} to avoid losing to the fz's context deadline.

don't segfault if a gate's script doesn't exist.

time="2024-05-01T13:40:44+10:00" level=info msg="executing task" file=lib/fz/task.go task_hash=2103319012 task_name=flappy
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x52c115]

goroutine 6 [running]:
github.com/jonhiggs/flamingzombies/lib/fz.Gate.IsOpen({{0xc000014520, 0xc}, {0xc00001c1a0, 0x1a}, {0x0, 0x0, 0x0}}, 0xc0000c6000)
        /home/jon/src/flamingzombies/lib/fz/gate.go:67 +0xa95
github.com/jonhiggs/flamingzombies/lib/fz.ProcessNotifications.func1()
        /home/jon/src/flamingzombies/lib/fz/notification.go:26 +0x10c7
created by github.com/jonhiggs/flamingzombies/lib/fz.ProcessNotifications in goroutine 1
        /home/jon/src/flamingzombies/lib/fz/notification.go:20 +0x1a
exit status 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.