From 198274914a4e844d79147c05276ec724ff45fbd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toralf=20F=C3=B6rster?= Date: Sat, 3 Aug 2024 20:16:36 +0200 Subject: [PATCH] unify lockfile name + switch par 2 and 3 --- metrics.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/metrics.sh b/metrics.sh index aaf9f15..8f8a002 100755 --- a/metrics.sh +++ b/metrics.sh @@ -158,7 +158,7 @@ set -eu export LANG=C.utf8 export PATH=/usr/sbin:/usr/bin:/sbin/:/bin -lockfile="/tmp/$(basename $0).lock" +lockfile="/tmp/torutils-$(basename $0).lock" if [[ -s $lockfile ]]; then pid=$(cat $lockfile) if kill -0 $pid &>/dev/null; then @@ -170,16 +170,15 @@ fi echo $$ >"$lockfile" intervall=${1:-0} -export NICKNAME=${2:-$(grep "^Nickname " /etc/tor/torrc 2>/dev/null | awk '{ print $2 }')} # if neither given nor found then use _orport2nickname() -export datadir=${3:-/var/lib/node_exporter} - +export datadir=${2:-/var/lib/node_exporter} cd $datadir +export NICKNAME=${3:-$(grep "^Nickname " /etc/tor/torrc 2>/dev/null | awk '{ print $2 }')} # if neither given nor found then use _orport2nickname() export cpus=$(((1 + $(nproc)) / 2)) export -f _histogram _ipset2nickname _orport2nickname while :; do - now=${EPOCHSECONDS} + now=$EPOCHSECONDS export tmpfile=$(mktemp /tmp/metrics_torutils_XXXXXX.tmp) echo "# $0 $(date -R)" >$tmpfile