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

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

netio shows network speed 2 digits after "."

See merge request !143
parents 519c6efe 179a3704
Branches
No related tags found
1 merge request!143netio shows network speed 2 digits after "."
......@@ -8,6 +8,7 @@
# 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
# 2023-08-22 v1.3 <axel.hahn@unibe.ch> show status line with 2 digits after "."
# ======================================================================
......@@ -133,7 +134,7 @@ 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"
ph.status "Network IO ... IN $(ph.toUnit $iTotalRead M 2 ) MB/s >> [host] >> $(ph.toUnit $iTotalTrans M 2 ) MB/s OUT"
echo "$out"
......
......@@ -37,6 +37,7 @@
# 2023-05-05 v1.9 <axel.hahn@unibe.ch> user specific counter directory
# 2023-05-17 v1.10 <axel.hahn@unibe.ch> ph.getOS searches in os-release first
# 2023-06-22 v1.11 <axel.hahn@unibe.ch> fix ph.toUnit with float values; shell fixes
# 2023-08-24 v1.12 <axel.hahn@unibe.ch> toUnit got 3rd param for count of digits after "."
# ======================================================================
......@@ -293,15 +294,24 @@ function ph._getExp(){
#
# param string value with optional single letter for unit, i.e. 12M
# param char target unit
# param integer count of digits after "."; default: none (=integer value)
function ph.toUnit(){
local _value=$1
local _unit=$2
local _digits=${3:-0}
local _multiply; _multiply=$( ph._getExp "$_value" )
local _divisor; _divisor=$( ph._getExp "$_unit" )
# echo "DEBUG ... $_divisor .. $_multiply"
echo "$(echo "$_value" | tr -d "[:alpha:]" )*${_multiply}/$_divisor" | bc
local _bc
_bc="bc"
local _dots
test $_digits -gt 0 && _dots=$( yes "." | head -$_digits | tr -d "\n" )
test $_digits -gt 0 && _bc+=" -l | grep -o '.*\\.${_dots}'"
echo "$(echo "$_value" | tr -d "[:alpha:]" )*${_multiply}/$_divisor" | eval "$_bc" | sed "s#^\.#0.#"
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment