banshee is under active development: collectors will keep changing, and a version you publish will likely need adjustments. For stable use, wait for version 1.0.0.

Examples

banshee/examples-collection/examples/basics/

conditions

Example: if, elseif, else, comparisons and && || !, on the swap of a Linux.

  • example
  • basics
  • if
  • conditions
  • ssh

by banshee1 installation1 version

v1Latest

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; else takes the rest. A block is always between braces, even for one line, and one writes elseif, never else 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, so heavy never 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 with watch.above.
  • The ternary ? : does not exist in Keen: write an if … else.