Command Assistant lets you run routine Operations and Maintenance (O&M) tasks on Simple Application Server instances without logging in to each server. Create reusable commands to automate scripts, poll processes, reset logon passwords, install or uninstall software, update applications, and install patches.
Commands support Shell scripts for Linux servers and Bat and PowerShell scripts for Windows servers. You can define custom parameters using the {{key}} format to set variable values at run time.
Limits
A Base64-encoded script cannot exceed 18 KB in size.
Create a command
Go to the Command Assistant page in the Simple Application Server console.
On the My Commands tab, click Create Command.
In the Create Command panel, configure the following parameters.
Parameter
Description
Command Type
Select the command type. Linux servers support Shell. Windows servers support Bat and PowerShell.
Command Name
Enter a name for the command.
Command
Enter the command content. You can type the content directly, for example, the shell command
ifconfig -sto view brief network interface controller (NIC) information. Alternatively, pressCtrl+Ior right-click the blank area in the Command field and click AI Command Assistant. Follow the on-screen instructions, enter the command content, pressEnter, and then click Insert Command.Used Parameters
Turn on this toggle to define custom parameters in the
{{key}}format in the Command field. Enter values in the Command Parameters field.Command Description
Enter a description that explains the purpose of the command for easier management and maintenance.
Execution Path
Specify a custom execution path. Defaults:
/rootfor Linux instances,C:\Windows\System32for Windows instances.Timeout Period
Set the timeout period in seconds. If a task exceeds this limit, Command Assistant forcefully stops the process. Default: 60 seconds. Valid values: 10 to 86,400 (24 hours).
Tag
Optional. Add tags (Tag Key / Tag Value) to categorize and manage commands.
Click Create Command.
Custom parameter rules
Custom parameters use the {{key}} format, such as {{parameterName}}. The following rules apply:
Maximum number of parameters: 20
Allowed characters: digits and letters
Parameters cannot be empty strings
Maximum length per parameter: 64 characters
To use custom parameters, turn on Used Parameters and enter parameter values in the Command Parameters field.
Common commands
The following examples show common O&M commands. Parameters in the {{key}} format are custom parameters. To use them, turn on Used Parameters and enter the parameter values in the Command Parameters field.
Change the logon password of a server
Run one of the following commands based on the operating system.
Linux:
echo "root:<yourPassword>"|chpasswdWindows:
net user "Administrator" "<yourPassword>"
Replace
<yourPassword>with the new password.The password must be 8 to 30 characters long. It must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. For a Windows instance, the password cannot start with a forward slash (
/).
Add, delete, or modify user information
Add a user and set a password:
useradd -m {{newUser}} && echo "{{newUser}}:{{password}}" | chpasswdChange a password:
passwd {{password}}Delete a user:
userdel {{newUser}}Change a username:
usermod -l {{newUser}} -d /home/{{newUser}} -m {{previousUser}}
Enable, disable, and check the status of the firewall
Enable the firewall:
systemctl start firewalldDisable the firewall:
systemctl stop firewalldCheck the firewall status:
systemctl status firewalld
Install software
This example shows how to install Nginx on a CentOS 7 operating system.
yum -y install nginxInstall the CloudMonitor agent
For more information, see Install and uninstall the CloudMonitor agent.
ARGUS_VERSION=3.5.7 /bin/bash -c "$(curl -s https://cms-agent-cn-hongkong.oss-cn-hongkong-internal.aliyuncs.com/Argus/agent_install_ecs-1.7.sh)"Replace cn-hongkong in the command with the region ID of your Simple Application Server instance. To obtain the region ID, see Regions and zones.
View server system configuration
View basic server configuration:
# Displays information about active network interface cards. ifconfig # Displays information about all network interface cards. ifconfig -a # Displays brief information about network interface cards. ifconfig -s # Views memory information. free -g # Views memory information. cat /proc/meminfo # Views operating system information, such as the kernel version. uname -a # Views disk usage. df -h # Views all hardware information. dmidecode | moreView system process or file information:
# Views information about all processes. ps -ef # Views information about a specific process. {{processName}} is the key of a custom parameter. You must set a value for it when you run the command. ps -ef | grep {{processName}} # Views the details of a file in a path. ls -la {{fileName}} # Finds a file path. find {{path}} | grep {{fileName}}
Manage existing commands
After you create a command, you can view, clone, or delete it from the My Commands tab.
Operation | Description | Steps |
View a command | View the details of an existing command. | 1. In the Actions column, click View Details. 2. In the Command panel, review the command details. |
Clone a command | Create a new command by modifying a few parameters of an existing command. | 1. In the Actions column, click Clone. 2. In the Clone Command panel, modify the parameters and click Clone Command. |
Delete a command | Remove a command that you no longer need. | 1. In the Actions column, choose the more icon > Delete. 2. In the Delete Command dialog box, click Confirm. |
Next steps
After you create a command, run it on one or more instances from the My Commands tab. For more information, see Run command.