Hello,
I am using a homemade service template similar to App-Protocol-HTTP-Json-Content to get information from a database and value the number of users connected to a wireless network profil / SSID.
I am confused by the range definition which seems not demonstrating what the following documentations annouce :
- https://docs.centreon.com/fr/docs/monitoring/metrics/
- https://nagios-plugins.org/doc/guidelines.html#THRESHOLDFORMAT
I want the service to be in WARNING state if element_1 = 0, and CRITICAL if element_1 < 40.
Starting with the WARNING, here are my test results (for the purpose of the test I am replacing 0 and 40 by the output of the service the simulate and NOK case) :
- Definition or range for WARNING seems ok sometimes, nok others :
-
[centreon-engine@mypoller ~]$ /usr/lib/centreon/plugins/centreon_protocol_http.pl --plugin=apps::protocols::http::plugin --mode=json-content --hostname=[Hostname] --proto='https' --port='8181' --cacert-file='/etc/pki/tls/certs/ca-bundle.crt' --urlpath='/api/v3/query_sql' --header='Content-Type: application/json' --data='{"db":"wlc","q":"SELECT source, curr_clients_count, wlan_profile FROM '\''[MyTable]''\'' WHERE source = '\''[MyWLC]'\'' AND wlan_profile = '\''[MyProfile]'\'' AND time >= NOW() - INTERVAL '\''11 MIN'\''","format":"json"}' --lookup='$.[0].curr_clients_count' --threshold-value='element_1' --format-ok='%{values} user(s) connected' --format-warning='No user(s) connected' --format-critical='%{values} user(s) connected' --warning-numeric='122:122' --critical-numeric='' --warning-string='' --critical-string='''' --filter-perfdata='time' --filter-perfdata='element_1' --header="Authorization: Bearer [MyToken]"
WARNING: No user(s) connected | 'element_1'=122;;;; -
[centreon-engine@mypoller ~]$ /usr/lib/centreon/plugins/centreon_protocol_http.pl --plugin=apps::protocols::http::plugin --mode=json-content --hostname=[Hostname] --proto='https' --port='8181' --cacert-file='/etc/pki/tls/certs/ca-bundle.crt' --urlpath='/api/v3/query_sql' --header='Content-Type: application/json' --data='{"db":"wlc","q":"SELECT source, curr_clients_count, wlan_profile FROM '\''[MyTable]''\'' WHERE source = '\''[MyWLC]'\'' AND wlan_profile = '\''[MyProfile]'\'' AND time >= NOW() - INTERVAL '\''11 MIN'\''","format":"json"}' --lookup='$.[0].curr_clients_count' --threshold-value='element_1' --format-ok='%{values} user(s) connected' --format-warning='No user(s) connected' --format-critical='%{values} user(s) connected' --warning-numeric='123:' --critical-numeric='' --warning-string='' --critical-string='''' --filter-perfdata='time' --filter-perfdata='element_1' --header="Authorization: Bearer [MyToken]"
WARNING: No user(s) connected | 'element_1'=122;;;; - [centreon-engine@mypoller ~]$ /usr/lib/centreon/plugins/centreon_protocol_http.pl --plugin=apps::protocols::http::plugin --mode=json-content --hostname=[Hostname] --proto='https' --port='8181' --cacert-file='/etc/pki/tls/certs/ca-bundle.crt' --urlpath='/api/v3/query_sql' --header='Content-Type: application/json' --data='{"db":"wlc","q":"SELECT source, curr_clients_count, wlan_profile FROM '\''[MyTable]''\'' WHERE source = '\''[MyWLC]'\'' AND wlan_profile = '\''[MyProfile]'\'' AND time >= NOW() - INTERVAL '\''11 MIN'\''","format":"json"}' --lookup='$.[0].curr_clients_count' --threshold-value='element_1' --format-ok='%{values} user(s) connected' --format-warning='No user(s) connected' --format-critical='%{values} user(s) connected' --warning-numeric='122:122' --critical-numeric='' --warning-string='' --critical-string='''' --filter-perfdata='time' --filter-perfdata='element_1' --header="Authorization: Bearer [MyToken]"
WARNING: No user(s) connected | 'element_1'=121;;;;
- [centreon-engine@mypoller ~]$ /usr/lib/centreon/plugins/centreon_protocol_http.pl --plugin=apps::protocols::http::plugin --mode=json-content --hostname=[Hostname] --proto='https' --port='8181' --cacert-file='/etc/pki/tls/certs/ca-bundle.crt' --urlpath='/api/v3/query_sql' --header='Content-Type: application/json' --data='{"db":"wlc","q":"SELECT source, curr_clients_count, wlan_profile FROM '\''wlan_client_limit'\'' WHERE source = '\''[MyWLC]'\'' AND wlan_profile = '\''[MyProfile]'\'' AND time >= NOW() - INTERVAL '\''11 MIN'\''","format":"json"}' --lookup='$.[0].curr_clients_count' --threshold-value='element_1' --format-ok='%{values} user(s) connected' --format-warning='No user(s) connected' --format-critical='%{values} user(s) connected' --warning-numeric='121:' --critical-numeric='' --warning-string='' --critical-string='''' --filter-perfdata='time' --filter-perfdata='element_1' --header="Authorization: Bearer [MyToken]"
WARNING: No user(s) connected | 'element_1'=121;;;;
- [centreon-engine@mypoller ~]$ /usr/lib/centreon/plugins/centreon_protocol_http.pl --plugin=apps::protocols::http::plugin --mode=json-content --hostname=[Hostname] --proto='https' --port='8181' --cacert-file='/etc/pki/tls/certs/ca-bundle.crt' --urlpath='/api/v3/query_sql' --header='Content-Type: application/json' --data='{"db":"wlc","q":"SELECT source, curr_clients_count, wlan_profile FROM '\''wlan_client_limit'\'' WHERE source = '\''[MyWLC]'\'' AND wlan_profile = '\''[MyProfile]'\'' AND time >= NOW() - INTERVAL '\''11 MIN'\''","format":"json"}' --lookup='$.[0].curr_clients_count' --threshold-value='element_1' --format-ok='%{values} user(s) connected' --format-warning='No user(s) connected' --format-critical='%{values} user(s) connected' --warning-numeric='120:' --critical-numeric='' --warning-string='' --critical-string='''' --filter-perfdata='time' --filter-perfdata='element_1' --header="Authorization: Bearer [MyToken]"
WARNING: No user(s) connected | 'element_1'=121;;;;
- [centreon-engine@mypoller ~]$ /usr/lib/centreon/plugins/centreon_protocol_http.pl --plugin=apps::protocols::http::plugin --mode=json-content --hostname=[Hostname] --proto='https' --port='8181' --cacert-file='/etc/pki/tls/certs/ca-bundle.crt' --urlpath='/api/v3/query_sql' --header='Content-Type: application/json' --data='{"db":"wlc","q":"SELECT source, curr_clients_count, wlan_profile FROM '\''[MyTable]''\'' WHERE source = '\''[MyWLC]'\'' AND wlan_profile = '\''[MyProfile]'\'' AND time >= NOW() - INTERVAL '\''11 MIN'\''","format":"json"}' --lookup='$.[0].curr_clients_count' --threshold-value='element_1' --format-ok='%{values} user(s) connected' --format-warning='No user(s) connected' --format-critical='%{values} user(s) connected' --warning-numeric='0:0' --critical-numeric='' --warning-string='' --critical-string='''' --filter-perfdata='time' --filter-perfdata='element_1' --header="Authorization: Bearer [MyToken]"
WARNING: No user(s) connected | 'element_1'=117;;;;
Unless I clear my --warning-numeric option, simulate an OK case then retry
=> is there a cache file that can explain this behaviour ?
-
- Definition or range for CRITICAL seems NOK :
- [centreon-engine@mypoller ~]$ /usr/lib/centreon/plugins/centreon_protocol_http.pl --plugin=apps::protocols::http::plugin --mode=json-content --hostname=[Hostname] --proto='https' --port='8181' --cacert-file='/etc/pki/tls/certs/ca-bundle.crt' --urlpath='/api/v3/query_sql' --header='Content-Type: application/json' --data='{"db":"wlc","q":"SELECT source, curr_clients_count, wlan_profile FROM '\''wlan_client_limit'\'' WHERE source = '\''[MyWLC]'\'' AND wlan_profile = '\''[MyProfile]'\'' AND time >= NOW() - INTERVAL '\''11 MIN'\''","format":"json"}' --lookup='$.[0].curr_clients_count' --threshold-value='element_1' --format-ok='%{values} user(s) connected' --format-warning='No user(s) connected' --format-critical='%{values} user(s) connected' --warning-numeric='1:' --critical-numeric='40:' --warning-string='' --critical-string='''' --filter-perfdata='time' --filter-perfdata='element_1' --header="Authorization: Bearer [MyToken]"
CRITICAL: 117 user(s) connected | 'element_1'=117;;;;
=> According to both documentations the service must be CRITICAL only if element 1 is strictly lower than 40…
- [centreon-engine@mypoller ~]$ /usr/lib/centreon/plugins/centreon_protocol_http.pl --plugin=apps::protocols::http::plugin --mode=json-content --hostname=[Hostname] --proto='https' --port='8181' --cacert-file='/etc/pki/tls/certs/ca-bundle.crt' --urlpath='/api/v3/query_sql' --header='Content-Type: application/json' --data='{"db":"wlc","q":"SELECT source, curr_clients_count, wlan_profile FROM '\''wlan_client_limit'\'' WHERE source = '\''[MyWLC]'\'' AND wlan_profile = '\''[MyProfile]'\'' AND time >= NOW() - INTERVAL '\''11 MIN'\''","format":"json"}' --lookup='$.[0].curr_clients_count' --threshold-value='element_1' --format-ok='%{values} user(s) connected' --format-warning='No user(s) connected' --format-critical='%{values} user(s) connected' --warning-numeric='1:' --critical-numeric='@1:40' --warning-string='' --critical-string='''' --filter-perfdata='time' --filter-perfdata='element_1' --header="Authorization: Bearer [MyToken]"
CRITICAL: 117 user(s) connected | 'element_1'=117;;;;
- [centreon-engine@mypoller ~]$ /usr/lib/centreon/plugins/centreon_protocol_http.pl --plugin=apps::protocols::http::plugin --mode=json-content --hostname=[Hostname] --proto='https' --port='8181' --cacert-file='/etc/pki/tls/certs/ca-bundle.crt' --urlpath='/api/v3/query_sql' --header='Content-Type: application/json' --data='{"db":"wlc","q":"SELECT source, curr_clients_count, wlan_profile FROM '\''wlan_client_limit'\'' WHERE source = '\''[MyWLC]'\'' AND wlan_profile = '\''[MyProfile]'\'' AND time >= NOW() - INTERVAL '\''11 MIN'\''","format":"json"}' --lookup='$.[0].curr_clients_count' --threshold-value='element_1' --format-ok='%{values} user(s) connected' --format-warning='No user(s) connected' --format-critical='%{values} user(s) connected' --warning-numeric='1:' --critical-numeric='40:' --warning-string='' --critical-string='''' --filter-perfdata='time' --filter-perfdata='element_1' --header="Authorization: Bearer [MyToken]"
HELP !!
