1. Home
  2. Docs
  3. ClusterControl
  4. User Guide (CLI)
  5. s9s-script

s9s-script

Manage and execute Advisor scripts available in the Developer Studio.

Usage

s9s script {command} {options}

Command

Name, shorthand Description
−−tree Prints available scripts on the controller in a tree-like format.
−−execute Executes a script from a local file.
−−system Executes a shell command or an entire shell script on the nodes of the cluster showing the output of the command as job messages. See Shell Command.
−−tree Print the names of the scripts stored on the controller in tree format.

Options

Name, shorthand Description
−−cluster-id=ID The target cluster-ID.
−−cluster-name=NAME, -n The target cluster name.
--shell-command Executes a shell command with --system flag. See Shell Command.
--timeout The timeout value when executing the command/script in seconds, default is 10 seconds. If the command/script keeps running, the job will be failed and the execution of the command(s) is aborted.

Shell Command

If the --shell-command option is provided, the options argument will be executed. If a file name is provided as a command-line argument the content of the file will be executed as a shell script. If neither found in the command line the s9s will read its standard input and execute the lines found as a shell script on the nodes (this is the way to implement self-contained remote executed shell scripts using a shebang).

Please note that this will be a job and it can be blocked by other jobs running on the same cluster.

$ s9s script \
        --system \
        --log \
        --cluster-id=1 \
        --shell-command="df -h"

The command/script will be executed using the pre-configured OS user of the cluster. If that user has no superuser privileges the Sudo utility can be used in the command or the script to gain superuser privileges.

By default the command/script will be executed on all nodes, all members of the cluster except the controller. This can be changed by providing a node list using the --nodes command-line option.

To execute shell commands the authenticated user has to have executed privileges on the nodes. If the executive privilege is not granted the credentials of another Cmon User can be passed in the command line or the privileges can be changed (see s9s-tree for details about owners, privileges, and ACLs).

$ s9s script \
        --system \
        --cmon-user=system \
        --password=mysecret \
        --log \
        --cluster-id=1 \
        --timeout=2 \
        --nodes='192.168.0.127;192.168.0.44' \
        --shell-command="df -h"

Please note that the job will by default has a 10 seconds timeout, so if the command/script keeps running the job will be failed and the execution of the command(s) aborted. The timeout value can be set using the --timeout command-line option.

Examples

Print the scripts available for cluster ID 1:

$ s9s script --tree --cluster-id=1

Execute a script called test_script.sh on all nodes in the cluster with ID 1:

$ s9s script \
        --system \
        --log \
        --log-format="%M\n" \
        --timeout=20 \
        --cluster-id=1 \
        test_script.sh

Get the disk space summary of host 192.168.0.127 and 192.168.0.44 in cluster ID 1:

$ s9s script \
        --system \
        --log \
        --cluster-id=1 \
        --timeout=2 \
        --nodes='192.168.0.127;192.168.0.44' \
        --shell-command="df -h"
Was this article helpful to you? Yes No