playground/docker-stack/prom-proc-net.sh

28 lines
459 B
Bash

#!/bin/bash
[ -z "${PROM_PROC_NET_DIR}" ] && PROM_PROC_NET_DIR="/tmp/prometheus-proc-net"
function copy() {
local basedir="$1"
local tgtdir="$2"
for f in "$basedir"/*
do
local tgtfile=${f##$basedir/}
if [[ -d "$f" ]]
then
mkdir -p "${tgtdir}/${tgtfile}"
copy "$f" "${tgtdir}/${tgtfile}"
elif [[ -r "$f" ]]
then
cat "$f" "${tgtdir}/${tgtfile}"
:
fi
done
}
while true
do
copy "/proc/net" "${PROM_PROC_NET_DIR}"
sleep 0.5
done