bin/check-influxdb-query.rb in sensu-plugins-influxdb-0.0.5 vs bin/check-influxdb-query.rb in sensu-plugins-influxdb-0.0.7
- old
+ new
@@ -68,11 +68,11 @@
boolean: true,
default: false
option :ssl_ca_cert,
description: 'Path to the ssl ca certificate to connect to the InfluxDB server',
- short: '-c CA_CERT',
+ short: '-C CA_CERT',
long: '--ssl_ca_cert CA_CERT'
option :database,
short: '-d DATABASE',
long: '--database DATABASE',
@@ -155,17 +155,19 @@
username: config[:username],
password: config[:password]
value = influxdb.query config[:query]
- if config[:alias]
- query_name = config[:alias]
- else
- query_name = config[:query]
- end
+ query_name = if config[:alias]
+ config[:alias]
+ else
+ config[:query]
+ end
if config[:noresult] && value.empty?
critical "No result for query '#{query_name}'"
+ elsif config[:noresult] && !config[:jsonpath] && !value.empty?
+ ok "Value returned for query '#{query_name}'"
end
if config[:jsonpath]
json_path = JsonPath.new(config[:jsonpath])
value = json_path.on(value).first || 0