Check_TCP monitor not adding timestamp to RRD?

Hi everyone; I could be wildly barking up the wrong tree here, but I figured that it’s worth a shot!
I have LibreNMS+Nagios Plugins+RRDReST+Grafana. I’m using check_tcp for a few services that I care about and when I try to visualize the RRD’s in Grafana, I’m missing the time stamp in the DS that we can use to create the timeseries graph. The RRD has, of course, the start, step, and end; but Grafana seems to want time as an entry in the DS to graph this.

I know Libre stores the timestamps in the sql db; but can it also store the data in the RRD?

Interested in a workaround?

It looks to me like the problem is that check_tcp (and some other check scripts) use ‘time’ as the data DS, which LibreNMS normally uses as the timestamp DS.

So I created a wrapper that replaces time= with rtime= (for response time) in the output.

I just created a file called check_tcp_r in the same location as check_tcp with the following script contents…

#!/usr/bin/env bash

BIN_CT="/usr/lib/nagios/plugins/check_tcp"
BIN_SED="$(command -v sed)"

OUTPUT=$($BIN_CT $@)
EXITCODE=$?

echo $OUTPUT | $BIN_SED 's/time=/rtime=/'
exit $EXITCODE

…and make it executable. Then I created a new service with a tcp_r check type which gives me both time (as a timestamp) and rtime (as response time data) fields/DS.

That did exactly what I needed! Thank you!

1 Like