Examples
banshee/examples-collection/examples/basics/
functions
Example: functions of the author, parameters and return, on the memory of a Linux.
par banshee1 installation1 version
Publiée le 27 octobre 2026. First version in this collection.
Functions
A function written once and called four times, and another called twice, on the memory and the swap of a Linux.
How to read it
function kilobytes($meminfo, $name) { … }: a name without a point, its parameters, its body. It is written at the first level of the code, never inside a block, before or after its calls.- A function sees only its parameters: the text of
/proc/meminfois passed to it, it does not read$meminfoof the body. returngives back a value and leaves the function;percentreturns 0 for a host without swap, rather than divide by zero.failworks inside a function as everywhere: a line missing from/proc/meminfostops the collector.- A function never calls itself, directly or through another: the validation refuses it.
To adapt it
kilobytesreads any line of/proc/meminfo:Cached,Dirty,HugePages_Total…- A function name cannot be a word of Keen (
value,fail…) nor the name of a domain (text,http…).