https://login.veeam.com/en/oauth?client_id=nXojRrypJ8&redirect_uri=https%3A%2F%2Fwww.veeam.com%2Fservices%2Fauthentication%2Fredirect_url&response_type=code&scope=profile&state=eyJmaW5hbFJlZGlyZWN0TG9jYXRpb24iOiJodHRwczovL3d3dy52ZWVhbS5jb20va2IxNTUyIiwiaGFzaCI6IjczMzY4MGNkLTE0NTAtNDQwMS04NzdlLTRiYjEzNDgyM2RkZSJ9
1-800-691-1991 | 9am - 8pm ET
EN

How to run scripts correctly with Veeam Monitor

Purpose

As per our User Guide available at veeam.com:

To run a custom script, in the Action list, select Run script and enter the path to the executable file in the field on the right. You can use the following parameters in the command line for running a script: %1 — alarm name; %2— fired node name; %3 — triggering summary; %4 — time; %5 — alarm status; %6 — old alarm status  

Solution

First we will cover how to set up a script. Select an alarm from within Monitor under the Alarm Management button or create a new alarm.

Once done, click Modify (if an existing alarm), and then select the Actions tab.

From here, you can click the Add button and set the action to "Run script".  Once done, go ahead and add your script path, passing the variables needed for your script.  In this example, we will be using all variables and a .cmd file that is written in windows command/DOS (see screenshot below).  Please keep in mind that other file types can be used as long as they can be run in windows.  

Now that we have the Alarm Action set up, let's go over what is needed in the script.  For the script "test.cmd", use the following variables to pass the information needed.  

 set Alarm=%1

set Name=%2

set Summary=%3

set Time=%4

set Status=%5

set OldStatus=%6

set Total= %Alarm% %Name% %Summary% %Time% %Status% %OldStatus%

echo %Total%

Pause

'Set' is the command in DOS used to set a variable, 'Echo' is used to display a variable or command and 'Pause' is used to stop the process until you press a key so you can view/stop the process at that point.  Alternatively, you can set the following command to have all the %# variables in one variable, instead of keeping them individually. 

 set Total2=%1%2%3%4%5%6

echo %Total2%

Pause

Once done, your output should look similar to this: 

"Bad Host username logon attempt""xxxx.xxxx.xxxx""Fired by event type: BadUsernameSessionEvent""9/1/2011 7:04:05 PM""Warning (Yellow)""Warning (Yellow)" 

Another issue is that sometimes you need to return variables without the "" markings around them.  To remove this issue, run the following command:

set variablex=%variablex:"=%

So now the above code in both examples should look like this:

 set Alarm=%1

set Alarm=%Alarm:"=%

set Name=%2

set Name=%Name:"=%

set Summary=%3

set Summary=%Summary:"=%

set Time=%4

set Time=%Time:"=%

set Status=%5

set Status=%Status:"=%

set OldStatus=%6

set OldStatus=%OldStatus:"=%

set Total= %Alarm% %Name% %Summary% %Time% %Status% %OldStatus%

echo %Total%

Pause

 set Total2=%1%2%3%4%5%6

set Total2=%Total2:"=%

echo %Total2%

Pause

 With the output now displaying the following:  

Bad Host username logon attempt esx4.veeammlab.local Fired by event type:

BadUsernameSessionEvent 9/1/2011 7:04:05 PM Warning (Yellow) Warning (Yellow) 

With this understanding, you should be able to write any script needed for your environment using our variables.  If you have any further scripting questions or issues, please contact Veeam Support and we will help you to our best abilities per our support policy.

KB ID:
1552
Product:
Veeam ONE
Version:
5.0.0.261
Published:
2012-03-11
Last Modified:
2020-08-13
Please rate how helpful this article was to you:
5 out of 5 based on 1 ratings
Thank you for helping us improve!
An error occurred during voting. Please try again later.

Couldn't find what you were looking for?

Below you can submit an idea for a new knowledge base article.
Report a typo on this page:

Please select a spelling error or a typo on this page with your mouse and press CTRL + Enter to report this mistake to us. Thank you!

Spelling error in text

Knowledge base content request
By submitting, you agree that your personal data will be managed by Veeam in accordance with the Privacy Policy.

ty icon

Thank you!

We have received your request and our team will reach out to you shortly.

OK

error icon

Oops! Something went wrong.

Please go back try again later.