agent_based_api.v1.render

The “render” namespace adds functions to render values in a human readable way.

All of the render functions take a single numerical value as an argument, and return a string.

date(epoch)

Render seconds since epoch as date

In case None is given it returns “never”.

Return type:

str

datetime(epoch)

Render seconds since epoch as date and time

In case None is given it returns “never”.

Return type:

str

timespan(seconds)

Render a time span in seconds

Return type:

str

disksize(bytes_)

Render a disk size in bytes using an appropriate SI prefix

Example

>>> disksize(1024)
'1.02 kB'
Return type:

str

bytes(bytes_)

Render a number of bytes using an appropriate IEC prefix

Example

>>> bytes(1024**2)
'1.00 MiB'
Return type:

str

filesize(bytes_)

Render a file size in bytes

Example

>>> filesize(12345678)
'12,345,678 B'
Return type:

str

frequency(hertz)

Render a frequency in hertz using an appropriate SI prefix

Return type:

str

networkbandwidth(octets_per_sec)

Render network bandwidth using an appropriate SI prefix

Return type:

str

nicspeed(octets_per_sec)

Render NIC speed using an appropriate SI prefix

Return type:

str

iobandwidth(bytes_)

Render IO-bandwith using an appropriate SI prefix

Return type:

str

percent(percentage)

Render percentage

>>> percent(9.213)
'9.21%'
>>> percent(0.003)
'<0.01%'
>>> percent(-0.003)
'-0.00%'
Return type:

str