Examples
banshee/examples-collection/examples/basics/
loops
Example: foreach, for, while, break and continue, on the processes of a Linux.
by banshee1 installation1 version
Published on October 27, 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 (seeexamples/watches/deviate).continuegoes 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 += 1do not exist: write$i = $i + 1.while (…): turns as long as the condition holds.breakleaves 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
psare documented inman 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.