From 3819f1cc333beec195bbb0437a8aff88da50f067 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch> Date: Mon, 24 Apr 2023 12:15:38 +0200 Subject: [PATCH] fix units; add doc --- inc_pluginfunctions | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/inc_pluginfunctions b/inc_pluginfunctions index 0e239a3..abc6128 100644 --- a/inc_pluginfunctions +++ b/inc_pluginfunctions @@ -33,6 +33,7 @@ # 2022-10-25 v1.5 <axel.hahn@iml.unibe.ch> handle empty value in ph.perfadd # 2023-01-30 v1.6 <axel.hahn@unibe.ch> check performance params 5+6 and show a warning if missing # 2023-02-16 v1.7 <axel.hahn@unibe.ch> adding a generic min and max value did not really help +# 2024-04-24 v1.8 <axel.hahn@unibe.ch> fix unit conversion # ====================================================================== @@ -268,7 +269,8 @@ function ph._getExp(){ test "$_unit" = "K" && echo 2^10 test "$_unit" = "M" && echo 2^20 test "$_unit" = "G" && echo 2^30 - test "$_unit" = "P" && echo 2^40 + test "$_unit" = "T" && echo 2^40 + test "$_unit" = "P" && echo 2^50 # phyiscal # test "$_unit" = "m" && echo 10^-3 @@ -296,7 +298,7 @@ function ph.toUnit(){ local _divisor=`ph._getExp $_unit` # echo "DEBUG ... $_divisor .. $_multiply" - echo "`echo $_value | tr -d "[:alpha:]" `*${_multiply}/$_divisor" | bc + echo "$(echo $_value | tr -d "[:alpha:]" )*${_multiply}/$_divisor" | bc } @@ -318,6 +320,7 @@ function ph.getFileAge(){ # get file for storage of last value # global string dir_data custom path; default is /tmp/icinga_counter/ +# param string varName variable name of a value to store function ph._getStorefile(){ local varName=$1 @@ -332,6 +335,8 @@ function ph._getStorefile(){ } # save a value - needed for gdAddDeltaData +# param string varName variable name of a value to store +# param * value value as float/ integer function ph._savecounter() { local varName=$1 local value=$2 @@ -341,6 +346,9 @@ function ph._savecounter() { echo ${value} > "${sStoreFile}" } +# get age of last storage of a value +# used in perfdeltaspeed +# param string varName variable name of a value to store function ph._getageoflastvalue() { local varName=$1 local sStoreFile=$(ph._getStorefile "${varName}") @@ -349,6 +357,9 @@ function ph._getageoflastvalue() { # local inow=`date +%s` # echo $(( ${inow}-${ilast}+1 )) } +# get the last value +# used in perfdeltaspeed +# param string varName variable name of a value to store function ph._readlastvalue(){ local varName=$1 local sStoreFile=$(ph._getStorefile "${varName}") -- GitLab