123456789101112131415161718192021222324252627 |
- #!/bin/sh
- # Einzeldaten und Summen von nodes.json als labeled metrics for prometheus
- ME="`basename $0`"
- PROM_PREFIX=%%PROM_PREFIX%%
- PROMDIR=%%EXPORT_DIR%%
- [ -d $PROMDIR -a -w $PROMDIR ] || PROMDIR=/tmp
- PROMFILE=$PROMDIR/$PROM_PREFIX.prom
- NODES_URL="%%NODES_URL%%"
- NODESFILE=/tmp/nodes.json.$$
- NODES2PROM=%%BIN_DIR%%/nodes2prom
- [ -f $NODES2PROM -a -x $NODES2PROM ] || NODES2PROM=./nodes2prom
- if timeout -s HUP -k 2 50 \
- %%FETCH_CMD%% $NODESFILE "$NODES_URL"
- then
- $NODES2PROM $NODESFILE > $PROMFILE.new && \
- mv $PROMFILE.new $PROMFILE
- rm -f $NODESFILE
- else
- logger -t "$ME" "failed to fetch $NODES_URL"
- rm -f $NODESFILE
- exit 1
- fi
|