node_exporter: Add verbose option
This commit is contained in:
parent
b6bceb64a4
commit
56ed9010ac
1 changed files with 16 additions and 0 deletions
|
@ -6,19 +6,35 @@ umask 022
|
||||||
|
|
||||||
PATH="/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin"
|
PATH="/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin"
|
||||||
|
|
||||||
|
if [ "${1:-}" = "-v" ]; then
|
||||||
|
shift
|
||||||
|
VERBOSE=true
|
||||||
|
else
|
||||||
|
VERBOSE=false
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${1:-}" ]; then
|
||||||
|
echo "Usage: $(basename "$0") [-v]" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$(uname -s)" = "OpenBSD" ]; then
|
if [ "$(uname -s)" = "OpenBSD" ]; then
|
||||||
OUTDIR="/var/db/node-exporter"
|
OUTDIR="/var/db/node-exporter"
|
||||||
else
|
else
|
||||||
OUTDIR="/var/lib/prometheus/node-exporter"
|
OUTDIR="/var/lib/prometheus/node-exporter"
|
||||||
fi
|
fi
|
||||||
|
"$VERBOSE" && echo "Using output directory '${OUTDIR}'"
|
||||||
|
|
||||||
for script in /usr/local/libexec/node-exporter/*; do
|
for script in /usr/local/libexec/node-exporter/*; do
|
||||||
[ -x "$script" ] || continue
|
[ -x "$script" ] || continue
|
||||||
|
"$VERBOSE" && echo "Processing script '${script}'"
|
||||||
target="${OUTDIR}/$(basename "$script")"
|
target="${OUTDIR}/$(basename "$script")"
|
||||||
tmpfile="$(mktemp -p "$OUTDIR")"
|
tmpfile="$(mktemp -p "$OUTDIR")"
|
||||||
if "$script" > "$tmpfile" ; then
|
if "$script" > "$tmpfile" ; then
|
||||||
|
"$VERBOSE" && echo " Success, updating stats"
|
||||||
mv "$tmpfile" "$target"
|
mv "$tmpfile" "$target"
|
||||||
else
|
else
|
||||||
|
"$VERBOSE" && echo " Failure, skipping stats update"
|
||||||
rm -f "$tmpfile"
|
rm -f "$tmpfile"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue