Giter Club home page Giter Club logo

task-mon's Introduction

Task Monitoring with Healthchecks.io

github crates.io build status issues license

task-mon is a small binary for notifying Healthchecks.io when a command runs.

This serves a similar purpose to the curl-based patterns described in the Healthchecks documentation but provides more flexibility and ergonomics. Especially for shell scripts and cron jobs, delegating health management to a separate binary allows you to focus on the task at hand.

It supports Healthchecks' advanced optional features such as reporting failures, attaching logs, and monitoring execution time.

Usage

To execute a task and ping Healthchecks.io when it completes simply invoke task-mon with the check's UUID and the command to run:

$ task-mon --uuid 1234-abcd -- some_command --to --monitor
$ task-mon --ping-key abcd1234 --slug foo -- some_command --to --monitor
$ crontab -e
# m h dom mon dow command
  8 6 * * * /usr/local/cargo/bin/task-mon --uuid 1234-abcd -- some_command --to --monitor

task-mon will run the command and ping Healthchecks.io when it completes, reporting the exit status and the last 10K of output from the process.

Customization

$ task-mon --help
task-mon 0.3.0
CLI to execute commands and log results to healthchecks.io

USAGE:
    task-mon [OPTIONS] <--uuid <UUID>|--slug <SLUG>> [--] <COMMAND>...

ARGS:
    <COMMAND>...    The command to run

OPTIONS:
    -k, --uuid <UUID>                Check's UUID to ping
    -s, --slug <SLUG>                Check's slug name to ping, requires also specifying --ping-key
        --ping-key <PING_KEY>        Check's project ping key, required when using --slug [env:
                                     HEALTHCHECKS_PING_KEY=]
    -t, --time                       Ping when the program starts as well as completes
        --head                       POST the first 10k bytes instead of the last
        --ping-only                  Don't POST any output from the command
        --log                        Log the invocation without signalling success or failure; does
                                     not update the check's status
        --detailed                   Include execution details in the information POST-ed (by
                                     default just sends stdout/err
        --env                        Also POSTs the process environment; requires --detailed
        --verbose                    Write debugging details to stderr
        --user-agent <USER_AGENT>    Customize the user-agent string sent to the Healthchecks.io
                                     server
        --base-url <BASE_URL>        Base URL of the Healthchecks.io server to ping [env:
                                     HEALTHCHECKS_BASE_URL=] [default: https://hc-ping.com]
    -h, --help                       Print help information
    -V, --version                    Print version information

Related projects

There are of course a number of similar projects out there, but I was bored and didn't want to use any of them...

task-mon's People

Contributors

dimo414 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

task-mon's Issues

Send start pings by default

In #3 @bdd calls out several benefits of sending start pings by default (i.e. make --start default to true). Notably it would allow task-mon to respect the ping body limit without a local cache and would enable using run ids.

Support "log" signals

v2.3 added support for a /log endpoint that doesn't update the check's status. A --log flag should be sufficient to support this.

Detect and cache the Ping-Body-Limit response header and support non-default limit

As of v2.1 responses include a Ping-Body-Limit header indicating how large the log payload can be. We could cache this value somewhere like /tmp/.healthchecks-<base_url_slug>.Ping-Body-Limit to be used in subsequent invocations.

Also, the existing hard-coded value doesn't support other installs with different limits, so a --body_limit flag should be added so callers can proactively specify the limit they'd like to use.

Support URL slugs

URL slugs (added in healthchecks/healthchecks#491) offer an alternative to per-check UUIDs.

I think you could get away with passing <ping-key>/<slug> as the --uuid, but it would very much be a hacky workaround. In particular, it would be nice to accept the <ping-key> as an environment variable as well as a flag, given @cuu508's thoughts on treating the ping key as a secret.

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.