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();
foreach my $xpath_find (@{$self->{option_results}->{lookup}}) {
next if ($xpath_find eq '');
eval {
my $jpath = JSON::Path->new($xpath_find);
@values = $jpath->values($self->{json_response_decoded});
@ -379,7 +381,7 @@ __END__
=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'
--lookup='$..expiration' --header='Content-Type: application/json'
@ -389,7 +391,7 @@ JSON OPTIONS:
=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>
@ -398,8 +400,8 @@ See: http://goessner.net/articles/JsonPath/
=item B<--lookup-perfdatas-nagios>
Take perfdatas from the JSON response (JSON XPath string)
Chain must be formated in Nagios format.
Take perfdata from the JSON response (JSON XPath string)
Chain must be formatted in Nagios format.
Ex : "rta=10.752ms;50.000;100.000;0; pl=0%;20;40;; rtmax=10.802ms;;;;"
=back
@ -473,11 +475,11 @@ Returns a UNKNOWN status if the value matches the string.
=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>
Critical threshold in seconds of webservice response time
Critical threshold in seconds of web service response time.
=back
@ -523,7 +525,7 @@ Specify this option if you are accessing a web page using hidden basic authentic
=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>
@ -551,11 +553,11 @@ Specify that the type of certificate is PKCS1.
=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>
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>

View File

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