banshee est en développement actif : les collecteurs vont encore changer, et une version que vous publiez demandera sans doute des ajustements. Pour un usage stable, attendez la 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

par banshee1 installation1 version

v1Dernière

Publiée le 27 octobre 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.