Commit 61a3390d authored by Azat Khuziyakhmetov's avatar Azat Khuziyakhmetov
Browse files

fixed beegfs clients collector script

parent dec9e0d3
......@@ -2,7 +2,7 @@
#This will report some custom BeeGFS info to telegraf/influx
#
# Created by: Khuziyakhmetov, Azat <azat.khuziyakhmetov@gwdg.de>
# date: September 18, 2018
# date:June 19, 2020
isdebug=false # set it `true` to get debug info when calling from a terminal
......@@ -14,7 +14,7 @@ HOSTNAME="$(hostname -s)"
BGFSHOSTNAME="$HOSTNAME.ib.gwdg.cluster"
BGFSLOGPATH=/dev/shm/beegfs-logger
BGFLOGFILE=$BGFSLOGPATH/beegfs.log
BGFSLOGFILE=${BGFSLOGPATH}/${HOSTNAME}.beegfs.log
debug() {
if $isdebug; then
......@@ -36,9 +36,9 @@ fi
# Create files if they don't exist
if [ ! -d "$BGFSLOGPATH" ]; then
mkdir $BGFSLOGPATH && touch $BGFLOGFILE
elif [ ! -w "$BGFLOGFILE" ]; then
touch $BGFLOGFILE
mkdir $BGFSLOGPATH && touch $BGFSLOGFILE
elif [ ! -w "$BGFSLOGFILE" ]; then
touch $BGFSLOGFILE
fi
# Create necessary arrays
......@@ -55,19 +55,13 @@ while IFS== read -r key value; do
if [ "$value" = "" ]; then value=0; fi
prev_metrics[$key]=$value
debug "$key = $value"
done < "$BGFLOGFILE"
done < "$BGFSLOGFILE"
CURTS=$(date +%s)
beegfs_command="beegfs-ctl --clientstats --names --nodetype=storage --interval=0 --filter=$BGFSHOSTNAME"
data=$( $beegfs_command | grep $BGFSHOSTNAME)
debug "Output of BeeGFS: $data"
# difference between timestamps
FRACTS=$((CURTS - PREVTS))
if [ "$FRACTS" -le "0" ]; then
FRACTS=1
fi
# Parse the current measurements
debug "Parsing current measurments"
prev_is_val=false
......@@ -85,9 +79,12 @@ done
for m in ${!aggr_metrics[@]}; do
cur_metric=${aggr_metrics[$m]}
prev_metric=${prev_metrics[$m]}
diff=`bc <<< "($cur_metric - $prev_metric) / $FRACTS"`
debug "$m: ( $cur_metric - $prev_metric ) / $FRACTS = $diff"
if [ "$prev_metric" = "" ]; then prev_metric=0; fi
diff=`bc <<< "scale=0; ($cur_metric - $prev_metric) / 1"`
debug "$m: ( $cur_metric - $prev_metric ) = $diff"
if [ "$diff" -ge "0" ]; then
metrics[$m]=$diff
......@@ -118,5 +115,7 @@ for m in ${!aggr_metrics[@]}; do
mf="$m=${aggr_metrics[$m]}\n$mf"
done
mf="timestamp=$CURTS\n$mf"
echo -e "$mf" > $BGFLOGFILE
echo -e "$mf" > $BGFSLOGFILE
debug "measurements are exported"
exit 0
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment