#1 Global Leader in Data Protection & Ransomware Recovery

How to run scripts correctly with Veeam Monitor client

KB ID: 1552
Product: Veeam ONE | 9.0 | 9.5 | 10 | 11
Published: 2012-03-11
Last Modified: 2021-05-26
mailbox
Get weekly article updates
By subscribing, you are agreeing to have your personal information managed in accordance with the terms of Veeam's Privacy Notice.

Cheers for trusting us with the spot in your mailbox!

Now you’re less likely to miss what’s been brewing in our knowledge base with this weekly digest

error icon

Oops! Something went wrong.

Please try again later.

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.

 

 

To submit feedback regarding this article, please click this link: Send Article Feedback
To report a typo on this page, highlight the typo with your mouse and press CTRL + Enter.

Spelling error in text

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
Thank you!

Thank you!

Your feedback has been received and will be reviewed.

Oops! Something went wrong.

Please try again later.

You have selected too large block!

Please try select less.

KB Feedback/Suggestion

This form is only for KB Feedback/Suggestions, if you need help with the software open a support case

By submitting, you are agreeing to have your personal information managed in accordance with the terms of Veeam's Privacy Notice.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
Verify your email to continue your product download
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
Thank you!

Thank you!

Your feedback has been received and will be reviewed.

error icon

Oops! Something went wrong.

Please try again later.