Examples
banshee/examples-collection/examples/basics/
conditions
Example: if, elseif, else, comparisons and && || !, on the swap of a Linux.
by banshee1 installation1 version
Published on October 27, 2026. First version in this collection.
Conditions
if, elseif and else, and the operators that compare and combine, on the swap of a Linux summed up in one word: none, unused, light or heavy.
How to read it
if (…) { … } elseif (…) { … } else { … }: the first condition that holds wins;elsetakes the rest. A block is always between braces, even for one line, and one writeselseif, neverelse if.==and!=compare in numbers when both sides are numbers, in texts otherwise.<,>,<=,>=compare numbers.||: one side true is enough.&&: both must be true; the right side is only read when the left one has not decided already, soheavynever divides by a total of zero, the first branch having taken it.!turns true into false and false into true:!text.is_number($total).fail('misconfigured', …)stops the collector when the answer is not the one expected.
To adapt it
- The two thresholds of
heavy(half of the swap, 1 GiB left) are written in the code: they classify, the watch judges. To let the administrator change them, return the figures as numbers and watch them withwatch.above. - The ternary
? :does not exist in Keen: write anif … else.