PNP Helper functions are meant to simplify the creation of templates. In contrast to the rrd helper functions they don't call existing RRDtool functions.
(string,number,string,number) pnp::adjust_unit ( $value, $base=1000, $format='%.3lf' )
The purpose of this function is to “normalize” large numbers. Modern hard disks have reached sizes of several GB or TB and looking at numbers like 1521073648234 you begin to count the digits so it would be more convienient to translate the value. The same applies to network traffic.
The function takes up to three parameters and returns an array with four elements in any case.
$size = pnp::adjust_unit(1521073648234,1024,'%7.3lf');
Please note that “$size” is an array consisting of four fields:
$size := " 1.383 T"
contains the formatted value including the unit
$size := "1.383"
contains the formatted number
$size := "T"
contains the unit
$size := "1099511627776"
contains the divisor
Assuming check_disk returns “MB” as UOM you can append that as well
$disk = pnp::adjust_unit("1524MB",1024,'%7.3lf');
will result in $disk := “1.448 GB”