Open gust102 opened 2 months ago
Hello :)
Have you tried the following generic options (which might do what you want):
--change-short-output --change-long-output
:
Modify the short/long output that is returned by the plugin.
Syntax: --change-short-output=pattern~replacement~modifier
Most commonly used modifiers are i (case insensitive) and g (replace all occurrences).
Example: adding --change-short-output='OK~Up~gi' will replace all occurrences of 'OK', 'ok', 'Ok' or 'oK' with 'Up'
or
--output-ignore-labe
:
Remove the status label ("OK:", "WARNING:", "UNKNOWN:", CRITICAL:") from the
beginning of the output.
Example: 'OK: Ram Total:...' will become 'Ram Total:...'
Hello,
But that would only change the output text, and still the exit code will be 3 (UNKNOWN)? What I am looking for is "as long as ResultCode not starts with 42, everything is OK (exit 0)"
BR Fredrik
Hello :)
Ok I need more context about your needs, but my first impression is that you may need an additional option to accept certain return codes. Can you provide us the plugin output with the option --debug
set ? (you can anonymized part that need it)?
/usr/lib64/nagios/plugins/centreon_plugins.pl --plugin cloud::azure::management::monitor::plugin \
--custommode='api' \
--mode='get-metrics' \
--subscription=xxxx \
--tenant=xxxx \
--client-id=xxxx \
--client-secret=xxxx \
--resource=xxxx \
--resource-group=xxxx \
--resource-namespace=microsoft.insights/components \
--resource-type= \
--metric=requests/failed \
--aggregation=Count \
--interval=PT30M \
--filter-dimension="request/resultCode sw '42'" \
--warning-metric=1 \
--critical-metric=5 \
--debug
UNKNOWN: No metric found (Are the filters properly set?)
== Info: Trying 51.12.196.178:443...
== Info: Connected to management.azure.com (51.12.196.178) port 443 (#0)
== Info: ALPN, offering h2
== Info: ALPN, offering http/1.1
== Info: CAfile: /etc/pki/tls/certs/ca-bundle.crt
== Info: TLSv1.0 (OUT), TLS header, Certificate Status (22):
== Info: TLSv1.3 (OUT), TLS handshake, Client hello (1):
== Info: TLSv1.2 (IN), TLS header, Certificate Status (22):
== Info: TLSv1.3 (IN), TLS handshake, Server hello (2):
== Info: TLSv1.2 (OUT), TLS header, Finished (20):
== Info: TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
== Info: TLSv1.2 (OUT), TLS header, Certificate Status (22):
== Info: TLSv1.3 (OUT), TLS handshake, Client hello (1):
== Info: TLSv1.2 (IN), TLS header, Finished (20):
== Info: TLSv1.2 (IN), TLS header, Certificate Status (22):
== Info: TLSv1.3 (IN), TLS handshake, Server hello (2):
== Info: TLSv1.2 (IN), TLS header, Unknown (23):
== Info: TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
== Info: TLSv1.3 (IN), TLS handshake, Certificate (11):
== Info: TLSv1.3 (IN), TLS handshake, CERT verify (15):
== Info: TLSv1.3 (IN), TLS handshake, Finished (20):
== Info: TLSv1.2 (OUT), TLS header, Unknown (23):
== Info: TLSv1.3 (OUT), TLS handshake, Finished (20):
== Info: SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
== Info: ALPN, server accepted to use h2
== Info: Server certificate:
== Info: subject: C=US; ST=WA; L=Redmond; O=Microsoft Corporation; CN=management.azure.com
== Info: start date: Oct 3 08:46:26 2024 GMT
== Info: expire date: Apr 1 08:46:26 2025 GMT
== Info: subjectAltName: host "management.azure.com" matched cert's "management.azure.com"
== Info: issuer: C=US; O=Microsoft Corporation; CN=Microsoft Azure RSA TLS Issuing CA 04
== Info: SSL certificate verify ok.
== Info: Using HTTP2, server supports multi-use
== Info: Connection state changed (HTTP/2 confirmed)
== Info: Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
== Info: TLSv1.2 (OUT), TLS header, Unknown (23):
== Info: TLSv1.2 (OUT), TLS header, Unknown (23):
== Info: TLSv1.2 (OUT), TLS header, Unknown (23):
== Info: Using Stream ID: 1 (easy handle 0x559288c1e650)
== Info: TLSv1.2 (OUT), TLS header, Unknown (23):
=> Send header: GET /subscriptions/xxxx/resourceGroups/xxxx/providers/microsoft.insights/components//xxxx/providers/microsoft.insights/metrics?api-version=2018-01-01&metricnames=requests%2Ffailed&aggregation=Count×pan=2024-11-05T14%3A36%3A21Z%2F2024-11-05T14%3A46%3A21Z&interval=PT30M&$filter=request/resultCode%20sw%20'42' HTTP/2
Host: management.azure.com
accept:application/json
authorization:Bearer xxxxx
== Info: TLSv1.2 (IN), TLS header, Unknown (23):
== Info: TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
== Info: TLSv1.2 (IN), TLS header, Unknown (23):
== Info: TLSv1.2 (OUT), TLS header, Unknown (23):
== Info: TLSv1.2 (IN), TLS header, Unknown (23):
== Info: TLSv1.2 (IN), TLS header, Unknown (23):
=> Recv header: HTTP/2 200
=> Recv header: cache-control: no-cache
=> Recv header: pragma: no-cache
=> Recv header: content-length: 698
=> Recv header: content-type: application/json; charset=utf-8
=> Recv header: expires: -1
=> Recv header: x-ms-correlation-request-id: xxxx
=> Recv header: x-ms-ratelimit-remaining-subscription-resource-requests: 999
=> Recv header: request-context: appId=cid-v1:xxxx
=> Recv header: x-ms-request-id: xxxx
=> Recv header: strict-transport-security: max-age=31536000; includeSubDomains
=> Recv header: x-ms-routing-request-id: SWEDENSOUTH:20241105T144536Z:xxxx
=> Recv header: x-content-type-options: nosniff
=> Recv header: date: Tue, 05 Nov 2024 14:45:36 GMT
=> Recv header:
=> Recv data: {"cost":9,"timespan":"2024-11-05T14:36:21Z/2024-11-05T14:46:21Z","interval":"PT30M","value":[{"id":"/subscriptions/xxxx/resourceGroups/xxx/providers/microsoft.insights/components/xxx/providers/Microsoft.Insights/metrics/requests/failed","type":"Microsoft.Insights/metrics","name":{"value":"requests/failed","localizedValue":"Failed requests"},"displayDescription":"Count of HTTP requests marked as failed. In most cases these are requests with a response code >= 400 and not equal to 401.","unit":"Count","timeseries":[],"errorCode":"Success"}],"namespace":"microsoft.insights/components","resourceregion":"westeurope"}
== Info: TLSv1.2 (IN), TLS header, Unknown (23):
== Info: Connection #0 to host management.azure.com left intact
Hi,
I have an issue with this command :
When there are no hits, i get: UNKNOWN: No metric found (Are the filters properly set?)
Can't find any option to get OK instead of UNKNOWN when the filter is empty.
BR Fredrik