1-800-691-1991 | 9am - 8pm ET
EN

How to run scripts correctly with Veeam Monitor client

KB ID: 1552
Product: Veeam ONE 11, Veeam ONE 10a, Veeam ONE 9.5, Veeam ONE 9.0
Published: 2012-03-11
Last Modified: 2021-05-26

Purpose

There are two possibilities to run a script with Veeam ONE:

 

  1. As a notification action - select this option if you want to run a custom script when the alarm is triggered or when the alarm status changes. By running a script, you can automate routine tasks that you normally perform when specific alarms fire. For example, if a critical system is affected, you may need to immediately open a ticket with the in-house support or perform corrective actions that will eliminate the problem;
  2. As a remediation action - you can specify what actions must be performed after the alarm is triggered, or after the alarm status changes.

 

Solution

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.

The executable file must be located on the machine running the Veeam ONE Server component.

How to set up a script.

Select an existing alarm or create a new one using the Alarm Management tab. Once done, click Edit (if an existing alarm), and then select the Notifications 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.

Or if you wish it to be run as a remediation action select Actions tab:

In this example, we will be using 3 variables and a .ps1 file that is written in PowerShell. 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 Notification set up, let's go over what is needed in the script. For the script "alarm.ps1", let’s use the following variables to pass the information needed. This is the full text indicated in the alarm settings:

powershell.exe E:\script\alarm.ps1 '%1' '%5' '%2'

 

This is the script content:

$AlarmName=$args[0]

$AlarmState=$args[1]

$ObjectName=$args[2]

$Text="$(Get-Date)" + "`r`n" + "$AlarmName" + " alarm goes ->" + "$AlarmState" + " on VM " + "$ObjectName" + "`r`n"

$Text | Out-File E:\script\output.log -Append

After passing the arguments the result is saved into the $Text variable and the result is typed into the output file with the current date information. "`r`n" means new line here, “Get-Date” cmdlet returns the actual date and time.

Once done, your output should look similar to this: 


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, contact Veeam Support and we will help you to our best abilities per our support policy.

 

 

KB ID: 1552
Product: Veeam ONE 11, Veeam ONE 10a, Veeam ONE 9.5, Veeam ONE 9.0
Published: 2012-03-11
Last Modified: 2021-05-26

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
Your report was sent to the responsible team. Our representative will contact you by email you provided.
We're working on it please try again later
Knowledge base content request
By submitting, you are agreeing to have your personal information managed in accordance with the terms of Veeam's Privacy Policy.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
Thank you for your interest in Veeam products!
We've sent a verification code to:
  • Incorrect verification code. Please try again.
An email with a verification code was just sent to
Didn't receive the code? Click to resend in sec
Didn't receive the code? Click to resend

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.