beetlebug▾
/

ztcl::sysinfosysinfo

Reads the processors, the memory, the processes, the disks, the network, the GPUs, and the battery of the host.

ztcl::sysinfo SUBCOMMAND ?ARG ...?

Description

The numbers of the machine for a monitor such as top. One call of sample gives one sample as a dict. The counters stay raw and grow from the boot, so the caller computes each rate from two samples. A field that the OS cannot give is absent, and the key missing gives the reason.

The command is not a package: it exists when the embedder turns on the capability sysinfo, and it is absent otherwise. It only reads, and it reads no file of the root folder. Its values depend on the host, so the capability is off by default. The list of processes shows the names of the other programs of the user, and with -detail their command lines.

macOS has a backend today. On Linux and Windows a sample gives os and a reason for each other field, until their backends ship (ztcl#1413, ztcl#1415).

ztcl::sysinfo::sample is the same command as ztcl::sysinfo sample. A unique prefix of a subcommand names the subcommand. An unknown or ambiguous subcommand gives TCL LOOKUP SUBCOMMAND with the word at the end.

Subcommands

SubcommandDescription
ztcl::sysinfo sampleGives one sample of the host as a dict.

Returns

The result of the subcommand.

Examples

% dict exists [ztcl::sysinfo sample -parts os] os
1

% expr {[dict get [ztcl::sysinfo sample -parts os] os] in {linux macos windows}}
1

Errors

% ztcl::sysinfo nope
unknown or ambiguous subcommand "nope": must be sample
-errorcode TCL LOOKUP SUBCOMMAND nope

% ztcl::sysinfo
wrong # args: should be "ztcl::sysinfo subcommand ?arg ...?"
-errorcode TCL WRONGARGS

Facts

Capability
sysinfo. A new interpreter does not have it until the host turns it on.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.10

The full page: ztcl::sysinfo.

See also