Open.ControlTier > ModuleForge
 

shellutil

various shell utilities

Overview

Open in Workbench shellutil: various shell utilities

This module contains a set of commands useful for managing system processes.

Design

Super Type
Managed-Entity
Role Abstract. (Objects cannot be created.)
Instance Names Unique
Notification false
Template Directory
Data View Children, proximity: 1
Logger Name shellutil

Constraints

None

Attributes

None

Commands

Note
Commandline options displayed in square brackets "[]" are optional. If an option expects arguments, then angle brackets are shown after the option "<>". Any default value is shown within the brackets.

env

get environment info

The env command looks up values of environment variables. Use the -key option to specify a particular key to lookup. If no key option is specified all environment variables are printed.

Format: Uses YAML to print lookup results.

Example: Print the value of the CTL_BASE variable

	    $ ctl -m shellutil -c env -- -key CTL_BASE
	    --- 
	    CTL_BASE: /ctier/ctl
	  

static: This command can be run outside of an object context.

Usage
env [-key <.*>] [-output <>]

Options

Option Description
key env key
output output file

exec

executes a command

static: This command can be run outside of an object context.

Usage
exec [-argline <>] -executable <> [-failonerror <false>] [-os <>] [-output <>] [-script <>] [-scriptfile <>] [-timeout <>]

Options

Option Description
argline arguments for execututable
executable executable path
failonerror fail if there is an error
os list of Operating Systems on which the command may be executed.
output Name of a file to which to write the output. If the error stream is not also redirected to a file or property, it will appear in this output.
script script to execute
scriptfile scriptfile to execute
timeout Stop the command if it doesn't finish within the specified time

kill

kill process

static: This command can be run outside of an object context.

Usage
kill -pid <> [-sig <TERM>]

Options

Option Description
pid process id
sig signal to send

pkill

kill named process

static: This command can be run outside of an object context.

Usage
pkill [-pname <>] [-sig <TERM>]

Options

Option Description
pname process name
sig signal to send

ps

get process info

Obtains and prints process table information.

The following pieces of information are shown for each running process:

  • user: user name
  • command: command and arguments
  • pcpu: percentage cpu usage
  • pmem: percentage memory usage
  • state: symbolic process state
  • pid: process ID

Example: Show bash processes

	    $ ctl -m shellutil -c ps -- -pname bash
	    --- 
	    user: alexh
	    command: bash
	    pmem: "0.0"
	    args: "[-login]"
	    state: S
	    pid: "57085"
	    pcpu: "0.0"
	  

static: This command can be run outside of an object context.

Usage
ps [-format <yaml>] [-output <>] [-pname <.*>]

Options

Option Description
format output format. (plain, yaml)

Display the result in the spcified format. If "plain" is specified, results are displayed in their native ps command format. If "yaml" is specified then each process is displayed in a key/value pair format.

output output file

Save the results to the output file. If no -output option is specified results are printed to the terminal.

pname process name

Filter process info to those matching specified process name. The value for the -pname argument can also be a regular expression. If the argument is unspecified then all processes are listed.

whoami

print the user name

static: This command can be run outside of an object context.

Usage
whoami

Options

Option Description