A GTP echo probe is eighteen lines of Dockerfile and one NULL check

Teaching cloudprober to ping over GTP needed no fork of either project — it needed a one-line patch to an upstream file that dereferences a pointer it never checks.

Monitoring

An ICMP ping to a gateway's signalling address tells you the host is up. It says nothing about the stack that carries subscriber sessions, because that stack listens on UDP 2123 and answers a different message. GTP has an echo of its own (Echo Request, Echo Response), and gtping already speaks it, so the probe to build was an image that has both tools in it.

The whole image

ARG CLOUDPROBER_VERSION=v0.13.7

FROM alpine:latest AS build
RUN apk add musl-dev linux-headers git gcc make
COPY fix-ifs-with-no-addr.patch .
RUN git clone https://github.com/ThomasHabets/gtping.git \
    && cd gtping \
    && git apply /fix-ifs-with-no-addr.patch \
    && sed -i '/#include"gtping.h"/a #include <time.h>' src/monotonic_generic.c \
    && ./configure && make && make install

FROM cloudprober/cloudprober:${CLOUDPROBER_VERSION}
LABEL GTP_PING_VERSION=gtping-0.15-master-patch
EXPOSE 9313
COPY --from=build /usr/local/bin/gtping /usr/local/bin/gtping

Two stages (builder, runtime). The builder is Alpine with a C toolchain; the runtime is the upstream cloudprober image with one static binary copied in. Neither project is vendored, forked or patched in place — the patch lives in this repository and is applied at build time, and the LABEL records which upstream tag it was applied to (gtping-0.15, master plus the patch).

The NULL check

The patch is four lines of diff against src/ifaddrs_ifaddrs.c (one changed, three of context):

-        if (curifa->ifa_addr->sa_family != dest->ai_family) {
+        if (!curifa->ifa_addr || curifa->ifa_addr->sa_family != dest->ai_family) {

getIfAddrs() walks the interface list and compares each address family against the destination's. ifa_addr is allowed to be NULL — getifaddrs(3) says so — and it is NULL for any interface with no address assigned. On a developer's laptop every interface has one (lo, eth0, wlan0), so the loop never trips. Inside a container it does: the probe segfaulted before a single packet left the host.

That is the whole reason this repository exists. The second fix in the same RUN is smaller: monotonic_generic.c uses clock_gettime without including <time.h>, which newer GCC refuses, so a sed inserts the include after the existing #include"gtping.h". A sed in a Dockerfile is an ugly way to carry a patch; it is also two lines shorter than a second patch file, and it has not needed to change since.

What the metrics are, and are not

EXPOSE 9313 declares cloudprober's metrics port, and that is the only metrics surface here. gtping prints to stdout and exports nothing (no listener, no textfile output). So the series this image produces are cloudprober's own — success, failure and latency per probe, labelled with the probe name — with GTP visible only in the name you give the probe. There is no gtp_* metric family, because nothing in the image emits one.

That matters when writing the alert. The useful signal is a probe whose ICMP sibling to the same address is green while the GTP probe is red; the pair has to be configured deliberately, since one probe on its own cannot distinguish a dead host from a dead GTP stack.

Four commits, and the last two are CI

CW-1663 built the image (one commit, eighteen lines of Dockerfile). Then fix(CW-3385): add missing time.h include for newer GCC once the toolchain moved under it, feat(CW-3385): migrate CI from Jenkins to GitHub Actions, and ci(CW-3385): add promote_to_prod for automatic production promotion. That last one is worth more than it looks: the image that passed in development is promoted to production, not rebuilt there. A rebuild of the same Dockerfile would clone gtping's master again and produce a different binary from the same four lines of patch.