Giter VIP home page Giter VIP logo

sensu-plugins-http's People

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sensu-plugins-http's Issues

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::GemNotFound with message: Could not find gem 'kitchen-localhost (<= 0.3.0, >= 0.3)' in any of the gem sources listed in your Gemfile.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

You can mention @dependabot in the comments below to contact the Dependabot team.

Follow redirects option for check-http.rb

This is a feature request:

There are occasions where we need to monitor a HTTP endpoint that has a redirect. Currently, we set up two checks, one that confirms the first hop is a redirect (setting the redirect switch to return a OK status code), and one that confirms the second hop is 200 OK.

It would be beneficial to have this occur in just one check, where the option to follow the redirect(s) is included in the check-http.rb script. This way we can also use the additional functionality of checking output, etc in the output of the final hop.

It appears to me that there is already code in the check-head-redirect.rb script that would apply.

Check failed to run: execution expired

We still see this issue occasionally even after upgrading to sensu 1.0, sensu-plugin-1.4.5 with http-2.5.0

Check failed to run: execution expired, [
 \"/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-1.4.5/lib/sensu-plugin/check/cli.rb:23:in `write'\", 
 \"/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-1.4.5/lib/sensu-plugin/check/cli.rb:23:in `puts'\", 
 \"/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-1.4.5/lib/sensu-plugin/check/cli.rb:23:in `puts'\", 
 \"/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-1.4.5/lib/sensu-plugin/check/cli.rb:23:in `output'\", 
 \"/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-1.4.5/lib/sensu-plugin/cli.rb:29:in `block (2 levels) in <class:CLI>'\", 
 \"/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-http-2.5.0/bin/check-http.rb:242:in `rescue in run'\", 
 \"/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-http-2.5.0/bin/check-http.rb:237:in `run'\", 
 \"/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-1.4.5/lib/sensu-plugin/cli.rb:58:in `block in <class:CLI>'\"]
 \n","status":2

This check took 15 seconds to run. Expected to have taken less than 1

command: "check-http.rb -u https://domain/path --response-code 302 -r"

Usage

Please provide an Usage examples

support -f, --follow

Hello,

Please add support for following redirects, similar to nagios's check_http plugin.

Error parsing resource: mapping values are not allowed in this context

Perhaps a sensu-go bug but passing a Host header in v5.19.1

type: CheckConfig
api_version: core/v2
metadata:
  name: check_http_unicorn
  namespace: default
spec:
  command: check-http.rb --hostname 10.2.12.116 --port 8080 --header 'Host: mydomain.dev' --request-uri / -r true

results in

Error: in /etc/sensu/conf.d/checks: error parsing resources: yaml: line 7: mapping values are not allowed in this context

Removing --header 'Host: mydomain.dev allows the check config to upload but without the header the check will fail.

Removing the assignment : prevents key value mapping of custom headers.

CheckHttp CRITICAL: Request error: undefined method `strip' for nil:NilClass

Check failed to run: execution expired

Hi guys,

I recently updated ruby to 2.3.0 and found that sensu-plugin loader is reporting run failures when http plugin timeouts. Below is message included with sensu alert email.

Check failed to run: execution expired, ["/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.2.0/lib/sensu-plugin/check/cli.rb:23:in `write'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.2.0/lib/sensu-plugin/check/cli.rb:23:in `puts'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.2.0/lib/sensu-plugin/check/cli.rb:23:in `puts'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.2.0/lib/sensu-plugin/check/cli.rb:23:in `output'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.2.0/lib/sensu-plugin/cli.rb:29:in `block (2 levels) in <class:CLI>'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-http-0.4.0/bin/check-http.rb:209:in `rescue in run'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-http-0.4.0/bin/check-http.rb:204:in `run'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.2.0/lib/sensu-plugin/cli.rb:56:in `block in <class:CLI>'"]

Admin GUI: http://manager.local:8080
Host: manager
Timestamp: 2016-04-28 22:08:40 +1000
Address:  172.17.11.73
Check Name:  check_http_chef
Command:  /opt/sensu/embedded/bin/check-http.rb -u https://chef.local -t 10 -k
Status:  CRITICAL
Occurrences:  3

root@manager:~# /opt/sensu/embedded/bin/gem --version 2.6.3

root@manager:~# /opt/sensu/embedded/bin/ruby --version ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]

When I am running plugin directly from command line it returns prroper status.

root@manager:~# /opt/sensu/embedded/bin/check-http.rb -u https://chef.local -t 10 -k
CheckHttp CRITICAL: Request timed out

Has anyone encountered this issue ?

Thanks.

metrics-http-json.rb HTTP basic auth

Extracting metrics from an api endpoint that requires authentication fails in a strange way.
When the --url parameter is formatted like "user:pass@localhost:8080" the check fails with this output:

Check failed to run: Failed to open TCP connection to http:80 (getaddrinfo: Name or service not known), ["/usr/lib/ruby/2.3.0/net/http.rb:882:in `rescue in block in connect'", "/usr/lib/ruby/2.3.0/net/http.rb:879:in `block in connect'", "/usr/lib/ruby/2.3.0/timeout.rb:91:in `block in timeout'", "/usr/lib/ruby/2.3.0/timeout.rb:101:in `timeout'", "/usr/lib/ruby/2.3.0/net/http.rb:878:in `connect'", "/usr/lib/ruby/2.3.0/net/http.rb:863:in `do_start'", "/usr/lib/ruby/2.3.0/net/http.rb:852:in `start'", "/var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:715:in `transmit'", "/var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:145:in `execute'", "/var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:52:in `execute'", "/var/lib/gems/2.3.0/gems/sensu-plugins-http-5.1.1/bin/metrics-http-json.rb:91:in `run'", "/var/lib/gems/2.3.0/gems/sensu-plugin-4.0.0/lib/sensu-plugin/cli.rb:59:in `block in <class:CLI>'"]

Of course, the request is not for port 80, making this failure perplexing.

Example in `check-http-json` does not work.

Trying this example:

#   Check that will verify http status, JSON validity, and that page.totalElements value is
#   greater than 10
#      ./check-http-json.rb -u http://my.site.com/metric.json --key page.totalElements --value-greater-than 10

I don't see where page.totalElements is setup. It does not exist in leaf so far as i see.

Command run:

/opt/sensu/embedded/bin/ruby /opt/sensu/embedded/bin/check-http-json.rb -u https://jsonplaceholder.typicode.com/todos/ --key page.totalElements --value-less-than 10

Returns:

CheckJson CRITICAL: key check failed: undefined method `to_f' for #<Array:0x000000013a9f70>
Did you mean?  to_s
               to_a
               to_h

Versions:

/opt/sensu/embedded/bin/ruby -v
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
/opt/sensu/embedded/bin/gem list |grep 'sensu-plugins-http'
sensu-plugins-http (3.0.1)
/opt/sensu/embedded/bin/sensu-client --version
1.4.2

How to incorporate into sensu-agent (check .rb not found)

I'm absolutely new to sensu and perhaps my question is not in the right place here, but I don't know where to start.
I followed both beginner guides
https://docs.sensu.io/sensu-go/latest/guides/monitor-server-resources/
and
https://docs.sensu.io/sensu-go/latest/guides/monitor-external-resources/

Like usual in documentation, there's something basic missing which is just assumed that you know, but not stated explicitely. The requirements on the agent.

I am running sensu-backend and sensu-agent via docker. It's basically working. the agent is based on sensu/sensu:latest and extended with ruby etc from alpine packages like so:

FROM sensu/sensu:latest
RUN apk add -U --no-cache ruby bash docker openssh

My checks tell me: sh: check-cpu.rb: not found

I understand that those files, obviously coming from ruby-runtime are missing on the agent. But how to install?
Obviously, sensuctl asset add sensu/sensu-ruby-runtime is not enough. It's actually not documented anywhere, what this really does behind the scenes. Does it populate the plugin to the agent?

My docker knowledge is pretty solid, but I don't get how the sensu agent thing works. I know there's communication via http and rabbit, but not how it exactly looks like.
I've read all about the asset thing, and still don't understand how it works.

I followed the instructions on https://bonsai.sensu.io/assets/sensu/sensu-ruby-runtime to create the Docker Alpine Image and tried to start as agent, but sensu-agent is missing in this image. Which leads me to the assumtion, it's not ought to be done this way.

I'm lost, please help :-D

thats my swarm docker-compose.yml for testing: https://gist.github.com/port22/c4b98464e0fe7f39d4966c20301e79c9

No output from check-https-cert.rb in Uchiwa

Not sure if this is an Uchiwa issue or an issue with check-https-cert.rb, but my check returns output on the command line but no output when I view it in Uchiwa. Any idea as to the cause?

Error installing plugin with sensu-install

I'm getting the following error with sensu 0.25.7-1 when I'm trying to install this plugin using sensu-install.

Is there any workaround?

[root@i-044a3f27c1ba0a344 bin]# sensu-install -p sensu-plugins-http
[SENSU-INSTALL] installing Sensu plugins ...
[SENSU-INSTALL] determining if Sensu plugin gem 'sensu-plugins-http' is already installed ...
false
[SENSU-INSTALL] Sensu plugin gems to be installed: ["sensu-plugins-http"]
[SENSU-INSTALL] installing Sensu plugin gem 'sensu-plugins-http'
Building native extensions.  This could take a while...
ERROR:  Error installing sensu-plugins-http:
    ERROR: Failed to build gem native extension.

    current directory: /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/unf_ext-0.0.7.2/ext/unf_ext
/opt/sensu/embedded/bin/ruby -r ./siteconf20160817-29383-xe3h6u.rb extconf.rb
checking for main() in -lstdc++... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/opt/sensu/embedded/bin/$(RUBY_BASE_NAME)
    --with-static-libstdc++
    --without-static-libstdc++
    --with-stdc++lib
    --without-stdc++lib
/opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:541:in `try_link0'
    from /opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:556:in `try_link'
    from /opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:765:in `try_func'
    from /opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:997:in `block in have_library'
    from /opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:942:in `block in checking_for'
    from /opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:350:in `block (2 levels) in postpone'
    from /opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:320:in `open'
    from /opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:350:in `block in postpone'
    from /opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:320:in `open'
    from /opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:346:in `postpone'
    from /opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:941:in `checking_for'
    from /opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:992:in `have_library'
    from extconf.rb:6:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /opt/sensu/embedded/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0/unf_ext-0.0.7.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/unf_ext-0.0.7.2 for inspection.
Results logged to /opt/sensu/embedded/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0/unf_ext-0.0.7.2/gem_make.out
[SENSU-INSTALL] failed to install Sensu plugin gem 'sensu-plugins-http'
[SENSU-INSTALL] you can run the sensu-install command again with --verbose for more info
[SENSU-INSTALL] please take note of any failure messages above
[SENSU-INSTALL] make sure you have build tools installed (e.g. gcc)
[SENSU-INSTALL] trying to determine the Sensu plugin homepage for sensu-plugins-http ...
homepage: https://github.com/sensu-plugins/sensu-plugins-http

`certificate verify failed` and unable to add cert into trusted

Hi,

I am using a free StartSSL.com certificate at one of my applications and using this:
check-http.rb -s -u https://url_of_app:5520/test

I get the following error:
Request error: SSL_connect returned=1 errno=0 state=error: certificate verify failed

Any idea what is wrong? The certificate is not expired. Maybe I have to add it to the ca store somehow?

incorrect metrics output metrics-curl.rb

Hi,
Original output of curl contains a comma
Thus using ',' as split separator causes confusion and incorrect metrics.
It must be changed :
curl -w "%{time_total}|%{time_namelookup}|%{time_connect}|%{time_pretransfer}|%{time_redirect}|%{time_starttransfer}|%{http_code}" "http://localhost/index.php?action=Login"
0,038|0,004|0,005|0,005|0,000|0,038|301

Dependencies

A list with the dependencies in the documentation would be very... very helpful.

Expiry warning breaks when insecure option is used

The wrong expiry date is calculated when the -k (insecure) option is passed in. This then breaks expiry warning functionality.

For example:

/opt/sensu/embedded/bin/ruby check-http.rb -s -e 10000 -u 'https://www.google.com/'
CheckHttp WARNING: Certificate will expire 2017-05-17 08:58:00 UTC

And then with -k:

/opt/sensu/embedded/bin/ruby check-http.rb -s -e 10000 -u 'https://www.google.com/' -k
CheckHttp WARNING: Certificate will expire 2018-08-21 04:00:00 UTC

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::GemNotFound with message: Could not find gem 'kitchen-localhost (~> 0.3)' in any of the gem sources listed in your Gemfile.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

You can mention @dependabot in the comments below to contact the Dependabot team.

Move aws checks to aws plugin

A few checks in http use aws-sdk to check S3. That functionality should move to the aws plugin to minimize dependencies in the http plugin and keep AWS checks together. The checks should be copied to the aws repo, deprecated here, and then removed in a future major release.

Accessing deep JSON objects with metrics-http-json-deep.rb seem impossible

Hi,

I'm trying to access count from the below snippet but I either can't figure out the syntax or there is some undocumented limitation to metrics-http-json-deep.rb.

This is what I use:

metrics-http-json-deep.rb -u 'http://sensuserver:9200/_stats' -p '_stats' -r '_all[0].primaries[0].docs'

I've tried various other syntaxes for the -r parameter without success and with or without -p (since that is part of the url I pass). I've also tried passing in -h -P -p instead of the url as well but then get the

"no implicit conversion of Regexp into string" error instead of the "normal" "undefined method `each' for nil:NilClass"

{
  "_shards" : {
    "total" : 42,
    "successful" : 21,
    "failed" : 0
  },
  "_all" : {
    "primaries" : {
      "docs" : {
        "count" : 615431,
        "deleted" : 0

Any assistance or guidance would be greatly appreciated.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::GemNotFound with message: Could not find gem 'kitchen-localhost (<= 0.3.0, >= 0.3)' in any of the gem sources listed in your Gemfile.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

You can mention @dependabot in the comments below to contact the Dependabot team.

check-http.rb --port doesn't work

What can I say...

root@fserver0001:/# /opt/sensu/embedded/bin/check-http.rb --port 888888888888 -u http://192.168.1.35
CheckHttp OK: 200, 970 bytes

I have a service on port 5004. If I stop this service...

root@fserver0001:/# /opt/sensu/embedded/bin/check-http.rb --port 5004 -u http://192.168.1.35
CheckHttp OK: 200, 970 bytes

Allow override of http status codes.

Hello,

I am writing some health checks for Vault, and find this plugin to be very useful. I do however have to need to check json values, even if the http status code returned is not 200. For Vault specifically, a 429 is perfectly valid and has meaning of it's own.

I have a solution here, would this be acceptable? It simply gives the option to override failure if the code is not 200. This is a workable solution for me, but I would love your feedback.
https://github.com/aatchison/sensu-plugins-http/commit/5e0998ff0e69eeba956440f144012920f5525694#diff-6ba3638df2b4a2aa90beb376dc703d4eR179
https://github.com/aatchison/sensu-plugins-http/tree/allow-override-http-status-code

Thanks

Arron

metrics-http-json-deep.rb not working

I've been having a difficult time with the metrics-http-json-deep.rb check. I am trying to use it to collect metrics reported in JSON over HTTP in order to send them to graphite. When I run it against a simple JSON message with just two key/value pairs (like http://echo.jsontest.com/key/value/one/two), I get the following error:

Check failed to run: undefined method each' for nil:NilClass, ["/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-http-1.0.0/bin/metrics-http-json-deep.rb:81:in deep_value'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-http-1.0.0/bin/metrics-http-json-deep.rb:119:in run'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.2.0/lib/sensu-plugin/cli.rb:56:in block in <class:CLI>'"]

With more complex JSON messages, such as the output I'm actually trying to record, I get this error:

Check failed to run: no implicit conversion of Regexp into String, ["/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-http-1.0.0/bin/metrics-http-json-deep.rb:82:in tr'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-http-1.0.0/bin/metrics-http-json-deep.rb:82:in block in deep_value'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-http-1.0.0/bin/metrics-http-json-deep.rb:81:in each'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-http-1.0.0/bin/metrics-http-json-deep.rb:81:in deep_value'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-http-1.0.0/bin/metrics-http-json-deep.rb:119:in run'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.2.0/lib/sensu-plugin/cli.rb:56:in block in <class:CLI>'"]

I installed the check using sensu-install, if that helps. Any idea what the issue could be here? Would greatly appreciate any help debugging this.

New release needed

I need a new release with 074f514 included.

In version 1.0.0 sensu-plugins-http is the only sensu plugin that depends on 'rest-client', '~> 2.0'.

I build (automatically with fpm) RPM packages of all needed sensu gems (plugins and dependencies).
And the 'rest-client', '~> 2.0' dependency conflicts with other plugins 'rest-client', '1.8.0'.

[BUG] `frozen_string_literals: true` does not play nicely with `mixlib-cli` and blows up spectacularly

Check failed to run: can't modify frozen String, ["/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/mixlib-cli-1.7.0/lib/mixlib/cli.rb:316:in build_option_arguments'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/mixlib-cli-1.7.0/lib/mixlib/cli.rb:269:in block (2 levels) in opt_parser'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/mixlib-cli-1.7.0/lib/mixlib/cli.rb:268:in each'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/mixlib-cli-1.7.0/lib/mixlib/cli.rb:268:in block in opt_parser'", "/opt/sensu/embedded/lib/ruby/2.4.0/optparse.rb:1062:in initialize'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/mixlib-cli-1.7.0/lib/mixlib/cli.rb:263:in new'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/mixlib-cli-1.7.0/lib/mixlib/cli.rb:263:in opt_parser'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/mixlib-cli-1.7.0/lib/mixlib/cli.rb:230:in parse_options'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-1.4.5/lib/sensu-plugin/cli.rb:13:in initialize'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-1.4.5/lib/sensu-plugin/cli.rb:57:in new'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-1.4.5/lib/sensu-plugin/cli.rb:57:in `block in class:CLI'"]

metrics-http-json-deep filtering only integers with 'Only Numbers' flag

From the usage of the metric check bin/metrics-http-json-deep.rb:
-n, --number Output numbers only
From that, using common sense (and the formal definition of the word 'number'), I infer that this check will output any type of number, and in particular, Real Numbers !
Albeit, from the code, it is clear that this option only outputs integers:
output "#{scheme}.#{ekey}", value unless config[:numonly] && !value.is_a?(Integer) link

It is needed to change the line to something like:
output "#{scheme}.#{ekey}", value unless config[:numonly] && !value.is_a?(Numeric)
for two main reasons, the first of which and the more obvious one, mentioned above, and the second being that this change will not affect graphite values insertion, meaning the usage will not be harmed, but improved.

Cannot install gem

hello,
I cannot install the plugin, i receive the following error:
Building native extensions. This could take a while...
ERROR: Error installing sensu-plugins-http:
ERROR: Failed to build gem native extension.

current directory: /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/unf_ext-0.0.7.2/ext/unf_ext

/opt/sensu/embedded/bin/ruby -r ./siteconf20170213-8973-tlwo.rb extconf.rb
checking for main() in -lstdc++... no
creating Makefile

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/opt/sensu/embedded/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0/unf_ext-0.0.7.2/mkmf.log

current directory: /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/unf_ext-0.0.7.2/ext/unf_ext
make "DESTDIR=" clean

current directory: /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/unf_ext-0.0.7.2/ext/unf_ext
make "DESTDIR="
compiling unf.cc
make: g++: Command not found
make: *** [unf.o] Error 127

make failed, exit code 2

Gem files will remain installed in /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/unf_ext-0.0.7.2 for inspection.
Results logged to /opt/sensu/embedded/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0/unf_ext-0.0.7.2/gem_make.out

and in the logs i have:
[root@dev2-fr1-storage-cl1-01 bin]# cat /opt/sensu/embedded/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0/unf_ext-0.0.7.2/mkmf.log
have_library: checking for main() in -lstdc++... -------------------- no

"gcc -o conftest -I/opt/sensu/embedded/include/ruby-2.3.0/x86_64-linux -I/opt/sensu/embedded/include/ruby-2.3.0/ruby/backward -I/opt/sensu/embedded/include/ruby-2.3.0 -I. -I/opt/sensu/embedded/include -L/opt/sensu/embedded/lib -I/opt/sensu/embedded/include -fPIC conftest.c -L. -L/opt/sensu/embedded/lib -Wl,-R/opt/sensu/embedded/lib -L/opt/sensu/embedded/lib -Wl,-R/opt/sensu/embedded/lib -L. -Wl,-rpath /opt/sensu/embedded/lib -I/opt/sensu/embedded/include -fstack-protector -L/opt/sensu/embedded/lib -rdynamic -Wl,-export-dynamic -L/opt/sensu/embedded/lib -Wl,-R/opt/sensu/embedded/lib -Wl,-R/opt/sensu/embedded/lib -L/opt/sensu/embedded/lib -lruby -lpthread -lrt -ldl -lcrypt -lm -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char *argv)
4: {
5: return 0;
6: }
/
end */

"gcc -o conftest -I/opt/sensu/embedded/include/ruby-2.3.0/x86_64-linux -I/opt/sensu/embedded/include/ruby-2.3.0/ruby/backward -I/opt/sensu/embedded/include/ruby-2.3.0 -I. -I/opt/sensu/embedded/include -L/opt/sensu/embedded/lib -I/opt/sensu/embedded/include -fPIC conftest.c -L. -L/opt/sensu/embedded/lib -Wl,-R/opt/sensu/embedded/lib -L/opt/sensu/embedded/lib -Wl,-R/opt/sensu/embedded/lib -L. -Wl,-rpath /opt/sensu/embedded/lib -I/opt/sensu/embedded/include -fstack-protector -L/opt/sensu/embedded/lib -rdynamic -Wl,-export-dynamic -L/opt/sensu/embedded/lib -Wl,-R/opt/sensu/embedded/lib -Wl,-R/opt/sensu/embedded/lib -L/opt/sensu/embedded/lib -lruby -lstdc++ -lpthread -lrt -ldl -lcrypt -lm -lc"
/bin/ld: cannot find -lstdc++
collect2: error: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /top/
4: extern int t(void);
5: int main(int argc, char *argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: int t(void) { void ((volatile p)()); p = (void (()()))main; return !p; }
/
end */

"gcc -o conftest -I/opt/sensu/embedded/include/ruby-2.3.0/x86_64-linux -I/opt/sensu/embedded/include/ruby-2.3.0/ruby/backward -I/opt/sensu/embedded/include/ruby-2.3.0 -I. -I/opt/sensu/embedded/include -L/opt/sensu/embedded/lib -I/opt/sensu/embedded/include -fPIC conftest.c -L. -L/opt/sensu/embedded/lib -Wl,-R/opt/sensu/embedded/lib -L/opt/sensu/embedded/lib -Wl,-R/opt/sensu/embedded/lib -L. -Wl,-rpath /opt/sensu/embedded/lib -I/opt/sensu/embedded/include -fstack-protector -L/opt/sensu/embedded/lib -rdynamic -Wl,-export-dynamic -L/opt/sensu/embedded/lib -Wl,-R/opt/sensu/embedded/lib -Wl,-R/opt/sensu/embedded/lib -L/opt/sensu/embedded/lib -lruby -lstdc++ -lpthread -lrt -ldl -lcrypt -lm -lc"
conftest.c:13:13: error: conflicting types for ‘main’
extern void main();
^
conftest.c:5:5: note: previous definition of ‘main’ was here
int main(int argc, char *argv)
^
checked program was:
/
begin */
1: #include "ruby.h"
2:
3: /top/
4: extern int t(void);
5: int main(int argc, char *argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: extern void main();
14: int t(void) { main(); return 0; }
/
end */


Do I need to install any specific packet or something? For other sensu plugins I don't have any issues

Check http response greater of n bytes

Would be util an option in http check that check response length is greater than option value. Actually there is an option to check if response length is equals to option value

Create a check that supports xml

We found the check-http-json.rb was a very helpful check for our JSON returning API calls but wanted to be able to leverage it for our XML returning API calls as well.

So I have made some tweaks (as per code below) to allow you to select response type XML or JSON, then it converts the XML response to JSON and performs the same JSON search on it.
This has been working well for us so far.

Also, in order to be able to output this to influxDB to be able to build a dashboard in grafana I added the ability to select an output type or Check or Metric that will output in the Check output format or metric output format so that it will go into influxdb.

Just sharing this back in case you wanted to consider making this part of the plugin or making your own modification to fit this need.

# ! /usr/bin/env ruby
# 
# check-http-json
# 
# DESCRIPTION:
# Takes either a URL or a combination of host/path/query/port/ssl, and checks
# for valid JSON output in the response. Can also optionally validate simple
# string key/value pairs.
# 
# OUTPUT:
# plain text
# 
# PLATFORMS:
# Linux
# 
# DEPENDENCIES:
# gem: sensu-plugin
# gem: json
# 
# USAGE:
# #YELLOW
# 
# NOTES:
# Based on Check HTTP by Sonian Inc.
# Charles Curran: Made small tweak to allow for XML response use, converts to JSON then does the KEY = VALUE compare
# 
# LICENSE:
# Copyright 2013 Matt Revell [email protected]
# Released under the same terms as Sensu (the MIT license); see LICENSE
# for details.
# 

require 'sensu-plugin/check/cli'
require 'json'
require 'net/http'
require 'net/https'
require 'active_support/core_ext/hash'
# 
# Check JSON
# 

class CheckJson < Sensu::Plugin::Check::CLI
  option :url, short: '-u URL'
  option :host, short: '-h HOST'
  option :path, short: '-p PATH'
  option :query, short: '-q QUERY'
  option :port, short: '-P PORT', proc: proc(&:to_i)
  option :header, short: '-H HEADER', long: '--header HEADER'
  option :ssl, short: '-s', boolean: true, default: false
  option :insecure, short: '-k', boolean: true, default: false
  option :user, short: '-U', long: '--username USER'
  option :password, short: '-a', long: '--password PASS'
  option :cert, short: '-c FILE'
  option :cacert, short: '-C FILE'
  option :timeout, short: '-t SECS', proc: proc(&:to_i), default: 15
  option :key, short: '-K KEY', long: '--key KEY'
  option :value, short: '-v VALUE', long: '--value VALUE'
  ##CHUCK ADDED OPTIONS
  option :responseType, short: '-r RESPONSETYPE', default:'JSON'
  option :outputType, short: '-o OUTPUTTYPE', default:'CHECK'
  option :metricscheme, short: '-m METRICSCHEME'

  ##CHUCK ADDED FUNCTION
  def output_result(output,metircscheme, status, outputMessage)
    if output.upcase == "CHECK"
        if status == "OK"
            ok outputMessage
        elsif status == "WARNING"
            warning outputMessage
        elsif status == "FAIL"
            fail outputMessage
        elsif status == "CRITICAL"
            critical outputMessage
        else #UKNOWN
            unknown outputMessage
        end
    end
    if output.upcase == "METRIC"
        if status == "OK"
            state = 0
        elsif status == "WARNING"
            state = 1
        elsif status == "FAIL"
            state = 2
        elsif status == "CRITICAL"
            state = 2
        else #UNKNOWN
            state = 3
        end
       puts "#{metircscheme}\t#{state}\t#{Time.now}"
       exit 0
    end
  end

  def run
    if config[:url]
      uri = URI.parse(config[:url])
      config[:host] = uri.host
      config[:path] = uri.path
      config[:query] = uri.query
      config[:port] = uri.port
      config[:ssl] = uri.scheme == 'https'
    else
      # #YELLOW
      unless config[:host] && config[:path] # rubocop:disable IfUnlessModifier
        # unknown 'No URL specified'
        #CHUCK
        output_result(config[:outputType],config[:metricscheme], "UKNOWN", "No URL specified")
      end
      config[:port] ||= config[:ssl] ? 443 : 80
    end
    begin
      timeout(config[:timeout]) do
        acquire_resource
      end
    rescue Timeout::Error
      # critical 'Connection timed out'
      #CHUCK
      output_result(config[:outputType],config[:metricscheme], "CRITICAL", "Connection timed out")
    rescue => e
      # critical "Connection error: #{e.message}"
      #CHUCK
      output_result(config[:outputType],config[:metricscheme], "CRITICAL", "Connection error: #{e.message}")
    end
  end

  def json_valid?(str)
    JSON.parse(str)
    return true
  rescue JSON::ParserError
    return false
  end

  def acquire_resource # rubocop:disable all
    http = Net::HTTP.new(config[:host], config[:port])


if config[:ssl]
  http.use_ssl = true
  if config[:cert]
    cert_data = File.read(config[:cert])
    http.cert = OpenSSL::X509::Certificate.new(cert_data)
    http.key = OpenSSL::PKey::RSA.new(cert_data, nil)
  end
  http.ca_file = config[:cacert] if config[:cacert]
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE if config[:insecure]
end

req = Net::HTTP::Get.new([config[:path], config[:query]].compact.join('?'))
if !config[:user].nil? && !config[:password].nil?
  req.basic_auth config[:user], config[:password]
end
if config[:header]
  config[:header].split(',').each do |header|
    h, v = header.split(':', 2)
    req[h] = v.strip
  end
end
res = http.request(req)

##Chuck: Added Check for New Response Type to Convert XML Response to JSON so it can process it
if config[:responseType] == "XML" then
    responseBody = Hash.from_xml(res.body).to_json
    # puts "XML Converted To : #{responseBody}"
elsif config[:responseType] == "JSON" then
    responseBody = res.body
else
    # critical ' is an invalid response type from request'
    ##CHUCK
    output_result(config[:outputType],config[:metricscheme], "CRITICAL", ' is an invalid response type from request')
end

# critical res.code unless res.code =~ /^2/
# critical 'invalid JSON from request' unless json_valid?(responseBody)
# ok 'valid JSON returned' if config[:key].nil? && config[:value].nil?

##CHUCK
if !res.code =~ /^2/
    output_result(config[:outputType],config[:metricscheme], "CRITICAL", res.code)
end
if !json_valid?(responseBody)
    output_result(config[:outputType],config[:metricscheme], "CRITICAL", " invalid JSON from request")
end
if config[:key].nil? && config[:value].nil?
    output_result(config[:outputType],config[:metricscheme], "OK", " valid JSON returned")
end

json = JSON.parse(responseBody)

begin
  keys = config[:key].scan(/(?:\\\.|[^.])+/).map { |key| key.gsub(/\\./, '.') }

  leaf = keys.reduce(json) do |tree, key|
    # fail "could not find key: #{config[:key]}" unless tree.key?(key)
    ##CHUCK
    if !tree.key?(key)
        output_result(config[:outputType],config[:metricscheme], "FAIL",  "could not find key: #{config[:key]}")
    end
    tree[key]
    end

  # fail "unexpected value for key: '#{config[:value]}' != '#{leaf}'" unless leaf == config[:value]
  output_result(config[:outputType],config[:metricscheme], "FAIL'"  "unexpected value for key: '#{config[:value]}' != '#{leaf}'") unless leaf == config[:value]

  # ok "key has expected value: '#{config[:key]}' = '#{config[:value]}'"
  output_result(config[:outputType],config[:metricscheme], "OK", "key has expected value: '#{config[:key]}' = '#{config[:value]}'")
rescue => e
  # critical "key check failed: #{e}"
  output_result(config[:outputType],config[:metricscheme], "CRITICAL", " key check failed: #{e}")
end

  end
end

Failing to build

Hi,

I'm trying to download and build the gem by using either sensu-install -p http or /opt/sensu/embedded/bin/gem install sensu-plugins-http and I'm getting the following errors:

mstsc_2016-08-05_14-19-15

Any ideas how I can resolve this?

Kind regards,
James.

check-http.rb fails with IPv6(-only) DNS names

Command: check-http.rb -u :::http.url|https://rpm.cyberfusion.nl::: -k -r

Output: CheckHttp CRITICAL: Request error: Failed to open TCP connection to rpm.cyberfusion.nl:443 (Hostname not known: rpm.cyberfusion.nl)

IPv6-only DNS name:

MacBook-Air-van-William:~ wedwards$ host rpm.cyberfusion.nl
rpm.cyberfusion.nl is an alias for packages.cyberfusion.nl.
packages.cyberfusion.nl has IPv6 address 2a0c:eb00:0:f7:185:233:175:203

CheckJson CRITICAL: key check failed: unexpected value for key: 'true' != 'true'

The plugin checks for string values, but JSON may contain boolean or integer values. For example, the object {"health": true, "errors": 0} would fail for --key "errors" --value "0" and --key "health" --value "true".

I notice that this works in sensu-community-plugins/http/check-http-json.rb, which handles nested values as well. I'm submitting a patch for the string comparison, but will hold off on nested values for now. Is there a reason for the difference?

read postbody as a string argument and not as a file in check-http-json.rb

See this line. Forcing the sensu-client to have a file with the body when using -b argument is limiting. I would prefer the server to be able to send the body as a string argument. I've tried to hack around this by using the <(..) bash statement in order to create an on-the-fly file descriptor and pass it as the body argument instead:

// sensu-server checks conf.d:
"check-gcm-service-health": {
    "command": "check-http-json.rb -u 'http://gcm-http.googleapis.com/gcm/send' -m POST -H 'Content-Type: application/json,Authorization: key=my-key' -b <(echo '{\"to\": \"my-device-token\"}') -K 'results' -v '[{\"error\"=>\"NotRegistered\"}]'",
        // other options

This however doesn't work, since sensu-client is using /bin/sh and not /bin/bash (I think), thus the <(..) statement returns a sh: 1: Syntax error: "(" unexpected.

It would've been a lot easier (and simpler) if the body could be passed as a string argument instead of a file. You can easily stay backward compatible by using:

check-http-json.rb -b `cat body.txt`

failed to install Sensu plugin gem 'sensu-plugins-http' because of missing dependencies

The latest sensu-plugins-http fails to install.

Actual behaviour:

# sensu-install -p http
[SENSU-INSTALL] installing Sensu plugins ...
[SENSU-INSTALL] determining if Sensu plugin gem 'sensu-plugins-http' is already installed ...
/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-0.25.7/exe/sensu-install:45: warning: Insecure world writable dir /opt in PATH, mode 040777
false
[SENSU-INSTALL] Sensu plugin gems to be installed: ["sensu-plugins-http"]
[SENSU-INSTALL] installing Sensu plugin gem 'sensu-plugins-http'
Building native extensions.  This could take a while...
/opt/sensu/embedded/lib/ruby/site_ruby/2.3.0/rubygems/ext/builder.rb:76: warning: Insecure world writable dir /opt in PATH, mode 040777
ERROR:  Error installing sensu-plugins-http:
    ERROR: Failed to build gem native extension.

    current directory: /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/unf_ext-0.0.7.2/ext/unf_ext
/opt/sensu/embedded/bin/ruby -r ./siteconf20160818-28877-1f8qvvw.rb extconf.rb
checking for main() in -lstdc++... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/opt/sensu/embedded/bin/$(RUBY_BASE_NAME)
    --with-static-libstdc++
    --without-static-libstdc++
    --with-stdc++lib
    --without-stdc++lib
/opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:541:in `try_link0'
    from /opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:556:in `try_link'
    from /opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:765:in `try_func'
    from /opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:997:in `block in have_library'
    from /opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:942:in `block in checking_for'
    from /opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:350:in `block (2 levels) in postpone'
    from /opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:320:in `open'
    from /opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:350:in `block in postpone'
    from /opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:320:in `open'
    from /opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:346:in `postpone'
    from /opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:941:in `checking_for'
    from /opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:992:in `have_library'
    from extconf.rb:6:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /opt/sensu/embedded/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0/unf_ext-0.0.7.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/unf_ext-0.0.7.2 for inspection.
Results logged to /opt/sensu/embedded/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0/unf_ext-0.0.7.2/gem_make.out
[SENSU-INSTALL] failed to install Sensu plugin gem 'sensu-plugins-http'
[SENSU-INSTALL] you can run the sensu-install command again with --verbose for more info
[SENSU-INSTALL] please take note of any failure messages above
[SENSU-INSTALL] make sure you have build tools installed (e.g. gcc)
[SENSU-INSTALL] trying to determine the Sensu plugin homepage for sensu-plugins-http ...
homepage: https://github.com/sensu-plugins/sensu-plugins-http
# cat   /opt/sensu/embedded/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0/unf_ext-0.0.7.2/mkmf.log
"gcc -o conftest -I/opt/sensu/embedded/include/ruby-2.3.0/x86_64-linux -I/opt/sensu/embedded/include/ruby-2.3.0/ruby/backward -I/opt/sensu/embedded/include/ruby-2.3.0 -I.  -I/opt/sensu/embedded/include   -L/opt/sensu/embedded/lib -I/opt/sensu/embedded/include -fPIC conftest.c  -L. -L/opt/sensu/embedded/lib -Wl,-R/opt/sensu/embedded/lib -L/opt/sensu/embedded/lib -Wl,-R/opt/sensu/embedded/lib -L. -Wl,-rpath /opt/sensu/embedded/lib -I/opt/sensu/embedded/include -fstack-protector -L/opt/sensu/embedded/lib -rdynamic -Wl,-export-dynamic -L/opt/sensu/embedded/lib  -Wl,-R/opt/sensu/embedded/lib     -Wl,-R/opt/sensu/embedded/lib -L/opt/sensu/embedded/lib -lruby  -lpthread -lrt -ldl -lcrypt -lm   -lc"
/opt/sensu/embedded/lib/ruby/2.3.0/mkmf.rb:395: warning: Insecure world writable dir /opt in PATH, mode 040777
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

Expected behaviour:

# sensu-install -p http:0.3.0
[SENSU-INSTALL] installing Sensu plugins ...
[SENSU-INSTALL] determining if Sensu plugin gem 'sensu-plugins-http:0.3.0' is already installed ...
/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-0.25.7/exe/sensu-install:45: warning: Insecure world writable dir /opt in PATH, mode 040777
false
[SENSU-INSTALL] Sensu plugin gems to be installed: ["sensu-plugins-http:0.3.0"]
[SENSU-INSTALL] installing Sensu plugin gem 'sensu-plugins-http:0.3.0'
Fetching: sensu-plugins-http-0.3.0.gem (100%)
You can use the embedded Ruby by setting EMBEDDED_RUBY=true in /etc/default/sensu
Successfully installed sensu-plugins-http-0.3.0
1 gem installed
[SENSU-INSTALL] successfully installed Sensu plugins: ["http:0.3.0"]

Allow alternate response codes

I have a use case where I have a /healthcheck route that returns a json hash containing the status of each major external component that the system talks to. My desire is to setup a check-http-json check for each of the three components of the app so that I can know at a glance where the issue might be. The trouble that I'm running into is that my /healthcheck route returns a 200 if everything is healthy and a 503 otherwise. This results in all of my checks going critical if any of them fail. I'd like to be able to ignore the response code with a --ignore-respose-code parameter (or similar).

$ curl http://127.0.0.1/healthcheck -v
* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 80 (#0)
> GET /healthcheck HTTP/1.1
> User-Agent: curl/7.35.0
> Host: 127.0.0.1
> Accept: */*
> 
< HTTP/1.1 503 Service Unavailable
* Server nginx/1.8.0 is not blacklisted
< Server: nginx/1.8.0
< Date: Mon, 27 Jul 2015 18:43:10 GMT
< Content-Type: application/json
< Transfer-Encoding: chunked
< Connection: keep-alive
< X-Powered-By: Express
< 
* Connection #0 to host 127.0.0.1 left intact
{
  "generated_at": "2015-07-27T18:43:08.837Z",
  "duration_millis": "0.3",
  "tests": {
    "db": {
      "test_name": "db",
      "tested_at": "2015-07-27T18:43:08.837Z",
      "duration_millis": "3.4",
      "result": "passed"
    },
    "redis": {
      "test_name": "redis",
      "tested_at": "2015-07-27T18:43:08.837Z",
      "result": "failed",
      "duration_millis": "999.9",
      "error": "timeout"
    },
    "statsd": {
      "test_name": "statsd",
      "tested_at": "2015-07-27T18:43:08.837Z",
      "result": "passed",
      "duration_millis": "1.0"
    }
  }
}

Notice that redis.result === "failed" and db and statsd.result === "passed"

Given that /healthcheck output, I'd like to setup the following checks and have deploymenttracker-http and deploymenttracker-redis be critical and -statsd and -db be OK.

{
  "checks": {
    "deploymenttracker-http": {
      "type": "check",
      "handlers": ["default"],
      "command": "/opt/sensu/embedded/bin/ruby /etc/sensu/plugins/http/check-http.rb -t 10 -u http://localhost/healthcheck",
      "interval": 30,
      "standalone": true
    },
    "deploymenttracker-db": {
      "type": "check",
      "handlers": ["default"],
      "command": "/opt/sensu/embedded/bin/ruby /etc/sensu/plugins/http/check-http-json.rb -t 10 -u http://localhost/healthcheck --key \"tests,db,result\" --value \"passed\"",
      "interval": 30,
      "standalone": true
    },
    "deploymenttracker-redis": {
      "type": "check",
      "handlers": ["default"],
      "command": "/opt/sensu/embedded/bin/ruby /etc/sensu/plugins/http/check-http-json.rb -t 10 -u http://localhost/healthcheck --key \"tests,redis,result\" --value \"passed\"",
      "interval": 30,
      "standalone": true
    },
    "deploymenttracker-statsd": {
      "type": "check",
      "handlers": ["default"],
      "command": "/opt/sensu/embedded/bin/ruby /etc/sensu/plugins/http/check-http-json.rb -t 10 -u http://localhost/healthcheck --key \"tests,statsd,result\" --value \"passed\"",
      "interval": 30,
      "standalone": true
    }
  }
}

Would you be open to a PR adding a --ignore-status-code parameter that would alter the code flow to not return critical with the code if --ignore-status-code was asserted? If you have suggestions for a better parameter name or different implementation, I'd be happy to hear them. https://github.com/sensu/sensu-community-plugins/blob/master/plugins/http/check-http-json.rb#L101

Thanks for your consideration!

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.