varlinkctl
(1)Introspect with and invoke Varlink services
Options
12--moreWhen used with call: expect multiple method replies. If this flag is set the method call is sent with the more flag set, which tells the service to generate multiple replies, if needed. The command remains running until the service sends a reply message that indicates it is the last in the series (or if the configured timeout is reached, see below). This flag should be set only for method calls that support this mechanism. If this mode is enabled output is automatically switched to JSON-SEQ mode, so that individual reply objects can be easily discerned. This switch has no effect on the method
-EA shortcut for --more --timeout=infinity. This switch is useful for method calls that implement subscription to a continuous stream of updates. Added in version 257.
--collectThis is similar to --more but collects all responses in a JSON array, and prints it, rather than in JSON_SEQ mode. Added in version 256.
--onewayWhen used with call: do not expect a method reply. If this flag is set the method call is sent with the oneway flag set (the command exits immediately after), which tells the service not to generate a reply. Added in version 255.
--jsonMODESelects the JSON output formatting, one of "pretty" (for nicely indented, colorized output) or "short" (for terse output with minimal whitespace and no newlines), defaults to "short". Added in version 255.
-jEquivalent to --json=pretty when invoked interactively from a terminal. Otherwise equivalent to --json=short, in particular when the output is piped to some other program. Added in version 255.
-q--quietSuppress output of method call replies. Added in version 257.
--gracefulTakes a qualified Varlink error name (i.e. an interface name, suffixed by an error name, separated by a dot; e.g. "org.varlink.service.InvalidParameter"). Ensures that if a method call fails with the specified error this will be treated as success, i.e. will cause the varlinkctl invocation to exit with a zero exit status. This option may be used more than once in order to treat multiple different errors as successes. Added in version 257.
--timeoutExpects a timeout in seconds as parameter. By default, a timeout of 45s is enforced. To turn off the timeout specify "infinity" or an empty string. Added in version 257.
--no-pagerDo not pipe output into a pager.
-h--helpPrint a short help text and exit.
--versionPrint a short version string and exit.
DESCRIPTION
varlinkctl may be used to introspect and invoke Varlink[1] services.
Services are referenced by one of the following:
For convenience, these two simpler (redundant) service address syntaxes are also supported:
COMMANDS
The following commands are understood:
info ADDRESS
Added in version 255.
list-interfaces ADDRESS
Added in version 255.
list-methods ADDRESS [INTERFACE...]
Added in version 257.
introspect ADDRESS [INTERFACE...]
Added in version 255.
call ADDRESS METHOD [ARGUMENTS]
The reply parameters are written as JSON object to STDOUT.
Added in version 255.
validate-idl [FILE]
Added in version 255.
help
Added in version 255.
EXAMPLES
Example 1. Investigating a Service
The following three commands inspect the "io.systemd.Resolve" service implemented by systemd-resolved.service(8), listing general service information and implemented interfaces, and then displaying the interface definition of its primary interface:
$ varlinkctl info /run/systemd/resolve/io.systemd.Resolve
Vendor: The systemd Project
Product: systemd (systemd-resolved)
Version: 254 (254-1522-g4790521^)
URL: https://systemd.io/ Interfaces: io.systemd
io.systemd.Resolve
org.varlink.service $ varlinkctl list-interfaces /run/systemd/resolve/io.systemd.Resolve io.systemd io.systemd.Resolve org.varlink.service $ varlinkctl introspect /run/systemd/resolve/io.systemd.Resolve io.systemd.Resolve interface io.systemd.Resolve type ResolvedAddress(
ifindex: ?int,
...
(Interface definition has been truncated in the example above, in the interest of brevity.)
Example 2. Invoking a Method
The following command resolves a hostname via systemd-resolved.service(8)'s ResolveHostname method call.
$ varlinkctl call /run/systemd/resolve/io.systemd.Resolve io.systemd.Resolve.ResolveHostname '{"name":"systemd.io","family":2}' -j
{
"addresses" : [
{
"ifindex" : 2,
"family" : 2,
"address" : [
185,
199,
111,
153
]
}
],
"name" : "systemd.io",
"flags" : 1048577
}
Example 3. Investigating a Service Executable
The following command inspects the /usr/lib/systemd/systemd-pcrextend executable and the IPC APIs it provides. It then invokes a method on it:
# varlinkctl info /usr/lib/systemd/systemd-pcrextend
Vendor: The systemd Project
Product: systemd (systemd-pcrextend)
Version: 254 (254-1536-g97734fb)
URL: https://systemd.io/ Interfaces: io.systemd
io.systemd.PCRExtend
org.varlink.service # varlinkctl introspect /usr/lib/systemd/systemd-pcrextend io.systemd.PCRExtend interface io.systemd.PCRExtend method Extend(
pcr: int,
text: ?string,
data: ?string ) -> () # varlinkctl call /usr/lib/systemd/systemd-pcrextend io.systemd.PCRExtend.Extend '{"pcr":15,"text":"foobar"}' {}
Example 4. Invoking a method remotely via SSH
The following command acquires a report about the identity of a remote host "somehost" from systemd-hostnamed.service(8) by connecting via SSH to the AF_UNIX socket the service listens on:
# varlinkctl call ssh-unix:somehost:/run/systemd/io.systemd.Hostname io.systemd.Hostname.Describe '{}'
To invoke a Varlink service binary directly on the remote host, rather than talking to a service via AF_UNIX can be done like this:
# varlinkctl call ssh-exec:somehost:/usr/bin/systemd-creds org.varlink.service.GetInfo '{}'