A command template supports execution of a command or script on the Operations Sentinel server. For example, the command or script can send email or access a remote system. With a command template, you can invoke any type of script that Windows supports. You should not, however, execute a program that displays windows since the windows will not appear.
Default Environment When Using a Command Template
Commands or scripts are executed on the Operations Sentinel server, under the Operations Sentinel service account. The default environment is as follows:
The current folder is alarm-scripts, located on the Operations Sentinel server in the Operations Sentinel data folder.
Any output that is sent to stdout and stderr is discarded, unless your command explicitly redirects it to a file. In the following example, output from both stdout and stderr is directed to the file test.out.txt.
cmd.exe /C test.bat >test.out.txt.
The default for the PATH environment variable searches only the current folder, data-folder\alert-scripts, and the folder %WINDIR%\system32.
The environment variables WINDIR and SYSTEMROOT are both set to the value of Windows environment variable WINDIR. For Windows Server 2012, Windows Server 2012 R2, Windows 2016, Windows 2019, Windows Server 2022, Windows 8.1, Windows 10, and Windows 11 systems, this is typically C:\WINDOWS.
The following environment variables contain values of the attributes from the alert event report that triggered the action:
SP_ALERTID
SP_ALERTQUAL
SP_APPL
SP_APPLQUAL
SP_CLASS
SP_EXT_ACTION_LIST
SP_HELP
SP_INSTANCE
SP_SENDER_DATE
SP_SENDER_TIME
SP_SERVER
SP_SERVER_DATE
SP_SERVER_TIME
SP_SEV
SP_TEXT
SP_user-defined
One of these variables is defined for each user-defined attribute specified for the alert, where user-defined is the name of the attribute in all uppercase, with any white space characters removed.
To refer to these environment variables, use the syntax appropriate for the scripting language you choose. For example, for a DOS script specify %SP_ALERTID%.
Exit codes are recorded in the log SP-EAI for successful and failed action executions. If an action execution produces an exit code of 0, the execution is assumed to be successful. Exit codes of 60 through 100 are reserved for use by Operations Sentinel. When writing scripts, use exit codes other than 0 and 60 through 100 to represent failures.