Actions

Actions is a tool for performing operations on the network nodes in your Storage right from the Network tree.

Actions can be accessed via the network node and group context menus:

By default, only the actions that are applicable to the selected nodes are visible in the menu. This can be changed from the Options.

Standard actions

TNI comes with three standard actions:

  • Reboot;
  • Power off;
  • Wake-on-LAN.

These actions don't need to be configured. To execute one of them, simply select it from the action list of the desired node or group of nodes.

Custom actions

Custom actions allow you to use any system routines or third-party utilities in order to accomplish a desired task involving a remote network device.

Custom actions are defined in the action text file using a simple syntax. To access the file, right-click any asset, choose Edit actions from the Actions sub-menu and, when the Options window opens, click the Edit commands in Notepad button in Options / Actions.

A convenient, brief summary for the action definition syntax, with examples and a complete list of keywords and templates, can be found in the Actions section of the Options window, with one-click copy capability included. The list is also available on this documentation page.

Defining a new action

To add a new action, add a line to the action text file:

Action name=command

Action name is the name that will appear in the Actions menu.

Command is the command for the operating system to execute.

Templates

Inside the command's definition, certain string templates are used to pass the parameters of a targeted network node into the command. These are the supported templates:

 %HOST%  FQDN, hostname or IP, depending on the Static IP flag of the asset
 %HOSTNAME%  Hostname of the asset
 %ALIAS%  Alias of the asset
 %IP%  IP-address of the asset
 %MAC-%  Hyphen-separated MAC-address
 %MAC:%  Colon-separated MAC-address
 %MAC%  MAC-address without delimiters
 %SSHPORT%  Custom SSH port as specified in the scanner options
 %USERNAME%  Username from the login record used for asset scanning
 %PASSWORD%  Password from the login record used for asset scanning
 %DATE%  Current date (YYYYMMDD)
 %TIME%  Current time (HHMM)
 %TIMES%  Current time (HHMMSS)

An example of using a template in a command:

Ping asset=ping.exe %HOST%

Conditions

Conditional directives may be added to the action's definition, thus rendering the action inapplicable to certain assets. This is useful in a variety of cases, i.e. to prevent attempts to execute a command that are certain to fail.

A condition is specified when {$IF condition} is added before the action's definition in this way:

{$IF condition}Action name=command

These are the supported conditions:

 OPEN00  The specified port is open
 OPENSSHPORT  The SSH port specified in the scanner settings is open
 ONLINE  The device is online
 WIN  It's a Windows device
 LIN  It's a Linux device
 MAC  It's an OS X device
 SSH  The device was scanned via SSH (a Linux, OS X, FreeBSD, or an ESX/ESXi device)
 SNMP  The device was scanned via SNMP
 LAN  The device and the PC running TNI 3 share the same subnet
 EXISTS(filename.exe)  The specified executable exists on the paths specified in the PATH environment variable

Several conditions separated by commas result in a logical AND treatment.

Adding an "!" before a condition negates it (logical NOT).

Example usage with conditions:

{$IF LAN,!ONLINE}Wake-on-LAN=wol.exe %MAC:%

Actions for multiple nodes

By default, any action is considered inapplicable to several devices at once. Thus, it won't appear in the action list when you select several devices or a group. To make it available in these cases, multiple targets have to be allowed explicitly by adding the {$MULTI} directive in front of the definition.

Example:

{$MULTI}{$IF LAN,!ONLINE}Wake-on-LAN=wol.exe %MAC:%

When targeted at multiple devices, a condition is considered satisfied if any of the target nodes satisfies it. To make a condition mandatory for all targets, an "!" should be added after it.

Examples:

{$IF LAN} If any of the target nodes share the local subnet
{$IF LAN!} If all of the target nodes share the local subnet

Negation and mandatory-for-all modification can be combined:

{$IF !ONLINE!} If all of the targeted nodes are offline

Accidental run protection

If an action is "unsafe", adding an {$?} directive to the definition will display a confirmation dialog before every execution.

{$?}Shutdown="C:\PSTools\psshutdown.exe" -k \\%HOST%

Sending keystrokes

Sometimes executing a command launches a user interface that requires further user input. In order to automate this task, TNI can send predefined keystrokes to the launched application.

To send keystrokes, append /sendkeys: to the action's definition, followed by a string of keys to send. After the /sendkeys: command you may use:

Arbitrary text sent as is
Templates converted to text and sent as they are
{$WAIT X} pauses the execution for X milliseconds (if this directive is omitted, the default pause before sending any keys is one second)
{key name} simulate pressing a special key (the following keyboard keys can be used: F1..F10, LEFT, RIGHT, UP, DOWN, ENTER, BACKSPACE, PGUP, PGDN, HOME, END, TAB)

Example of usage:

Remote Desktop with login=mstsc.exe /v:%IP% /sendkeys:%PASSWORD%{ENTER}

When the action is executed, an authorization window will open up. TNI then sends the password to the input box and presses Enter to log in, automatically.