Skip to content

Script / EXE (script) ​

Runs a program from the script directory of the Probeward host and reads its result. The result is in Probeward's own JSON format, or in the JSON or XML format of the incumbent's custom sensors, so existing scripts can be reused by choosing the format. Read Scripts, plugins and the security model first: it says how to switch the feature on, where programs live, and what protects the host.

Only administrators can attach or change this sensor, and nothing runs until the administrator of the Probeward host sets PROBEWARD_SCRIPT_DIR.

Channels ​

KeyNameUnitDefault limits
run_msRun timemswarning above 10000
one per channel the program reportsits name (its key if it gave none)its unitnone. Set limits on the sensor.

run_ms is reserved: a program that reports it fails the poll.

Parameters ​

ParameterDefaultMeaning
filerequiredThe program's file name inside the script directory. A name only: no /, no \, no leading dot; letters, digits, ., _, - and +.
outputrequirednative_json, incumbent_json or incumbent_xml.
argsnoneUp to 32 arguments of at most 1024 bytes, passed one by one. {address} and {hostname} are replaced by the device's address and host name.
pass_secretfalseHand the sensor's secret credential to the program in the environment variable PROBEWARD_SECRET.

Suggested interval: 300 seconds. Credential: an optional secret, used when pass_secret is on.

The program also gets PROBEWARD_ADDRESS and PROBEWARD_HOSTNAME. It runs in the script directory with PATH=/usr/local/bin:/usr/bin:/bin, LC_ALL=C, no standard input, and nothing else from Probeward's environment. Its exit status must be 0; any other status is a collection failure whose message holds the first line of what the program wrote.

The native format ​

A JSON object on standard output:

json
{
  "status": "ok",
  "message": "3 jobs late",
  "channels": [
    {"key": "late_jobs", "name": "Late jobs", "value": 3, "unit": "jobs"},
    {"key": "oldest_s", "value": null}
  ]
}
FieldMeaning
statusok (default), warning or down. The sensor's own verdict, on top of any limits you set.
messageA short text, shown in the sensor and in notifications.
channelsUp to 64 readings. key is 1 to 40 characters of a-z, 0-9 and _, unique, and stable: history is stored under it. value is a finite number, or null for unknown. name (default: the key) and unit are for people: see where names and units come from.
errorA non-empty string makes the poll a collection failure with that text. Use it when the program could not do its job. Nothing else is read then.

Where names and units come from ​

The template knows only run_ms, so the name and unit of every other channel are the ones the program reported on its latest poll. Probeward keeps the latest name and unit it saw for each channel key, per sensor, and shows them in the channel table, the graphs, the value summary in the tree and the limits editor. The key stays the identity of the channel: history is stored under it, and a changed name or unit never relabels what was recorded. A channel that has stopped being reported stays listed until newer ones push it out (a sensor remembers up to 100 channels), so its limits can still be edited.

The text is untrusted. Names are cut to 80 characters and units to 16, control characters are removed, and both are shown as plain text only. A unit Probeward formats is shown the way the interface shows it (s, ms, B, %, °C: seconds, milliseconds, bytes, percent and celsius are read as those); any other unit is shown as written. A channel given neither a name nor a unit is listed by its key. The template wins over a program: a program cannot rename run_ms.

The incumbent's custom sensor result format ​

A script written for the incumbent's custom sensors can print its result as it always did, and the sensor reads it with output set to incumbent_json or incumbent_xml. This is a claim about the format only; scripts that need a particular runtime still need that runtime on the probe host (see scripts.md).

The JSON form is an object that holds a result list, text and error, either at the top or inside one wrapper object (whatever its name). The XML form is a root element, whatever its name, holding result elements, text and error.

FieldRead as
channelThe channel's name, shown as it is. The key is made from it: lower case, letters and digits, _ between them, at most 40 characters (Free space (C:) becomes free_space_c). Two channels with the same key get _2, _3. Keep the names stable: the key is the history.
valueA number or a numeric string. A comma decimal is accepted. Anything else is unknown.
unit, customunitThe unit shown with the channel: Percent is %, TimeResponse is ms, TimeSeconds is s, the byte units are B, Temperature is °C, Count is #; Custom uses customunit. Anything else is shown as written.
floatAccepted and ignored: a value with a decimal point is a decimal.
limitmode, limitmaxerror, limitmaxwarning, limitminerror, limitminwarning, limiterrormsg, limitwarningmsgWith limitmode on, a value beyond an error limit makes the sensor Down and beyond a warning limit Warning, with the limit message in the sensor's message. These are hints from the script; Probeward's own limits per channel work on top.
warningWhen on, the channel's presence makes the sensor Warning.
textThe sensor's message.
error1, true or a text: the poll is a collection failure, with text (or the error text) as the message.
valuelookup, mode, showchart, showtable, decimalmode, volumesize, speedsize, speedtime, notifychanged and other display fieldsIgnored. A value lookup is not applied: use a value map on the sensor instead.

Not accepted: XML with a DOCTYPE (so no entity tricks), more than 64 channels, or more than 2000 XML elements.

Failures ​

MessageMeaning
running scripts and plugins is switched off: set PROBEWARD_SCRIPT_DIR ... (kind config)The feature is off on this host.
there is no file named ... in the script directory, ... is not executable, ... is a link that leaves the script directory and is refused (kind config)Fix the directory.
Probeward is running as root and refuses to run scripts (kind config)Run Probeward as an unprivileged user.
... did not finish within N ms and was stopped (kind timeout)The program, and what it started, were killed.
... wrote more than 256 KiB to standard output and was stopped (kind protocol)The output limit.
... exited with status N: <first line> (kind protocol)The program failed.
the output of ... could not be read: ... (kind protocol)The output does not follow the format; the message says where.
... reported an error: <text> (kind protocol)The program said so.

AGPL-3.0-only