A tool to send command execution results to Sensu

Version on this page:0.2.0
LTS Haskell 11.22:
Stackage Nightly 2018-03-12:
Latest on Hackage:

See all snapshots sensu-run appears in

BSD-3-Clause licensed by Mitsutoshi Aoe
Maintained by [email protected]
This version can be pinned in stack with:sensu-run-0.2.0@sha256:c2f0258e1f34addbb8a2abfd26ee0c8eda894b9d5ec9b0710019f190d24adca5,1324

Module documentation for 0.2.0

There are no documented modules for this package.


Hackage Hackage-Deps Stackage Nightly Build Status Build status

sensu-run runs a command and send its result to Sensu server using the client socket input or via the Sensu API. It is useful to monitor cron jobs for example.


Install stack.

stack install --resolver=nightly sensu-run

will install the sensu-run command in ~/.local/bin.


% sensu-run --help
Usage: sensu-run ([-n|--name NAME] [--source SOURCE] [--ttl SECONDS]
                 [--timeout SECONDS] [--handler HANDLER] ([--port PORT] |
                 [--server URL]) [--dry|--dry-run] [-s|--shell] [COMMAND] |

Available options:
  -h,--help                Show this help text
  -n,--name NAME           The name of the check
  --source SOURCE          The check source, used to create a JIT Sensu client
                           for an external resource
  --ttl SECONDS            The time to live in seconds until check results are
                           considered stale
  --timeout SECONDS        The check executaion duration timeout in seconds
  --handler HANDLER        Sensu event handler(s) to use for events created by
                           the check
  --port PORT              Send results to the local sensu-client listening on
                           the specified port (default: 3030)
  --server URL             Send results to the specified Sensu server
  -s,--shell               Execute the command using the shell

--dry-run option is useful to check the JSON output:

% sensu-run --name check-home-src-size --handler foo --dry-run -- du -s $HOME/src | jq .
  "name": "check-home-src-size",
  "command": "du -s /home/maoe/src",
  "issued": 1496966954,
  "executed": 1496966954,
  "duration": 1.235584,
  "status": 0,
  "output": "44567740\t/home/maoe/src\n",
  "handlers": [

Without the --dry-run option, sensu-run sends the output to localhost:PORT, which is expected to be listened by sensu-client.

sensu-run sets the status field depending on the command exit code and timeout:

command exit code status field
0 0 (OK)
non-zero 2 (CRITICAL)
command timed out 3 (UNKNOWN)

Sensu API

sensu-run supports posting check results via Sensu API as well. Use --server option to specify Sensu server addresses. If multiple servers are specified, sensu-run tries them one by one until it succeeds.

sensu-run --name check-true --handler foo --server --server --dry-run -- du -s $HOME/src


Revision history for sensu-run

0.2.0 – 2017-07-12

  • Relax upper version bound for base
  • Kill child process(es) when timeout occurs – 2017-06-11

  • Relax upper version bound for optparse-applicative
  • Binary releases

0.1.1 – 2017-06-09

  • Add –version option

0.1.0 – 2017-06-07

  • Fix a bug that ignores –handle option by accident
  • Small documentation fixes
  • Enable AppVeyor builds

0.0.0 – 2017-05-16

  • Initial release