sensu-cli rubocop ruby Rubygems

A Sensu CLI for getting and deleting information from Sensu.


# Welcome to the sensu-cli.
#          ______
#       .-'      '-.
#     .'     __     '.
#    /      /  \      \
#    ------------------
#            /\
#           '--'
#         SENSU-CLI

A sensu-cli for interacting with the sensu api.

What is Sensu?


  • API interaction with info, health, stashes, events, clients, aggregates and checks
  • Resolve Events
  • Silence clients and checks
  • Get Requests (get clients, stashes, events, etc.)
  • Delete Requests (delete clients, stashes, aggregates and events)

Usage and Configuration

  • Installation: gem install sensu-cli
  • Installation using the embedded Sensu ruby: /opt/sensu/embedded/bin/gem install sensu-cli && ln -s /opt/sensu/embedded/bin/sensu-cli /usr/local/bin/
  • There is one settings file for host, port, ssl, and HTTP timeout that lives in your user directory ~/.sensu/settings.rb. You can alternatively place this in /etc/sensu/sensu-cli/settings.rb.
  • An example config file: host "" port "4567" ssl false api_endpoint "/api" read_timeout 20 open_timeout 20

This format was chosen so you can do some ENV magic via your profile and setting up an alias. For details see the wiki

All Configuration Settings: * host String - Required - Host of the Sensu API * port String/Integer - Required - Port of the Sensu API * ssl Boolean - Optional - Defaults False * api_endpoint String - Optional - Default “ * read_timeout Integer - Optional - Default 15 (seconds) * open_timeout Integer - Optional - Default 5 (seconds) * pretty_colors Boolean - Optional - Default True * proxy_address String - Optional * proxy_port Integer - Optional * user String - Optional - User for the Sensu API * password String - Optional - Password for the Sensu API


Available subcommands: (for details, sensu SUB-COMMAND --help)

** Aggregate Commands **
sensu-cli aggregate list (OPTIONS)
sensu-cli aggregate show CHECK (OPTIONS)
sensu-cli aggregate delete CHECK

** Check Commands **
sensu-cli check list
sensu-cli check show CHECK
sensu-cli check request CHECK SUB1,SUB2

** Client Commands **
sensu-cli client list (OPTIONS)
sensu-cli client show NODE
sensu-cli client delete NODE
sensu-cli client history NODE

** Event Commands **
sensu-cli event list
sensu-cli event show NODE (OPTIONS)
sensu-cli event delete NODE CHECK

** Health Commands **
sensu-cli health (OPTIONS)

** Info Commands **
sensu-cli info

** Silence Commands **
sensu-cli silence NODE (OPTIONS)

** Stash Commands **
sensu-cli stash list (OPTIONS)
sensu-cli stash show STASHPATH
sensu-cli stash delete STASHPATH
sensu-cli stash create PATH

** Resolve Commands **
sensu-cli resolve NODE CHECK

** Socket Commands **
sensu-cli socket create (OPTIONS)
sensu-cli socket raw INPUT

  --version, -v:   Print version and exit
     --help, -h:   Show this message


Filters are strings in ‘key,value’ format.


# show all events with name matching 'foo'
sensu-cli event list -i name,foo

# show all events whose output matches 'foo'
sensu-cli event list -i output,foo


This command can only be used on a host that is running sensu-client. The sensu-client exposes a socket for arbritary check results. For more information you can see the sensu client documentation.


# send a check result to the sensu server
sensu-cli socket create --name "check33" --output "Warn: Something broke really bad" --status 1

# send raw json check result to the sensu server
sensu-cli socket raw '{"name": "check34", "output": "Crit: Something broke even worse than on check33", "status": 2}'

# send raw json check result to the sensu server, faking the source
sensu-cli socket raw '{"name": "snmp", "output": "Crit: SNMP is bad on this switch", "status": 2, "source": "switch01"}'

Advanced Examples

These advanced examples show off the power of being able to use the sensu-cli tool in combination with other command line tools. Some use the jq command to do JSON parsing.

Have a host silence itself

sensu-cli silence `hostname -f` --owner root --reason "This server was just created" --expire 3600

Silence any client that has the word “test” in the name

sensu-cli client list -f json |
  jq -r .[].name |
  grep "test" |
  xargs --verbose --no-run-if-empty -n1 sensu-cli silence

Delete sliences older than 3 days

THRESHOLD=$(date +%s --date="3 days ago")
sensu-cli stash list --format json |
  jq -r "map(select( .[\"content\"][\"timestamp\"] < $THRESHOLD )) | .[].path " |
  xargs --verbose --no-run-if-empty -n1 sensu-cli stash delete

Resolve any checks that haven’t checked in in a month

THRESHOLD=$(date +%s --date="1 month ago")
sensu-cli event list --format json |
  jq --raw-output "map(select( .[\"check\"][\"issued\"] < $THRESHOLD )) | .[] | + \" \" + " |
  xargs --verbose --no-run-if-empty -n2 sensu-cli resolve


Please provide a pull request. I’m an ops guy, not a developer, so if you’re submitting code cleanup, all I ask is that you explain the improvement so I can learn.

License and Author

I’m releasing this under the MIT or Apache 2.0 license. You pick.

Author:: Bryan Brandau [email protected]

Copyright:: 2013, Bryan Brandau

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Related Repositories



A Sensu CLI for getting and deleting information from Sensu. ...



A Sensu CLI for getting and deleting information from Sensu. ...



A Sensu CLI for getting and deleting information from Sensu. ...

Top Contributors

agent462 solarkennedy jinnko somic pauloconnor piavlo FlorinAndrei martj686 kway mivok xrobau snltd dereklwood


-   v0.7.1 zip tar
-   v0.7.0 zip tar
-   v0.6.3 zip tar
-   v0.6.2 zip tar
-   v0.6.1 zip tar
-   v0.6.0 zip tar
-   v0.5.0 zip tar
-   v0.4.0 zip tar
-   v0.3.1 zip tar
-   v0.3.0 zip tar
-   v0.2.5 zip tar
-   v0.2.4 zip tar
-   v0.2.3 zip tar
-   v0.2.2 zip tar
-   v0.2.1 zip tar
-   v0.2.0 zip tar
-   v0.1.1 zip tar
-   v0.1.0 zip tar
-   0.6.2 zip tar