Scripts
The script library holds the scripts you run on your hosts: written once, versioned, run on one host or on a thousand, and run again on a schedule. A run is a batch of jobs, one per host, so it has the same states, approval, audit trail and live output as every other job.
The pages are under Scripts in the top bar:
| Page | What it is for |
|---|---|
| Library | The scripts you may read, with Run, Copy, Edit and Delete. |
| Runs | Every run, with how many hosts are in which state. A run's page lists its jobs and their output. |
| Schedules | Scripts that start by themselves. |
Who may do what
| You want to | You need |
|---|---|
| See a script | Access to the customer the script belongs to; a global script is visible to everyone who reaches any customer |
| Create or change a customer's script | script.edit at that customer |
| Create or change a global script | The administrator role |
| Run a script, stop a run, run the failures again, set up a schedule | script.run at every customer whose hosts are chosen |
| Approve a script version | The right to edit that script, and not being its author |
Permissions are granted per customer, see Users and Permissions. A run over hosts of several customers is refused as a whole if you may not run scripts at one of them; the dialog says which.
An assistant connected through the MCP server can submit a library script as a job, which always waits for approval.
Writing a script
A script has a name, a description and a category, and one or more versions. Each version carries:
- the code, up to 256 KB,
- the language: Bash, POSIX shell, PowerShell or Python,
- the operating system it is for: Linux, Windows or both. Bash and the POSIX shell exist on Linux only, so choosing Windows switches the language to PowerShell,
- a timeout, 10 minutes by default and at most 24 hours; the agent stops the script after that,
- the parameters, see below.
Saving a change to any of these creates the next version. A version never changes afterwards; the Versions tab lists them all with who saved them, their comment and a SHA-256 checksum of the code, and Changes shows what differs from an earlier version: the code line by line, the settings and the parameters. Changing only the name, description or category does not make a version.
A script is global or belongs to one customer. A customer's script is seen only by people who reach that customer. The scope is chosen when the script is created and cannot change; copy the script to move it.
Parameters
A parameter is a typed question asked of whoever runs the script: text, number,
yes or no, a choice from a list, or a secret. It reaches the script as an
environment variable of the same name, always as text: a number in its
decimal form, a yes or no as true or false. A parameter left empty takes its
default; an optional one without a default is left unset rather than set to an
empty string.
Names are letters, digits and underscores. Names that change how the interpreter
or the loader behaves are reserved and refused: PATH, PATHEXT, HOME,
IFS, ENV, TEMP, TMP, TMPDIR, SYSTEMROOT, WINDIR, COMSPEC,
PSMODULEPATH, SHELLOPTS, BASHOPTS and anything starting with LD_,
DYLD_, BASH_ or PYTHON.
Secrets
A secret parameter has no default. Its value is encrypted in the database
with the key described under
Configuration, shown nowhere after it was entered, given to the
script as an environment variable and masked (***) wherever it appears in
the output, even when it arrives split over two writes. The audit log and the run's
page list the names of the secrets that were used, never their values.
A script can still print a secret in a transformed form (reversed, encoded);
masking is a safeguard, not a reason to let a script handle what it should not.
The standard library
Four read-only scripts ship with the dashboard, each as a Linux and a Windows variant, so the library lists eight:
| Script | What it does |
|---|---|
| Clean temporary files | Removes old files from the temporary folders and reports the space freed. A dry run only lists them. |
| Collect diagnostics | Prints system, load, memory, disk, process, service, network and error information and saves it as a report on the host. |
| Flush DNS cache | Empties the local DNS cache. |
| Vacuum the journal / Trim event logs | Shrinks the systemd journal, or archives and empties the Windows event logs, by age and size. |
They are listed with the rest, marked Standard library, translated into the interface language and approved from the start. Nobody edits them, administrators included: copy one to make a script of your own, global or for one of your customers, and change that.
Running a script
Run opens a dialog with the parameters, the hosts and what stands in the way. Run script in a host's row on Infrastructure → Hosts or Access → Hosts opens the same dialog for that one host, after choosing the script from the library. Choose the hosts by:
- Hosts: pick them by name,
- Clusters: every agent host in the clusters,
- Customers: every agent host of the customers,
- Tags: hosts carrying any of the tags, optionally within one customer,
- Filter: hosts matching all of a name, operating system, status, tag and cluster. The filter is evaluated when the run starts, so a schedule over a filter follows the fleet.
Below the selection the dialog shows how many hosts it comes to and why a start would be refused: hosts of the wrong operating system are left out and counted; a customer you may not run scripts for, a customer that asks for four eyes and has not approved this version, and a selection of more than 1,000 hosts block it. Hosts that are waiting for approval to join are never included.
The run goes out as one batch:
- At most 10 hosts at a time by default, changeable per run, so a run over a cluster does not take every node at once.
- Offline hosts wait 24 hours. The jobs stay queued and go out when the host links; after a day they expire and show as Expired.
- Output is kept 90 days, 1 MB per host, like every job's, see Jobs. Only the end of the output is shown while it runs; the whole can be downloaded.
A run's page offers Stop run, which ends jobs that have not started at once and asks the hosts to stop the rest, and Run failures again, which starts a new run of the same version with the same parameters on the hosts that did not succeed. Hosts you stopped by hand are left out. Secrets are carried over encrypted; they are not typed again.
Four eyes
A customer with the Require approval policy (see Users and Permissions) runs only approved versions of a script. A new version of a script is not approved: somebody who may edit the script and did not write that version approves it on the Versions tab. The same policy makes the job engine ask for approval of each job. A customer with Require a reason needs a reason with every run; it goes into the audit log.
What the agent does
A run is a job of the type script.run, and the host must allow it: script has
to be in the actions list of the agent's config.yaml, see
Agent Installation. The agent then
-
checks that the code matches the SHA-256 checksum that was signed with the job, and refuses a script that was altered on the way,
-
writes the code to a file that only its own account can reach,
-
runs it as root, or as SYSTEM on Windows, with the interpreter of the language:
Language Linux Windows Bash, POSIX shell bash,shnot available PowerShell pwshpowershell.exe -NoProfile -ExecutionPolicy Bypass -FilePython python3, elsepythonpython, elsepy -3 -
streams what the script prints back while it runs,
-
at the timeout, or when the run is stopped, asks the script to end and, a few seconds later, kills the whole process group (on Windows the whole job object), so children it started are not left behind,
-
removes the file.
The job succeeds when the script exits with 0. If the interpreter is not installed the job fails at once and says which one is missing. Install it, or choose another language.
Schedules
A schedule runs a script on a selection of hosts without anybody pressing Run. It starts either
- on its own recurrence: every day at a time, on chosen weekdays at a time, or
by a five-field cron expression (
@dailyand the like work too), or - when a maintenance window opens, see Maintenance Windows, for the hosts that window covers. The jobs are held until the window is open.
Times are on the instance's time zone (Settings → General), so "every night at 02:30" stays 02:30 across the change to summer time. A time the clock skips that night happens an hour later.
Nothing polls: the dashboard sleeps until the next time of the schedule and is woken by any change to a schedule or a window. Every instance of a clustered dashboard runs the scheduler and exactly one fires each schedule.
Missed runs. A host that is offline at the scheduled time has the grace period (60 minutes by default, 24 hours at most) to come back; the job waits for it and then expires. In a window, hosts have until the window closes. If the dashboard itself was down at the time, the run is made up when it is back as long as the grace period has not run out. Otherwise the firing is missed: the schedule shows when and why, and an entry goes to the audit log. Other reasons for a missed run are a window that is over or deleted, a schedule whose account was removed or may no longer run scripts, a customer that asks for a reason or for an approved version that does not exist, and parameters that no longer fit the script.
A schedule runs with the rights the account that saved it has at the time it fires, so demoting or deleting that account stops its schedules. It runs the newest version of the script, except for customers that ask for four eyes, where it runs the newest approved one. The values of the parameters are stored with the schedule; its secrets, encrypted. Pause a schedule to stop it without losing it.
Retention
Output is deleted 90 days after the job finished, as set under Settings → Data retention. The run and the version that ran stay; a run keeps its own copy of the script's name, so deleting a script does not erase the record of what ran. Deleting a script removes its versions and schedules, which also means a run of it can no longer be repeated with Run failures again.
API
The scripts API follows the conventions of the HTTP API.
| Request | Does |
|---|---|
GET /api/scripts | The scripts you may see, without code. Filters q, category, os, language, scope, customerId. |
POST /api/scripts | Creates a script with its first version. |
GET /api/scripts/{id} | One script with its latest version and the list of versions. |
PATCH /api/scripts/{id} | Changes name, description and category. |
DELETE /api/scripts/{id} | Deletes the script. |
POST /api/scripts/{id}/versions | Saves the next version; 409 if nothing changed. |
POST /api/scripts/{id}/copy | Copies the script, the standard library included. |
POST /api/scripts/versions/{versionId}/approve | Approves a version for four-eyes customers. |
POST /api/scripts/runs | Starts a run: scriptId, optional versionId, target, values, timeoutSeconds, maxConcurrent, reason. |
POST /api/scripts/runs/{id}/cancel | Stops the run. |
POST /api/scripts/runs/{id}/rerun | Runs the failures again. |
POST /api/scripts/schedules | Creates a schedule. |
PATCH /api/scripts/schedules/{id} | Replaces a schedule, or pauses and resumes it with {"enabled": false}. |
DELETE /api/scripts/schedules/{id} | Deletes a schedule. |
A target is one of {"kind": "systems", "systemIds": [...]},
{"kind": "clusters", "clusterIds": [...]}, {"kind": "customers", "customerIds": [...]},
{"kind": "tags", "tags": [...], "customerId": "..."} or
{"kind": "filter", "filter": {"q", "os", "tag", "clusterId", "status"}, "customerId": "..."}.
Every write is recorded in the audit log as script.* and
script_schedule.*.
Troubleshooting
- A host does not run the script. Its
config.yamlhas noscriptunderactions, or the host is offline: the job waits for 24 hours. - "No host matches" for a selection that names hosts. Hosts of the other operating system are left out, and so are hosts that are not agent hosts.
- The run is refused for a customer. You lack
script.runthere, or the customer asks for four eyes and the version has not been approved, or asks for a reason. - The job fails with a missing interpreter. Install
bash,pwsh,python3or the matching interpreter on the host. - A schedule did not fire. Its row says when it was missed and why.