11.6 DosCommand

Use this Knowledge Script to run a non-interactive DOS command when an event is raised. For example, use this script to run a batch command for virus scanning, disk backup, or logging an entry in a trouble-ticket system.

You can include arguments in the command string. This script can also test your command-line syntax.

Use this Knowledge Script to create a script file that contains a series of commands to diagnose or correct problems on a server you are monitoring. You can then have this Action launch your script file when an event is detected. For example, enter: cmd /c \fixitscript.bat.

To ensure the command runs successfully:

  • Include the full path to the executable you want to run. For example, to issue a Ping command, enter a command similar to the following:

    cmd /c \ping.exe 164.210.210.1.
  • Be sure that the command you want to run does not require any user input.

  • To run this Action on the managed computer, select MC (Managed Client) as the Location on the Action tab of the Properties dialog box.

  • Check whether the computer where you want to run a command or script file accepts commands from the management server you are using. This access is controlled through the AllowDosCmd registry key setting. By default, the AllowDosCmd key is set to * to allow all management servers to initiate DOS commands. To restrict the management servers that are allowed to run DOS commands, you can set this key to a comma-separated list of computer names. For example, AllowDosCmd:REG_SZ:shasta,dynamo.

  • Verify that the AppManager Client Resource Monitor (NetIQmc) service account, whether it be the LocalSystem account or a user account, has permission to execute the command you want to run on the computer where you want the Action executed.

11.6.1 Setting Parameter Values

Set the following parameters as needed:

Parameter

How to Set It

Event Notification

Event severity -- Action failure

Set the event severity level, from 1 to 40, to indicate the importance of an event in which the DosCommand job fails. The default is 5 (red event indicator).

Severity Configuration

Minimum event severity for Action

Set the minimum severity level, from 1 to 40, for an event that triggers this Action. The default is 1.

Maximum event severity for Action

Set the maximum severity level, from 1 to 40, for an event that triggers this Action. The default is 40.

Action

Non-interactive DOS command

Specify the command to run. Do not enter a command that requires user input. The command you enter should take care of any input and output redirection or handling required. The default is del\temp\yunk.txt.

NOTE:If the command you are entering includes quotation marks ("), enclose the quoted string in a second set of quotation marks. For example, if the DOS command is net send "message", enter the following: cmd /c net send ""message"".

You can use the following keywords in the command:

  • $ShortMsg$ (short event message)

  • $DetailMsg$ (detailed event message)

  • $Time$ (date and time of the event)

  • $JobID$ (ID of the job that raised the event)

  • $MachineName$ (name of the computer where the event was raised)

  • $Severity$ (severity of the event)

  • $KSName$ (name of the Knowledge Script that raised the event)

  • $ObjectName$ (name of the AppManager resource object where the event was raised)

  • $EventID$ (event ID)

For $ShortMsg$ and $DetailMsg$, you can use number and wildcard options to indicate specific portions of the text string to include. For example:

  • $DetailMsg$[5] includes the fifth word of the detailed event message

  • $ShortMsg$[1-5] includes the first through fifth words of the short message event

  • $DetailMsg$[*5] includes the first through fifth words of the detailed event message

  • $ShortMsg$[5*] includes the fifth through last words of the short event message

If you do not enter a word specifier, AppManager returns the entire string.

Example

To print a detail message starting from the eighth word into c:\temp\log.txt, type the following command:

echo $DetailMsg$[8*] > c:\temp.log.txt

Normal/Expected exit code

Set the normal/expected exit code for the DOS command you enter. The default is 0.