cmk.agent_based.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.
- bytes(bytes_)
Render a number of bytes using an appropriate IEC prefix
- Return type:
str
Example
>>> bytes(1024**2) '1.00 MiB'
- date(epoch)
Render seconds since epoch as date
- Return type:
str
Example
>>> date(None) 'never' >>> _ = date(1606721022)
The latter will return something like ‘2020-11-30’, depending on the time zone.
- datetime(epoch)
Render seconds since epoch as date and time
- Return type:
str
Example
>>> datetime(None) 'never' >>> _ = datetime(1606721022)
The latter will return something like ‘2020-11-30 07:23:42’, depending on the time zone.
- disksize(bytes_)
Render a disk size in bytes using an appropriate SI prefix
- Return type:
str
Example
>>> disksize(1024) '1.02 kB'
- filesize(bytes_)
Render a file size in bytes
- Return type:
str
Example
>>> filesize(12345678) '12,345,678 B'
- frequency(hertz)
Render a frequency in hertz using an appropriate SI prefix
- Return type:
str
Example
>>> frequency(1e10 / 3.) '3.33 GHz'
- iobandwidth(bytes_)
Render IO-bandwith using an appropriate SI prefix
- Return type:
str
Example
>>> iobandwidth(128) '128 B/s'
- 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
Example
>>> nicspeed(1050) '8.4 kBit/s'
- percent(percentage)
Render percentage
- Return type:
str
Example
>>> percent(23.4203245) '23.42%' >>> percent(0.003) '<0.01%' >>> percent(-0.003) '-0.00%'
- timespan(seconds)
Render a time span in seconds
unaware of leap-years…
- Return type:
str
Example
>>> timespan(1606721) '18 days 14 hours' >>> timespan(0.0001) '100 microseconds' >>> timespan(24*60*60) '1 day 0 hours' >>> timespan(365*24*60*60) '1 year 0 days' >>> timespan(100*365*24*60*60) '100 years 0 days'