fix(protocols/http): mode json-content missing expression (#5064)

Co-authored-by: garnier-quentin <garnier.quentin@gmail.com>
Fixes CTOR-679
This commit is contained in:
omercier 2024-06-14 14:29:02 +02:00 committed by GitHub
parent e0230b4ae9
commit 932e425931
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 43 additions and 30 deletions

View File

@ -193,6 +193,8 @@ sub lookup {
$self->decode_json_response(); $self->decode_json_response();
foreach my $xpath_find (@{$self->{option_results}->{lookup}}) { foreach my $xpath_find (@{$self->{option_results}->{lookup}}) {
next if ($xpath_find eq '');
eval { eval {
my $jpath = JSON::Path->new($xpath_find); my $jpath = JSON::Path->new($xpath_find);
@values = $jpath->values($self->{json_response_decoded}); @values = $jpath->values($self->{json_response_decoded});
@ -379,7 +381,7 @@ __END__
=head1 MODE =head1 MODE
Check JSON webservice. Can send the json request with option '--data'. Example: Check JSON web service. Can send the json request with option '--data'. Example:
centreon_plugins.pl --plugin=apps::protocols::http::plugin --mode=json-content --data='/home/user/request.json' --hostname='myws.site.com' --urlpath='/get/payment' centreon_plugins.pl --plugin=apps::protocols::http::plugin --mode=json-content --data='/home/user/request.json' --hostname='myws.site.com' --urlpath='/get/payment'
--lookup='$..expiration' --header='Content-Type: application/json' --lookup='$..expiration' --header='Content-Type: application/json'
@ -389,7 +391,7 @@ JSON OPTIONS:
=item B<--data> =item B<--data>
Set the JSONrequest or specify a file with the request inside. Set the JSON request or specify a file with the request inside.
=item B<--lookup> =item B<--lookup>
@ -398,8 +400,8 @@ See: http://goessner.net/articles/JsonPath/
=item B<--lookup-perfdatas-nagios> =item B<--lookup-perfdatas-nagios>
Take perfdatas from the JSON response (JSON XPath string) Take perfdata from the JSON response (JSON XPath string)
Chain must be formated in Nagios format. Chain must be formatted in Nagios format.
Ex : "rta=10.752ms;50.000;100.000;0; pl=0%;20;40;; rtmax=10.802ms;;;;" Ex : "rta=10.752ms;50.000;100.000;0; pl=0%;20;40;; rtmax=10.802ms;;;;"
=back =back
@ -473,11 +475,11 @@ Returns a UNKNOWN status if the value matches the string.
=item B<--warning-time> =item B<--warning-time>
Warning threshold in seconds of webservice response time Warning threshold in seconds of web service response time.
=item B<--critical-time> =item B<--critical-time>
Critical threshold in seconds of webservice response time Critical threshold in seconds of web service response time.
=back =back
@ -523,7 +525,7 @@ Specify this option if you are accessing a web page using hidden basic authentic
=item B<--ntlmv2> =item B<--ntlmv2>
Specify this option if you are accessing a web page using ntlmv2 authentication (use with --credentials and --port options). Specify this option if you are accessing a web page using NTLMv2 authentication (use with --credentials and --port options).
=item B<--timeout> =item B<--timeout>
@ -551,11 +553,11 @@ Specify that the type of certificate is PKCS1.
=item B<--get-param> =item B<--get-param>
Set GET params (multiple option. Example: --get-param='key=value'). Set a parameter for GET requests (multiple option. Example: --get-param='key=value').
=item B<--header> =item B<--header>
Set HTTP headers(multiple option). Example: --header='Content-Type: xxxxx'. Set HTTP headers(multiple option). Example: --header='Content-Type: application/json'.
=item B<--unknown-status> =item B<--unknown-status>

View File

@ -1,6 +1,9 @@
--add-sysdesc --add-sysdesc
--api-password --api-password
--api-version --api-version
--cacert-file
--cert-pkcs12
--cert-pwd
--critical-bytesallocatedpercentage --critical-bytesallocatedpercentage
--display-transform-dst --display-transform-dst
--display-transform-src --display-transform-src
@ -11,6 +14,8 @@
--force-counters32 --force-counters32
--force-counters64 --force-counters64
--force-oid --force-oid
--get-param
--lookup-perfdatas-nagios
--map-speed-dsl --map-speed-dsl
--mqtt --mqtt
--mqtt-allow-insecure --mqtt-allow-insecure
@ -23,22 +28,46 @@
--mqtt-timeout --mqtt-timeout
--mqtt-username --mqtt-username
--nagvis-perfdata --nagvis-perfdata
--ntlmv2
--oid-display --oid-display
--oid-extra-display --oid-extra-display
--oid-filter --oid-filter
--urlpath
--warning-bytesallocatedpercentage --warning-bytesallocatedpercentage
2c 2c
ADSL ADSL
Avigilon Avigilon
Centreon Centreon
Datacore Datacore
Fortigate
Fortinet
HashiCorp
IpAddr
Iwsva
Loggly
MBean
MQTT
Mosquitto
NTLMv2
NagVis
Nagios
Netscaler
OID
PKCS1
RRDCached
SNMP
SSH
Sansymphony
SureBackup
TendMicro
VDSL2
Veeam
WSMAN
XPath
deltaps deltaps
df df
eth eth
fanspeed fanspeed
Fortigate
Fortinet
HashiCorp
hashicorpvault hashicorpvault
ifAlias ifAlias
ifDesc ifDesc
@ -47,18 +76,9 @@ in-bcast
in-mcast in-mcast
in-ucast in-ucast
interface-dsl-name interface-dsl-name
IpAddr
Iwsva
keepass keepass
ldap ldap
license-instances-usage-prct license-instances-usage-prct
Loggly
MBean
Mosquitto
MQTT
NagVis
Netscaler
OID
okta okta
oneaccess-sys-mib oneaccess-sys-mib
out-bcast out-bcast
@ -69,22 +89,13 @@ powershell
proto proto
psu psu
queue-messages-inflighted queue-messages-inflighted
RRDCached
Sansymphony
SNMP
space-usage-prct space-usage-prct
SSH
SureBackup
teampass teampass
timeframe timeframe
topic-messages-inflighted topic-messages-inflighted
total-oper-down total-oper-down
total-oper-up total-oper-up
TendMicro
uptime uptime
userpass userpass
VDSL2
Veeam
v1 v1
v2 v2
WSMAN