Giter VIP home page Giter VIP logo

sensu-cli's People

Contributors

agent462 avatar florinandrei avatar jinnko avatar kway avatar martj686 avatar mchlumsky avatar mivok avatar pauloconnor avatar piavlo avatar solarkennedy avatar spr-mweber3 avatar tarcinil avatar xrobau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar

sensu-cli's Issues

sensu client socket

from @joemiller:
what do you think about extending it beyond just the rest api and providing interfaces to other things like the sensu client socket? eg: sensu event create NAME STATUS OUTPUT (options) would be equiv to: echo '{"name": "some_check", "status": 2, "output": "check output"}' | nc 127.0.0.1 3030

Running sensu-cli through a pipe is sometimes noisey

When I pipe sensu-cli through something that kills the sensu-cli proc mid-stream, it gets a broken-pipe exception:

$ sensu-cli client list -f json | grep -q something
/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-cli-0.6.1/lib/sensu-cli/pretty.rb:39:in `write': Broken pipe - <STDOUT> (Errno::EPIPE)
    from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-cli-0.6.1/lib/sensu-cli/pretty.rb:39:in `puts'
    from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-cli-0.6.1/lib/sensu-cli/pretty.rb:39:in `puts'
    from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-cli-0.6.1/lib/sensu-cli/pretty.rb:39:in `json'
    from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-cli-0.6.1/lib/sensu-cli/base.rb:59:in `make_call'
    from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-cli-0.6.1/lib/sensu-cli/base.rb:7:in `setup'
    from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-cli-0.6.1/bin/sensu-cli:6:in `<top (required)>'
    from /usr/bin/sensu-cli:23:in `load'
    from /usr/bin/sensu-cli:23:in `<main>'

But only if I have grep -q?

Can you try to repo this on a setup you have to confirm it is not just me?

Bash completion help?

I would like to add bash completion to your tool to make it easier to tab out. (I'm so lazy)

Would you accept such a contribution? If so, I'm not sure where it would fit in a gem. contrib folder?

unsilence command

There isn't a specific unsilence command. I'm guessing this could be done with a stash delete of silence/{client,check}, based on a cursory look at the code.

But it would be cool if that were rolled into a command to unsilence a client or check, since the end user isn't necessarily going to know the stash path (and I haven't tested that the above works).

commands

Some thoughts for commands:

sensu client list
sensu client show (client)
sensu client silence (client)
sensu client delete (client)

sensu check list
sensu check silence (check)

sensu event list ("sensu events/sensu status"?)
sensu event show (event)

Need more examples to howto complete the settings.rb

The documentation about the setting.rb is too simples. For example:

  • The host variable: Does not explain witch host. It could be the local, the rabbbitmq, or the redis host. Also, i'm getting the message "An HTTP error occurred. Check your settings. Connection refused - connect(2)" and cannot find doc that explain the error.
  • The user variable: Does not explain witch user it need to connect to.

silenced does not support --format

The documentation still advocates using the old stash-based approach to deleting silencers older than N number of hours. I'd like to use the new silenced subcommand but notice that --format is not supported. This makes me sad.

Useful helpers for sensu-cli

sensu-cli makes interacting with the Sensu API simple and fairly painless, unless you want to apply some action to multiple results. I've got a script I threw together that I've been using to help automate some of the actions surrounding this. I figure they may be of use to others.

https://gist.github.com/yacn/6453047

It's pretty hacky and could definitely be cleaned up and refined, but I figured I may as well get it out there so others could benefit.

gem problem. sensu-cli not found

Installed sensu-cli, and no executable is being found:

$ sudo gem install sensu-cli
Successfully installed rainbow-1.1.4
Successfully installed mixlib-config-1.1.2
Successfully installed sensu-cli-0.0.10
3 gems installed
Installing ri documentation for rainbow-1.1.4...
Installing ri documentation for mixlib-config-1.1.2...
Installing ri documentation for sensu-cli-0.0.10...
Installing RDoc documentation for rainbow-1.1.4...
Installing RDoc documentation for mixlib-config-1.1.2...
Installing RDoc documentation for sensu-cli-0.0.10...
$ sensu-cli
-bash: sensu-cli: command not found

Add datacentre field to stashes

Uchiwa has the concept of datacentre, it would be great if the sensu-cli was able to set this field during stash creation. The use case I've currently got: creating silence stashes for EC2 instances that are coming up during instance creation, in a different datacentre to the Jenkins master that I'm creating the silence stashes from.

event list erubis error

Using version 0.6.3 of sensu-cli and running 'sensu event list' shows an erubis error message. Other sensu-cli commands seem to work fine.

~  ᐅ cat ~/.sensu/settings.rb
environment = ENV['SENSU_ENV']
port "4567"
ssl  false
host case environment
       when 'dev-ue1'
         'sensu-ue1.gin-dev.com'
       when 'dev-uw1'
         'sensu-uw1.gin-dev.com'
       when 'prod-ue1'
         'sensu-ue1.s-gin.com'
       when 'prod-uw1'
         'sensu-uw1.s-gin.com'
       else
         puts "#{environment} is not a valid environment"
         exit 1
       end

~  ᐅ SENSU_ENV=prod-ue1 sensu event list
(erubis:2:in `result': undefined local variable or method `id' for #<Erubis::Eruby:0x007ffd312cbbf0> (NameError)
    from /Users/j.alberts/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/erubis-2.7.0/lib/erubis/evaluator.rb:65:in `eval'
    from /Users/j.alberts/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/erubis-2.7.0/lib/erubis/evaluator.rb:65:in `result'
    from /Users/j.alberts/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/sensu-cli-0.6.3/lib/sensu-cli/pretty.rb:16:in `block in print'
    from /Users/j.alberts/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/sensu-cli-0.6.3/lib/sensu-cli/pretty.rb:15:in `each'
    from /Users/j.alberts/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/sensu-cli-0.6.3/lib/sensu-cli/pretty.rb:15:in `print'
    from /Users/j.alberts/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/sensu-cli-0.6.3/lib/sensu-cli/base.rb:61:in `make_call'
    from /Users/j.alberts/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/sensu-cli-0.6.3/lib/sensu-cli/base.rb:7:in `setup'
    from /Users/j.alberts/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/sensu-cli-0.6.3/bin/sensu:6:in `<top (required)>'
    from /Users/j.alberts/.rbenv/versions/2.0.0-p576/bin/sensu:23:in `load'
    from /Users/j.alberts/.rbenv/versions/2.0.0-p576/bin/sensu:23:in `<main>'
~  ᐅ SENSU_ENV=prod-ue1 sensu info
sensu:  {"version"=>"0.12.6"}
rabbitmq:  {"keepalives"=>{"messages"=>0, "consumers"=>4}, "results"=>{"messages"=>84, "consumers"=>4}, "connected"=>true}
redis:  {"connected"=>true}
3 total items
~  ᐅ gem list | grep erubis
erubis (2.7.0)
~  ᐅ SENSU_ENV=prod-ue1 sensu -v
sensu-cli version: 0.6.3

/etc/sensu/sensu-cli config file does not seem to be used by the gem

Ubuntu 14.04.1
Sensu 0.14 installed from the omnibus packages on the apt repository
sensu-cli 0.6.3
I'm using the Ruby and Gem embedded with Sensu:

# cat /etc/profile.d/sensu.sh 
export PATH=/opt/sensu/embedded/bin:/etc/sensu/plugins:$PATH
# which gem
/opt/sensu/embedded/bin/gem

I did 'gem install sensu-cli' and ran it once.

# sensu-cli info
We created the configuration file for you at /root/.sensu/settings.rb.  You can also place this in /etc/sensu/sensu-cli. Edit the settings as needed.
# sensu-cli info
The request requires user authentication.

Okay, I put the user and password there and it worked fine.

# sensu-cli info
sensu:  {"version"=>"0.14.0"}
transport:  {"keepalives"=>{"messages"=>0, "consumers"=>1}, "results"=>{"messages"=>2, "consumers"=>1}, "connected"=>true}
redis:  {"connected"=>true}
3 total items

Then I moved the config file into /etc/sensu, based on the warning during the first run, but the cli doesn't seem to use the system-level config file:

# cat .sensu/settings.rb > /etc/sensu/sensu-cli
# rm -rf .sensu/
# sensu-cli info
We created the configuration file for you at /root/.sensu/settings.rb.  You can also place this in /etc/sensu/sensu-cli. Edit the settings as needed.

Update client data (for JIT Clients)

I have a bunch of checks that use 'source' for devices on my network that can't run a sensu client (SANs, switches, firewalls, etc). I'd like to be able to use sensu-cli to amend the address and subscriptions for these clients.

please update the project rubygems

asking nicely rather than creating a pull request (let me know whether you prefer that i will submit a pull request)...

please update the rubygems in the project.

Bundler could not find compatible versions for gem "rainbow":
  In Gemfile:
    rubocop (= 0.50.0) was resolved to 0.50.0, which depends on
      rainbow (< 3.0, >= 2.2.2)

    sensu-cli (~> 0) was resolved to 0.0.7, which depends on
      rainbow (= 1.1.4)

Sensu event list

It would be nice if the sensu event list would output the subscription information.

Add functionality to disable coloured output

The coloured output is really helpful, but in some situations it makes it difficult to integrate the tool in scripts.. for example we run this during instance startup in AWS:

sensu-cli client history $(facter fqdn) | grep last_status | \
  sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" | awk '{print $2}' | egrep '(1|2|3)'

That nasty sed is there to parse the coloured output ASCII codes, otherwise we can't properly grep for last_status codes

Is there a simpler way to do this within the shell output?
Alternatively, would you consider adding an option which allows --nocolour ?

Deprecation Warning of gem trollop

After installing and running sensu-cli it states a deprecation Warning:

root@sensu02:/etc/sensu/sensu-cli# /opt/sensu/embedded/bin/gem install sensu-cli
Fetching: sensu-cli-0.10.0.gem (100%)
Successfully installed sensu-cli-0.10.0
Parsing documentation for sensu-cli-0.10.0
Installing ri documentation for sensu-cli-0.10.0
Done installing documentation for sensu-cli after 0 seconds
1 gem installed

root@sensu02:/etc/sensu/sensu-cli# sensu-cli 
[DEPRECATION] This gem has been renamed to optimist and will no longer be supported. Please switch to optimist as soon as possible.
#
# Welcome to the sensu-cli.
#          ______
#       .-'      '-.
#     .'     __     '.
#    /      /  \      \
#    ------------------
#            /\
#           '--'
#         SENSU-CLI
#

Will you switch to trollop in the near future or do we have to live with this Deprecation warning? :)

event.erb not found

sensu-cli requires that the CWD be in the gem location in order to find event.erb:

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/sensu-cli-0.6.1/lib/sensu-cli/pretty.rb:13:in `read': No such file or directory - lib/sensu-cli/templates/event.erb (Errno::ENOENT)
    from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/sensu-cli-0.6.1/lib/sensu-cli/pretty.rb:13:in `print'
    from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/sensu-cli-0.6.1/lib/sensu-cli/base.rb:61:in `make_call'
    from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/sensu-cli-0.6.1/lib/sensu-cli/base.rb:7:in `setup'
    from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/sensu-cli-0.6.1/bin/sensu-cli:6:in `<top (required)>'
    from /opt/chef/embedded/bin/sensu-cli:23:in `load'
    from /opt/chef/embedded/bin/sensu-cli:23:in `<main>'

Question - How to connect to the sensu api using the sensu-cli?

sensu-cli check list
An HTTP error occurred. Check your settings. Connection refused - connect(2)

/home/user/.sensu/settings.rb.

host "company.sheva.io"
port "4567"
ssl false
read_timeout 20
open_timeout 20
user ""
password ""

uchiwa.json contains an empty pass and username as well

Command sensu stash list returns an error

I'm using sensu-cli version 0.7.1 and ruby version 2.1.5

> sensu-cli stash list
/Users/therobot/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/json-1.8.3/lib/json/common.rb:155:in `parse': 757: unexpected token at 'null (JSON::ParserError)
'
    from /Users/therobot/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/json-1.8.3/lib/json/common.rb:155:in `parse'
    from /Users/therobot/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/sensu-cli-0.7.1/lib/sensu-cli/api.rb:39:in `response'
    from /Users/therobot/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/sensu-cli-0.7.1/lib/sensu-cli/base.rb:60:in `make_call'
    from /Users/therobot/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/sensu-cli-0.7.1/lib/sensu-cli/base.rb:11:in `setup'
    from /Users/therobot/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/sensu-cli-0.7.1/bin/sensu:6:in `<top (required)>'
    from /Users/therobot/.rbenv/versions/2.1.5/bin/sensu:23:in `load'
    from /Users/therobot/.rbenv/versions/2.1.5/bin/sensu:23:in `<main>'

Connect to message broker instead of api

The sensu-client connects to the RabbitMQ server instead of the API directly. Would it be possible to let the sensu-cli connect to the messagebroker instead of the api directly?

Displaying custom event field in output

Hi,

I have some custom values in my event-data on which i would like to do some filtering. Looking at the code, i figured that i would need to add my custom field to templates/event.erb file for it to display in the output.
Shouldn't it by default display all the fields which are part of the event ? or maybe its possible to print in the output and i'm missing something.

Thanks

Release 0.7.1

Can we get a new version of the gem released with the latest patch please? It would really help unblock me.

Failure when no proxy defined

Config is:

host '[SNIP]'
port '4567'

I enabled http debugging, stack traces, and output of 'opts'. result is:

{:path=>"/clients?limit=&offset=",
 :method=>"Get",
 :payload=>false,
 :host=>"[SNIP]",
 :port=>"4567",
 :ssl=>false,
 :user=>nil,
 :read_timeout=>15,
 :open_timeout=>5,
 :password=>nil,
 :proxy_address=>:ENV,
 :proxy_port=>nil}
opening connection to ENV...
An HTTP error occurred.  Check your settings. can't convert Symbol into String ["/opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:763:in `initialize'", "/opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:763:in `open'", "/opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:763:in `block in connect'", "/opt/chef/embedded/lib/ruby/1.9.1/timeout.rb:69:in `timeout'", "/opt/chef/embedded/lib/ruby/1.9.1/timeout.rb:100:in `timeout'", "/opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:763:in `connect'", "/opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:756:in `do_start'", "/opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:745:in `start'", "/opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:1285:in `request'", "/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/sensu-cli-0.6.0/lib/sensu-cli/api.rb:31:in `request'", "/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/sensu-cli-0.6.0/lib/sensu-cli/base.rb:47:in `make_call'", "/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/sensu-cli-0.6.0/lib/sensu-cli/base.rb:7:in `setup'", "/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/sensu-cli-0.6.0/bin/sensu-cli:6:in `<top (required)>'", "/opt/chef/embedded/bin/sensu-cli:23:in `load'", "/opt/chef/embedded/bin/sensu-cli:23:in `<main>'"]

Note the opening connection to ENV....

It looks like the issue is in lib/sensu-cli/base.rb where it defaults proxy_address to :ENV. Most places where environmental variables are used for proxies will specify the address and port together, so I don't think it makes sense in this structure to pull it from ENV.

Switching it to default to nil resolves the issue.

Feature: Delete check results

Earlier today I tried the sensu-cli and used:
sensu-cli event delete NODE CHECK

I initially thought that it would remove the check from the list of checks known to a certain client, but looks like I was wrong. The check was still shown on e.g. the list of checks on the client - but now without the results.

What I was looking for, was to clear any check results etc. for a certain check on a specific client, as it was removed from my configuration due to a new check with a new name.

To clear / remove trace of the check on the device, I ended up doing a curl directly to the Sensu API based on this: https://sensuapp.org/docs/0.26/api/results-api.html#resultsclientcheck-delete

Any chance this type of action could be added to sensu-cli?

filter results

The team wants the ability to filter results of at least clients by some given parameter. This would be client side filtering today. Potential pull request to sensu api?

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.