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/

loops

Example: foreach, for, while, break and continue, on the processes of a Linux.

  • example
  • basics
  • loops
  • foreach
  • while
  • ssh

par banshee1 installation1 version

v1Dernière

Publiée le 27 octobre 2026. First version in this collection.

Loops

The three loops of Keen, foreach, for and while, and the two words that steer them, continue and break, on the processes of a Linux counted by state.

How to read it

  • foreach ($states as $state): one turn per element of the list. foreach ($list as $key => $value) gives the key too (see examples/watches/deviate).
  • continue goes straight to the next turn: the zombies are counted by skipping every other state.
  • for ($i = 0; $i < list.count($states); $i = $i + 1): a counter, its start, its condition, its step. $i++ and $i += 1 do not exist: write $i = $i + 1.
  • while (…): turns as long as the condition holds. break leaves the loop at once: once one stopped process is found, the others need not be read.
  • text.like($state, 'Z*'): does the text follow the pattern, * standing for any characters.
  • A loop never turns forever: the poller counts the turns and stops the collector at its ceiling, saying so.

To adapt it

  • The states of ps are documented in man ps, under "PROCESS STATE CODES": D (waiting for a disk) is often worth counting too.
  • The watch on stopped processes is not checked by default ('enabled' => false): the administrator checks it on the probe.