SYSCLI: Scheduling Tasks on the DXi Using the cliadmin Account |
This article explains how customers can leverage the syscli commands available to them while logged in as cliadmin. Which commands are available to a customer depends on the version of firmware they are running.
The CLI guides do a good job at explaining how to run the commands, and at showing their syntax. But they don’t cover how to schedule those tasks remotely. This article will show examples for some of the more frequently requested items that customers want to know how to run.
First some basics…
To see what commands they can run, customers can do the following:
1. ssh to a DXi and log in, using the username cliadmin and the password cliadmin.
2. Run ls –l. This will output a list of the commands available for that firmware version.
3. The syscli command is found at /opt/DXi/syscli, and a symbolic link to that location is located in /home/cliadmin, which is where customers land when they log in.
Customers can discover all the available syscli commands by running
$syscli --help
Note: Customers can pipe this command to grep out certain things they want to see. For example, to see commands related to replication, they can run
$syscli --help |grep replication
The following sections show how customers can use various syscli commands to schedule when tasks are run.
1. Download plink.exe (which allows interactive logins to a remote SSH server) to the machine you want to schedule tasks from. You can get it at the PuTTY Download Page (http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html).
2. Save the file to a location from which to run it, such as C:\ or the desktop.
3. Run the Windows Task Scheduler. How you do this varies for different versions of Windows. The following link shows to run it in Windows Vista:
(http://windows.microsoft.com/en-US/windows-vista/Automate-tasks-with-Task-Scheduler-from-Windows-Vista-Inside-Out)
4. Create your task by setting the Name and Trigger. The Trigger is the frequency with which you want this task to run.
5. Set the Action to “Start a program.”
6. Run plink.exe, using arguments such as the ones shown below.
7. Add the arguments. Here is where to tell plink what to do. Examples:
· 10.20.230.75 -l cliadmin -pw cliadmin syscli --sync nas --name eric_nas
· 10.20.230.75 -l cliadmin -pw cliadmin syscli --disablerep vtl –name eric_vtl ç Pause replication
· 10.20.230.75 -l cliadmin -pw cliadmin syscli --enablerep vtl –name eric_vtl ç Resume replication
(You might run the last two commands to stop continuous replication traffic during certain hours.)
· 10.20.230.75 -l cliadmin -pw cliadmin syscli --start reclamation
Note: With certain older versions of Windows Task Scheduler, you can put everything on one line, rather than running plink.exe and then adding arguments, for example:
C:\plink 10.20.230.75 -l cliadmin -pw cliadmin syscli -- sync nas --name eric_nas
Customers can also remotely schedule when tasks are run on a Linux/UNIX system. The following discussion lists two methods. The first uses public authentication keys, while the second requires the customer to install a program called sshpass. The tricky part is passing the cliadmin password to the remote DXi, as shown above when using Windows and plink.exe.
Note: Method 1 is more secure, since Method 2 transfers the password in clear text.
On the customer server:
1. Generate the RSA key (#ssh-keygen -t rsa). This will create a file with a randomly generated filename in the user’s /home/[username]/.ssh/id_rsa.pub directory.
2. When instructed to do so below, copy the contents of that file into a file called authorized_keys, which you will create on the DXi.
On the DXi:
1. Log in as cliadmin.
2. Create a file named authorized_keys (bash-3.2$ vi authorized_keys).
3. Paste the contents of the file in the /home/[username]/.ssh/id_rsa.pub directory on the customer server into the authorized_keys file, and save the file. The key will look something like this:
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAub7f9Gh/ts0IXDE3egguTPV92NXFM/kHGW1gxi/yG23mjTb59zo9MS1psg39586DSVvB6twTIYmmwp3Va5ic19op5xAGLd9BFf
uvya/zScjQekTmXQgui+idDSk1WPkCAvzeMNW+59/BZuhj8t4zTa/VaQb8I0q+bXdkDwnn5Ox9w8jQGW2qiMtgkQSIGDELjQdoFhgPRNneakRcmdD9U3ECkFDf9YfFN9Fr9Fd
0s6r9sZa8stWKFGvxDhmn3/HZM1/UWkPwkFy607eCfC0ifwLXU6TgXrfnuU5ojISe/0y8bNI/WRgGxvK37FRW+tbq1avYHFId2fFF3GJJ4lU2SQ== root@BLUE-DXi0v220
Using ssh to Connect from the Customer Server to the DXi
The customer should now be able to ssh from the customer server to the DXi without entering a password. From here, all the customer needs to do is schedule a command in crontab that looks like this:
00 14 * * 0 ssh 10.20.234.84 -l cliadmin syscli --sync nas --name eric_nas ç Run every 2 pm on Sundays
00 08 * * 2 ssh 10.20.234.84 -l cliadmin syscli --start reclamation ç Run at 8 am on Tuesdays
A Note About crontab Syntax
A crontab file has five fields for specifying the day, date and time, followed by the command to be run at that interval.
* * * * * command to be executed
- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)
A Note About syscli -- help
To find out what syscli commands are available, customers can run syscli --help remotely from their server:
#ssh 10.20.234.84 -l cliadmin syscli --help
1. Install sshpass, if you do not already have it on your Linux/UNIX server.
2. Examples of lines to add to crontab:
00 14 * * 0 sshpass -p DXi password ssh 10.20.234.84 -l cliadmin syscli --sync nas --name eric_nas
00 08 * * 2 sshpass -p cliadmin ssh cliadmin@10.20.234.84 syscli --start reclamation
Notes:
· I personally have not used this method, but once the customer has installed sshpass, the customer should be able to schedule tasks by using Method 2.
· Both of the syntax examples shown above the work the same way as the earlier examples, with regard to username and host: [username]@[host] or [host] -l [username].
Attachments |
This page was generated by the BrainKeeper Enterprise Wiki, © 2018 |