[root@apps1 nagios_plugins]# ./check_prometheus_metric.sh -H 'http://localhost' -q 'count(consul_health_service_status{service="test"}) - sum(consul_health_service_status{service="test"})' -c 2 -w 1 -n test
UNKNOWN - unable to parse prometheus response
test is {};0;1452182545.297
when sh -x
++ get_prometheus_result
++ local _PROMETHEUS_CMD
++ local _RESULT
++ printf -v _PROMETHEUS_CMD '%s -server=%s -timeout=%s query' '/bin/docker run --rm -ti prom/prometheus-cli' http://localhost 30s
+++ /bin/docker run --rm -ti prom/prometheus-cli -server=http://localhost -timeout=30s query 'count(consul_health_service_status{service="test"}) - sum(consul_health_service_status{service="test"})'
'+ _RESULT='{};0;1452182314.599
=~ ^-?[0-9]+.?[0-9]*$ ]]
++ case "$_RESULT" in
'+ printf %s '{};0;1452182314.599
' PROMETHEUS_RESULT='{};0;1452182314.599
=~ ^-?[0-9]+$ ]]314.599
[[ false = \t\r\u\e ]]
NAGIOS_SHORT_TEXT='unable to parse prometheus response'
' NAGIOS_LONG_TEXT='test is {};0;1452182314.599
exit
on_exit
[[ -z '' ]]
NAGIOS_STATUS=UNKNOWN
[[ -z unable to parse prometheus response ]]
printf '%s - %s\n' UNKNOWN 'unable to parse prometheus response'
UNKNOWN - unable to parse prometheus response
]][ -n test is {};0;1452182314.599
' printf '%s\n' 'test is {};0;1452182314.599
test is {};0;1452182314.599
[root@apps1 nagios_plugins]# ./check_prometheus_metric.sh -H 'http://localhost' -q 'count(consul_health_service_status{service="test"}) - sum(consul_health_service_status{service="test"})' -c 2 -w 1 -n test UNKNOWN - unable to parse prometheus response test is {};0;1452182545.297
when sh -x ++ get_prometheus_result ++ local _PROMETHEUS_CMD ++ local _RESULT ++ printf -v _PROMETHEUS_CMD '%s -server=%s -timeout=%s query' '/bin/docker run --rm -ti prom/prometheus-cli' http://localhost 30s +++ /bin/docker run --rm -ti prom/prometheus-cli -server=http://localhost -timeout=30s query 'count(consul_health_service_status{service="test"}) - sum(consul_health_service_status{service="test"})' '+ _RESULT='{};0;1452182314.599 =~ ^-?[0-9]+.?[0-9]*$ ]] ++ case "$_RESULT" in '+ printf %s '{};0;1452182314.599 ' PROMETHEUS_RESULT='{};0;1452182314.599 =~ ^-?[0-9]+$ ]]314.599