Skip to content
Snippets Groups Projects
Commit 25100731 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

Merge branch '6468-docs-and-harmonize' into 'master'

netio: small fixes

See merge request !134
parents 9d6b1c54 b528add1
No related branches found
No related tags found
1 merge request!134netio: small fixes
......@@ -7,12 +7,13 @@
# ----------------------------------------------------------------------
# 2020-07-08 v1.0 <axel.hahn@iml.unibe.ch>
# 2023-08-21 v1.1 <axel.hahn@unibe.ch> add help; add param -i
# 2023-08-22 v1.2 <axel.hahn@unibe.ch> send perf data on single interface too; interfaces in alphabetic order; no more tmp file
# ======================================================================
. $( dirname $0 )/inc_pluginfunctions
export self_APPVERSION=1.1
export self_APPVERSION=1.2
# ----------------------------------------------------------------------
......@@ -62,8 +63,6 @@ if [ $bOptHelp -eq 1 ]; then
exit 0
fi
tmpfile2=`mktemp`
typeset -i iCountInterfaces
typeset -i iRead=0
......@@ -76,60 +75,61 @@ typeset -i iTotalTrans=0
data=$( cat /proc/net/dev | grep -E "(eth|en[ops][0-9]*)" )
allInterfaces=$( cut -f 1 -d ":" <<< "$data" | tr -d " " )
sInterface=$( ph.getValueWithParam "$allInterfaces" "i" "$@")
sInterface=$( ph.getValueWithParam "$allInterfaces" "i" "$@" | sort )
# ----- loop over all interfaces
iCountInterfaces=$( wc -w <<< "$sInterface" )
for myinterface in $sInterface
do
echo >>"$tmpfile2"
echo "--- ${myinterface}:" >> "$tmpfile2"
line=$( grep "${myinterface}:" <<< "$data" )
if [ -n "$line" ] ; then
out=$(
for myinterface in $sInterface
do
echo
echo "--- ${myinterface}:"
line=$( grep "${myinterface}:" <<< "$data" )
if [ -n "$line" ] ; then
# echo "SOURCE: $line" >> $tmpfile2
# echo "SOURCE: $line"
# total value of byte
iRead=$( echo "$line" | awk '{ print $2 }')
iTrans=$(echo "$line" | awk '{ print $10 }')
# total value of byte
iRead=$( echo "$line" | awk '{ print $2 }')
iTrans=$(echo "$line" | awk '{ print $10 }')
# speed in byte per sec based on last stored value and its age
iSpeedRead=$( ph.perfdeltaspeed "netio-${myinterface}-rx" $iRead)
iSpeedTrans=$(ph.perfdeltaspeed "netio-${myinterface}-tx" $iTrans)
# speed in byte per sec based on last stored value and its age
iSpeedRead=$( ph.perfdeltaspeed "netio-${myinterface}-rx" $iRead)
iSpeedTrans=$(ph.perfdeltaspeed "netio-${myinterface}-tx" $iTrans)
printf "%15s %15s %10s %-10s \n" "receive:" $iRead $iSpeedRead "byte/s" >> "$tmpfile2"
printf "%15s %15s %10s %-10s \n" "transmit:" $iTrans $iSpeedTrans "byte/s" >> "$tmpfile2"
printf "%15s %15s %10s %-10s \n" "receive:" $iRead $iSpeedRead "byte/s"
printf "%15s %15s %10s %-10s \n" "transmit:" $iTrans $iSpeedTrans "byte/s"
# to store data for each interface
if [ $iCountInterfaces -gt 1 ]; then
ph.perfadd "rx-${myinterface}" "$iSpeedRead"
ph.perfadd "tx-${myinterface}" "$iSpeedTrans"
fi
iTotalRead=$iTotalRead+$iSpeedRead
iTotalTrans=$iTotalTrans+$iSpeedTrans
else
ph.setStatus "unknown"
echo "UNKNOWN: the interface ${myinterface} does not exist." >> "$tmpfile2"
fi
done
iTotalRead=$iTotalRead+$iSpeedRead
iTotalTrans=$iTotalTrans+$iSpeedTrans
else
ph.setStatus "unknown"
echo "The interface [${myinterface}] does not exist."
fi
echo "" >> "$tmpfile2"
done
echo
)
# ----- total
if [ $iCountInterfaces -gt 1 ]; then
echo "--- total:"
printf "%15s %10s %-10s \n" "receive:" $iTotalRead "byte/s"
printf "%15s %10s %-10s \n" "transmit:" $iTotalTrans "byte/s"
fi >> "$tmpfile2"
out+=$(
echo "--- total:"
printf "%15s %10s %-10s \n" "receive:" $iTotalRead "byte/s"
printf "%15s %10s %-10s \n" "transmit:" $iTotalTrans "byte/s"
)
fi
ph.perfadd "rx" "$iTotalRead"
ph.perfadd "tx" "$iTotalTrans"
# ----- output
ph.status "Network IO ... IN $(ph.toUnit $iTotalRead M) MB/s >> [host] >> $(ph.toUnit $iTotalTrans M) MB/s OUT"
cat "$tmpfile2"
rm -f "$tmpfile2"
echo "$out"
ph.exit
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment