Operational Defect Database

BugZero found this defect 4453 days ago.

Veeam | kb1552

How to run scripts correctly with Veeam Monitor client

Last update date:

5/26/2021

Affected products:

Veeam ONE

Affected releases:

9.0

Fixed releases:

No fixed releases provided.

Description:

Purpose

There are two possibilities to run a script with Veeam ONE:   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; 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.

Additional Resources / Links

Share:

BugZero® Risk Score

What's this?

Coming soon

Status

Solved

Learn More

Search:

...