Executing Custom Shell Commands through Bright Cluster Manager

    

Bright Cluster Manager includes an interactive shell known as CMSH. Owing to personal preference, or the task at hand, Bright admins might choose the Command-Line Interface (CLI) for cluster management rather than the Bright GUI.

To illustrate this choice, considered here is a Bash script called listusernamesfromexcel. When run, this script provides the daily listing of new users to be added to the cluster. From the perspective of CMSH, listusernamesfromexcel is an example of a custom command.

Bright Cluster Manager supports custom commands external to CMSH and internal to CMSH. In addition to illustrating each of these cases here, usage guidelines are provided.

External to CMSH

First, consider custom commands external to CMSH.

If the custom command is an executable from the main operating system shell (Bash, C shell or other), it can be run through use of the shell escape character "!". For example, the script listusernamesfromexcel can be easily accessed in CMSH using the "!" prefix:

[bright61->user]% !listusernamesfromexcel

As a consequence, listusernamesfromexcel is run in a subshell. (Note that "!" on its own opens up a subshell).

If frequent use of the script is to be made, it may be aliased through the operating system’s shell - i.e., typically Bash (or .bashrc or .bash_profile to make the alias persistent). Of course, introduction of a catchy acronym like lunfe (listusernamesfromexcel) is another option; in this case, the script can be easily accessed in CMSH as follows:

[bright61->user]% !lunfe

In the simplest sense, then, `external' means CMSH has no context for the command being issued.

Internal to CMSH

Context-awareness is a characteristic of the internal-to-CMSH case, as CMSH is literally being extended to include the custom command.

To alias within CMSH, simply place the custom command in a file called <custom_command>.cmsh. Ensure that this file is located in the ~/.cm/cmsh directory, such that the full pathname for the custom command is ~/.cm/cmsh/<custom_command>.cmsh.

Using the listusernamesfromexcel example from the previous case, aliasing within CMSH involves creation of the file lunfe.cmsh with !lunfe as its content. After restarting CMSH, the custom command becomes available as:

[bright61->user]% lunfe

Note that the custom command lunfe exists within the same shell scope as the CMSH commands - i.e., internal to CMSH. In other words, internal-to-CMSH custom commands should not be invoked in a subshell through use of the “!” shell escape character.

Now that lunfe is `known’ to CMSH, it can be aliased within CMSH. For example, suppose listusernamesfromexcel accepts the argument thismonth to list new users added to the cluster this month. The CMSH-specific alias lunmth can be established with:

bright61->user]% alias lunmth lunfe thismonth

The lunmth alias can be made permanent by adding it to ~/.cm/cmsh/.cmshrc.

CMSH-aware custom commands may be introduced for reasons of:

  • Usability - To avoid use of the “!” character altogether.
  • Modularity - To maintain a clear separation between capabilities intended for operating-system versus cluster management.
  • Authenticity - To ensure use of a known script with known behaviors. Note that custom commands defined in this way benefit from the security measures specific to Bright Cluster Manager.
  • Locality - To introduce a capability that is available to both on premise as well as cloud-extended clusters.

CMSH is the interactive shell made available to admins through Bright Cluster Manager. CMSH enables for the cluster what Bash (and similar) does for individual systems. Like Bash, CMSH is highly customizable. For rapid results, and infrequent usage, use of customized commands external to CMSH makes sense. In less tactical contexts, the extra effort of extending CMSH through the definition of a custom command is appropriate and worthwhile.

Note: This post is based on the ninth most popular FAQ in the Bright Cluster Manager Knowledge Base. (To view the other nine FAQs in this Top 10 list, go to the FAQ Home area of The Bright Knowledge Base and look for the “Most popular FAQs” column on the right.) The Bright Knowledge Base is a substantial and authoritative resource for assistance in managing clusters via the Bright Cluster Manager. With numerous contributions from Bright users as well as Bright Computing, this Knowledge Base complements resources like the extensive and comprehensive Bright Administrator Manual.

High Performance Computing eBook