Control and query System Launch and Monitor
(slm)
Syntax:
slmctl [-n subsystem_path] "command [component]"...
Options:
- -n subsystem_path
- Set the access point that client applications write control and query commands to.
Should match the path specified by the slm option
-n. Default is /dev/slm.
- command [component]
- A quoted string that specifies a control or query command and, optionally, a
component or module name. For descriptions, see Control and query commands.
Description:
Client
applications can send SLM control and query commands via the
slmctl utility (on the command line or typed interactively)
or by directly writing the commands to the /dev/slm interface.
Note:
Only the system superuser (UID 0) can execute the commands.
Control and query commands
Control
commands can
start,
stop, or
restart a specified module or component. When you start a
component, SLM starts any dependencies (that aren't already running) and waits for
them as required. When you stop a component, SLM first stops any dependencies.
Restarting is the following sequence of stop and start operations:
- The component's dependents are stopped.
- The component itself is stopped.
- The component is started.
- The component's dependents that can be started are started.
Query commands can be used to obtain information about the current state
and dependencies of components.
Control commands
For option descriptions, see
Command options
- start [-dv]
- Start the specified component.
- stop [-sv]
- Stop the specified component.
- restart [-dsv]
- Stop, then start the specified component.
Query commands
For option descriptions, see
Command options
- active [-v][-p
pid]
- List all components that are active.
- dead [-v]
- List all components whose state is DEAD.
- inactive [-v]
- List all components that are inactive.
- initialized [-v]
- List all components whose state is INITIALIZED.
- listall [-v]
- List all components and their states.
- needs [-v component]
- List all components that this component depends on.
- starting [-v]
- List all components whose state is STARTING.
- stopping [-v]
- List all components whose state is STOPPING.
- usedby [-v component]
- List all components that depend on this component.
- waiting [-v]
- List all components whose state is WAITING.
Command options
- -d
- Debug mode: start components with their debug argument list.
- -p
pid
- Only display information for the process with the specified ID. Used only
with active.
- -s
- Stateless: ignore any stateless dependencies when stopping components.
- -v
- Verbose: give details of each action performed when responding to a
command.
Examples
slmctl "stop ssh" "start network-init"
Command example
Following execution of a command written to
/dev/slm, the results are
available to be read from the same file descriptor. Here's a simple example (with no
error handling):
int slm;
char text[128];
slm = open("/dev/slm", O_RDWR);
write(slm, "start -v all", 12);
while (read(slm, text, sizeof(text)) > 0)
printf("%s\n", text);
close(slm);
Output
The
slmctl utility emits output from the query commands but not
the control commands.
A query command queries the current state of an SLM component and can immediately
return a complete set of information.
The control commands cause a sequence of actions to be executed that can,
theoretically, take a long time. To avoid causing slmctl to
"hang" as it waits for SLM to produce output, SLM logs the output from control
commands to stdout or the system logger, using the verbosity
level that was specified when SLM started.
For query commands, the slmctl utility displays a list of
components that correspond to the specified query (e.g., for the
active query, a list of active components) with one component
name on each line.
If you specify -v, it displays additional information on each line
using the following format:
command
active
state [pid]
where:
- command is the command string specified for the component
in the configuration file.
- active is either ACTIVE or
INACTIVE.
- state is one of the following values: DEAD,
INITIALIZED, STARTING, STOPPING,
WAITING.
- pid is the process ID of the associated running process,
if the component has one.