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/mechanics/

lists

Example: arrays and the list tools, count, has, get, add; the TCP ports a Linux listens on.

  • example
  • list
  • array
  • ports
  • ssh

by banshee1 installation1 version

v1Latest

Published on October 27, 2026. First version in this collection.

Lists

Building and reading arrays, and the tools of the list domain, on the TCP ports a Linux listens on, against those expected.

How to read it

  • $ports = array();: an empty array. An array is a value: passing it to a function or another variable copies it.
  • $ports[$m[2]][$m[1]] = true;: writing under a key that is missing creates it, and what is missing above it. The variable itself must exist first.
  • list.count: the number of elements. list.has($ports, $port): is there an element under this key. list.get($closed, 0, ''): the element, or the default when the key is missing.
  • list.add($closed, $port): the list with one more element at its end. $a[] = $x does not exist in Keen.
  • A key is a text: $ports[22] and $ports['22'] are the same element.

To adapt it

  • foreach ($ports as $port => $addresses) goes over the keys and the values (see examples/watches/deviate).
  • To return one value per port, declare a per (see examples/mechanics/selection).