Giter Site home page Giter Site logo

check_json's People

Contributors

ajhodgson avatar bensinober avatar c-kr avatar davidmat avatar locutus304 avatar mtn-rowinandruscavage avatar rodo 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

check_json's Issues

Doesn't seem to handle 302 connections

We're trying to pull json data back from ntop ntopng server. It works fine with wget and curl but on the command line it fails with a 302 error

Check JSON status API CRITICAL - Connection failed: 302 Found

If I run a curl command:

$ curl -s "http://10.10.0.99:3000/lua/host_get_json.lua?ifname=0&host=10.10.0.67"

we get good output:

HTTP/1.1 200 OK
Cache-Control: max-age=0, no-cache, no-store
Server: ntopng 2.0.150531  [Debian jessie/sid (x86_64)]
Pragma: no-cache
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Set-Cookie: session=; max-age=3600; path=/; HttpOnly
Content-Type: application/json
Last-Modified: Thu, 09 September 2015 20:10:54 GMT

{ "mac_address": "00:23:AE:A0:89:1B", "asn": 0, "symbolic_name": "10.10.0.67", "category": "safe", "ip": { "ipVersion": 4, "localHost": false, "ip": "10.10.0.67" }, "localHost": true, "systemHost": false, "tcp_sent": { "packets": 1958033, "bytes": 318127095 }, "tcp_rcvd": { "packets": 1784791, "bytes": 1119715863 }, "udp_sent": { "packets": 12190, "bytes": 3046196 }, "udp_rcvd": { "packets": 0, "bytes": 0 }, "icmp_sent": { "packets": 0, "bytes": 0 }, "icmp_rcvd": { "packets": 0, "bytes": 0 }, "other_ip_sent": { "packets": 0, "bytes": 0 }, "other_ip_rcvd": { "packets": 0, "bytes": 0 }, "pktStats.sent": { "upTo64": 1106380, "upTo128": 468681, "upTo256": 2091, "upTo512": 50494, "upTo1024": 354549, "upTo1518": 10 }, "pktStats.recv": { "upTo64": 787311, "upTo128": 475369, "upTo256": 169050, "upTo512": 78722, "upTo1024": 158387, "upTo1518": 14365, "upTo2500": 3749, "upTo6500": 44319, "upTo9000": 10807, "above9000": 43407 }, "throughput_bps": 19409.199219, "throughput_trend_bps": "Down", "throughput_pps": 62.200001,SNIPPED FOR EASE OF POSTING

It looks like it's not following the redirect but curl/wget do. Tried a few things with

push @{ $ua->requests_redirectable }, 'POST';

but that didn't help. Any ideas?

check_value_str change breaking

this commit seems to have broken my setup:

f3233fb

I'm not quite seeing what the intention is here. Should the warning and critical be specific differently now?

E.g.
./check_json.pl -u 'https://myurl/status/healthcheck/version.json' -a '{version}->{message}' -w 292 -c 290 -v

yields:
$VAR1 = '$check_value = $json_response->{'{version}->{message}'}';
Check JSON status API UNKNOWN - No value received

That output of Dumper: '$check_value = $json_response->{'{version}->{message}'}'
certainly doesn't make any sense to me either.

I'm too stupid to do the simplest lookups

Hello,

looks like i'm really stupid because all i get is "no value received" or a "Check JSON status API OK" but no values at all....

This is a JSON Response i want to check:

{
"versionInfo": [
{
"versionString": "1.1"
,"majorVersion": "1"
,"minorVersion": "1"
}
]
}

i want to check the majorVersion value.

./check_json.pl --url "https://user:pw@host/pathtojason" --attributes '{versionInfo}->{majorVersion}' --ignoressl

always ends in a "Check JSON status API UNKNOWN - No value received"

Whats up with this?

Global symbol "@host" requires explicit package name

I get this error message in the latest version:

Possible unintended interpolation of @host in string at /usr/lib/nagios/plugins/check_json line 12. Global symbol "@host" requires explicit package name at /usr/lib/nagios/plugins/check_json line 12.
Execution of /usr/lib/nagios/plugins/check_json aborted due to compilation errors.

This is on a fully update Debian Stable with Perl 5.20.2

Booleans do not work

Executing

./check_json -u http://example.com -a '{"success"}' --expect '1'

where example.com returns

{"success":true}

would fail with

Not an ARRAY reference at /usr/share/perl5/Monitoring/Plugin/Threshold.pm line 19.

I added a hack in my fork that makes it work but it's not very pretty C0rn3j@a19e7aa

unable to output perfdata from traversed object

I am checking a value nested in an array (eg. the same thing that was broken and later fixed in issue #21 ) and the checking itself, complete with thresholds logic, seems to be working ok:

./check_json.pl -u http://user:[email protected]:8161/api/jolokia/read/org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=foobar -a '{value}->{ConsumerCount}' -w 2: -c 2:
Check JSON status API OK

But I'm not able to get the same value in outputvars, and the scripts returns this warning:

./check_json.pl -u http://user:[email protected]:8161/api/jolokia/read/org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=foobar -a '{value}->{ConsumerCount}' -w 2: -c 2: -o '{value}->{ConsumerCount}'
Use of uninitialized value $output_value in concatenation (.) or string at ./check_json.pl line 252.
Check JSON status API OK - ConsumerCount: 

And I cannot get the values in perfdata too, but this time without any warning:

./check_json.pl -T text/plain -u http://user:[email protected]:8161/api/jolokia/read/org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=foobar -a '{value}->{ConsumerCount}' -w 1: -c 1: -p '{value}->{ConsumerCount}'
Check JSON status API OK

Can't locate Nagios/Plugin.pm in @INC

I tried to execute the plugin but got error as following, just went through the net but with no luck, can anyone give any suggestion?

[root@nagioscore4 check_json-master]# ./check_json.pl -u https://store.ceair.com/mas/sdk10098/public/ydkbwszb/checkCode2
Can't locate Nagios/Plugin.pm in @inc (@inc contains: /root/perl5/lib/perl5/x86_64-linux-thread-multi /root/perl5/lib/perl5 /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ./check_json.pl line 8.
BEGIN failed--compilation aborted at ./check_json.pl line 8.

I didn't modified anything in the plugin "check_json.pl", if anything should be amended inside? thank you!

format of response?

I'm trying to write a script that will return JSON to this plugin, but I can't quite figure out what is supposed to be in the JSON. Should I be returning a dictionary of names and values? correlated lists?

Sorry if this is a dumb question -- first time I'm trying to write something like this.

Feature request: Add arbitrary header support

As a user I would like to be able to check some REST-API's that require you to send additional HTTP headers, such as "X-Auth-Token header" in my request.

To be able to use check_json against API's like this would be nice. So I thought I would add a feature request for it to include such functionality in the plugin.

Concatening metrics

Hello

I want to know if it's possible to cumulate metrics

Example :
/usr/local/noc/nagios-biz/plugins/libexec/check_json.pl -u http://1X.X.X.X/statistic -a '{network}->{eth0}->{in}' -p '{network}->{eth0}->{in}' -a '{network}->{eth0}->{out}' -p '{network}->{eth0}->{out}'

Regards

uninitialized value when warn/crit thresholds not specified

On fully updated Ubuntu 14.04 LTS systems the script will spit these warnings when not specifying -w and/or -c:

Use of uninitialized value in split at ./check_json.pl line 142.
Use of uninitialized value in split at ./check_json.pl line 143.

When -w is given the former goes away, when -c is given the latter goes away.
Seems like a minor, cosmetic issue.

Plugin Check Error

Hi,

Just wondering if there was an issue w/ using zeros as a warning and critical threshold. if I set that it comes back at critical even though the status is a one. if I set the warn and crit to something other than zeros it returns OK.

Check JSON status API CRITICAL - health: 1 | health=1;0;0
Check JSON status API OK - health: 1 | health=1;5;10

Thanks.

Feature request: return perfvars, even if expected value doesn't match actual

When the actual value does not match the expected value, no perfvars are in the output:

Check JSON status API CRITICAL - Expected value (224) not found. Actual: 218

However, if they match, they are in the output. It seems we prematurely exit, without calculating if the expected value does not match the actual.

Use of uninitialized value $output_value in concatenation (.) or string at check_json.pl line 252

When having multiple records like:

{
"from": "0.050",
"error": false,
"test": {
"test01": {
"alive": true,
"value": 147.43,
"rate_below_threshold": false,
"last_time": "Mon, 03 Jul 2017 11:31:46 GMT"
}
}
}

I got empty response for value ('{test}->{test01}->{value}')
e.g.:
/usr/lib64/nagios/plugins/check_json.pl --url "https://example.com/test.json" --attribute '{test}->{test01}->{value}' --warning 140: --critical 110: --perfvars '{test}->{test01}->{value}' --outputvars '{test}->{test01}->{value}'
Use of uninitialized value $output_value in concatenation (.) or string at /usr/lib64/nagios/plugins/check_json.pl line 252.

And no value returned..

RESTful API JSON Moxa Remote IO Module

Hello,

Does anyone have any advice if the script can support the following, or if I've configured the script correctly, or another project is more suitable?

Use:

$ ./check_json.pl  -m "Accept:vdn.dac.v1" -u 'http://127.0.0.1/api/slot/0/io/ai' -a '{io}->[0]->{diIndex}' --warning :0 --critical :0
$ Check JSON status API CRITICAL - Connection failed: 411 Length Required

I'm attempting to poll a Moxa Remote IO Module with the check_json script. The Moxa devices has a port available to communication via JSON/RESTful API. It requires the following header config Accept:vdn.dac.v1, Contant-Type:application/json. I

Also an example of it working with curl:

$ curl -H "Content-type: application/json" -H "Accept:vdn.dac.v1" --request GET  http://127.0.0.1/api/slot/0/io/ai

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.