Problem using $HOSTNAME$ in a custom object macro
Posted: Fri Mar 31, 2017 8:47 am
hello,
New to Nagios, sorry if this is a known issue, my searching so far didn't yield an answer on it.
I have a requirement to make an older version of Nagios (3.5.1) talk to Prometheus via check_prometheus_metric.sh (found on github). Eventually I had the need to pass an instance (host) into the Prometheus query, and I tried to derive that from $HOSTNAME$ like so:
That is to say, I wanted the $HOSTNAME$ to be substituted within the $_SERVICEPROMQL custom object macro, but instead the $HOSTNAME$ is passed to check_prometheus_metric.sh as-is. Tried a few variations such as using another custom object var+macro just for the $HOSTNAME$ part and even removing the _promql step, i.e.
but the result is the same, $HOSTNAME$ ends up being passed literally to check_prometheus_metric.sh
Is this an unsupported use of $HOSTNAME$ ?
thanks.
-jeff
New to Nagios, sorry if this is a known issue, my searching so far didn't yield an answer on it.
I have a requirement to make an older version of Nagios (3.5.1) talk to Prometheus via check_prometheus_metric.sh (found on github). Eventually I had the need to pass an instance (host) into the Prometheus query, and I tried to derive that from $HOSTNAME$ like so:
Code: Select all
define command {
command_name check_prometheus
command_line $USER32$/check_prometheus_metric.sh -H '$_SERVICEPROMETHEUS_SERVER$:$_SERVICEPROMETHEUS_PORT$' -q '$ARG1$' -w '$ARG2$' -c '$ARG3$' -n '$ARG4$' -m '$ARG5$'
}
define service {
use prometheus-service-template
hostgroup_name hbase
service_description HBase JVM GC Avg Time msec
_promql HBase_GcTimeMillis{instance=~"$HOSTNAME$"}/HBase_GcCount{instance=~"$HOSTNAME$"}
check_command check_prometheus!$_SERVICEPROMQL$!200!500!hbase_gc_time_ms_avg!gt
}
Code: Select all
check_command check_prometheus!HBase_GcTimeMillis{instance=~"$HOSTNAME$"}/HBase_GcCount{instance=~"$HOSTNAME$"}!200!500!hbase_gc_time_ms_avg!gt
Is this an unsupported use of $HOSTNAME$ ?
thanks.
-jeff