Monitoring and reporting for Veeam Backup & Replication, VMware vSphere and Microsoft Hyper-V
sandsturm
Expert
Posts: 110
Liked: 11 times
Joined: Mar 23, 2015 8:30 am
Contact:

Powershell script to forward alarms

Post by sandsturm » Apr 20, 2017 6:12 pm

Hi all

I'm searching for an example powershell script to forward alarms from Veeam One into the script. My idea is to trigger a powershell script from the alert management/run script option. I can't find examples how to pass the variables (alarm name, alarm status etc.) into a powershell script. Does anyone know how to do that?

many thanks
sandsturm

Shestakov
Veeam Software
Posts: 6738
Liked: 681 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

Re: Powershell script to forward alarms

Post by Shestakov » Apr 21, 2017 8:57 am

Hi sandsturm,
Could you describe your use case?
In the alarm`s "Actions" you may choose an option to run script.
Thanks!

Vitaliy S.
Product Manager
Posts: 22694
Liked: 1498 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Powershell script to forward alarms

Post by Vitaliy S. » Apr 21, 2017 12:02 pm

You can review script variables in this KB article, scroll down below to the More Information section.

sandsturm
Expert
Posts: 110
Liked: 11 times
Joined: Mar 23, 2015 8:30 am
Contact:

Re: Powershell script to forward alarms

Post by sandsturm » May 02, 2017 12:05 pm

Hi
I want to do the following:
Each time an alert is triggered in veeam ONE, a powershell script must be triggered. All alert parameters from veeam one (name, severity etc.) should be passed to this script. That means, in the alarm settings/actions/run script option of Veeam one, i want to put in something like

powershell.exe -command <path to alertscript.ps1> in field value.

The powershell script will look something like:

...
$alarm_name = $args[0]
$alarm_severity = $args[1]
....
<scriptcode to do something with the alarms>
....

# send alarm to our ITSM (eventmgmt system)
send-alarm -alarm_name $alarm_name -alarm_severity $alarm_severity ... -alarmsystem <URL_of_our_alarmsystem>


I hope this will clarify, what i want to do?
regards
sandsturm

Vitaliy S.
Product Manager
Posts: 22694
Liked: 1498 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Powershell script to forward alarms

Post by Vitaliy S. » May 03, 2017 11:55 am

Yes, it does. Have you tried to review how parameters are passed in the batch scripts from the KB article?

sandsturm
Expert
Posts: 110
Liked: 11 times
Joined: Mar 23, 2015 8:30 am
Contact:

Re: Powershell script to forward alarms

Post by sandsturm » May 03, 2017 12:23 pm

Yes, I did, but that does not work for me. I don't want to start a batch script and start the powershell script from within this batch script. Isn't it possible to run the powershell script directly?

Shestakov
Veeam Software
Posts: 6738
Liked: 681 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

Re: Powershell script to forward alarms

Post by Shestakov » May 03, 2017 2:53 pm

As far as I know "direct" scripts are not supported. So it`s better to use .bat file
You can use these arguments in the batch file:
  • %1 - Alarm
    %2 - Fired node name
    %3 - triggering summary
    %4 - Time
    %5 - status
    %6 - old status
Thanks!

sandsturm
Expert
Posts: 110
Liked: 11 times
Joined: Mar 23, 2015 8:30 am
Contact:

Re: Powershell script to forward alarms

Post by sandsturm » May 11, 2017 11:01 am

Okay, thank you. I was able to run a powershell script to, but I can't pass the variables (%1,%2...) correctly to the powershell script. So I start a .cmd and within this bat file I start my powershell script. This works fine.
Another question:
Is there an ID to find somewhere for each created alarm? I want to send all alerts to our global event collector, but if I do this, I need a unique identifier for each event, because if, for example, the OK message is fired from Veeam One for a former Error or Warning, i have to map this OK message to the according alarm. Is there a way to grab a unique alarm idenifier?

thx and regards
sandsturm

Shestakov
Veeam Software
Posts: 6738
Liked: 681 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

Re: Powershell script to forward alarms

Post by Shestakov » May 12, 2017 12:48 pm

There is no list of ID numbers because they vary from installation to installation, but you can find your particular alarm IDs in the table monitor.Alarm.
Thanks!

sandsturm
Expert
Posts: 110
Liked: 11 times
Joined: Mar 23, 2015 8:30 am
Contact:

Re: Powershell script to forward alarms

Post by sandsturm » May 12, 2017 1:22 pm

Thank you for your answer, I saw the ID in monitor.Alarm table, but this is a general ID for each specific type of alarm. I need an ID for each thrown alert/alarm which means, if Guest disk space is full on Server A1 for example, i want to see an ID 027 for this alert, and if server B5 has the same problem, another alarm ID must be generated (for the same type of alert, but for another server).
But as I understand you correct, this isn't the case, though Veeam ONE is no option to use in our company. We actually use Veeam MP for SCOM (where an alert ID is generated for each alarm), but I was searching for an alternative, because I don't have the "VM Change rate" report in Veeam MP for example.

thank you for your help
sandsturm

Shestakov
Veeam Software
Posts: 6738
Liked: 681 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

Re: Powershell script to forward alarms

Post by Shestakov » May 13, 2017 11:00 pm

I`ve got your point.
But what is the use case for different alarm IDs for each object? Do VMs you have different admins and you need to notify a corresponding admin?
Thanks!

sandsturm
Expert
Posts: 110
Liked: 11 times
Joined: Mar 23, 2015 8:30 am
Contact:

Re: Powershell script to forward alarms

Post by sandsturm » May 15, 2017 5:53 am

We have different monitoring containers in our company (SCOM with Veeam Management Pack, Nagios, etc.). All these systems forward their alarms over an event dispatcher platform into our ITSM. In this ITSM, events/alarms are redirected to the appropriate operations team where tickets appear depending on alarms severity. Let me explain one of many examples why this ID is important for us.
If an urgent alarm is generated within Veeam, a priority 1 alarm is generated in ITSM based on this, which means an SMS will be sent to the person in charge (Prio 1 leads to an SMS, while Prio 2 and less will create a ticket). If for any reason, this alarm is gone in Veeam (automatically) some minutes later, an event with Status=Reset/resolved is generated. We forward this (Reset)-alarm to our ITSM as well and the original alarm will be closed and a further SMS will be sent tot he person in charge, that he knows that nothing is to do. This matching of Alarm with Prioritiy 1 and Resolve-Alarm can be done only if I have a unique identifier, otherwise I can't do this match.
This is an elementary feature for us. Actually we use Veeam Management Pack with SCOM and there it is possible, because I have an ID within SCOM. But I want to switch from MP to Veeam ONE because of the better reporting, but I'm able to switch only in the case the alerting works as explained above.

I'm not a native english speaker, but I hope you understand what I mean?

Thx,
sandsturm

Shestakov
Veeam Software
Posts: 6738
Liked: 681 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

Re: Powershell script to forward alarms

Post by Shestakov » May 26, 2017 3:03 pm

Hello sandsturm,
I do understand your point and it makes sense for me. Thanks for the explanation.

To clear up the request, SCOM has unique ID per-alert / per-object, but ID is same for all triggers of such alarms.
I.e. say VM1 has alert on CPU Usage and its id is 00001, if VM2 has CPU Usage above the alert`s threshold, it will have id = 00002. If CPU Usage triggers again for VM1 the id alert is 00001 again.
Unlike SCOM, Veeam ONE has unique ids only for the alerts(alarms) themselves.

If we add unique IDs for each alarm / object, will it be sufficient for your case?

Thanks!

sandsturm
Expert
Posts: 110
Liked: 11 times
Joined: Mar 23, 2015 8:30 am
Contact:

Re: Powershell script to forward alarms

Post by sandsturm » May 29, 2017 5:11 am

Hi Shestakov

Yes, your explanation is exactly what we need. Do you think it's possible to implement such an ID?

thx a lot
sandsturm

Shestakov
Veeam Software
Posts: 6738
Liked: 681 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

Re: Powershell script to forward alarms

Post by Shestakov » May 29, 2017 10:30 am

Nothing is impossible for our R&D :)
The question is when we have got time for it.
Thank you for that request, it really makes sense, I`ll add it to our road map.

sandsturm
Expert
Posts: 110
Liked: 11 times
Joined: Mar 23, 2015 8:30 am
Contact:

Re: Powershell script to forward alarms

Post by sandsturm » May 29, 2017 10:37 am 1 person likes this post

sounds great

thx a lot
sandsturm

Horace27
Novice
Posts: 5
Liked: never
Joined: May 26, 2017 12:02 pm
Contact:

Re: Powershell script to forward alarms

Post by Horace27 » Aug 08, 2017 1:09 pm

Hi all.
I'm trying to launch like sandsturm a .cmd to take variables and after call a powershell .ps1, but I'm experiencing strange behavior: ps1 (without variables) works fine but if I launch .cmd it doesn't work.
I configure alarm action like this:

Action: Run script
Value: "C:\script\script.cmd"
Condition: Warning and errors

Where I make mistake? I've latest version of Veeam ONE (9.5.0.3254) Thanks

H.

Shestakov
Veeam Software
Posts: 6738
Liked: 681 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

Re: Powershell script to forward alarms

Post by Shestakov » Aug 08, 2017 5:25 pm

sandsturm was asking for unique ID for alarms, I guess the provided script did not work.
Could you describe your use case?

Horace27
Novice
Posts: 5
Liked: never
Joined: May 26, 2017 12:02 pm
Contact:

Re: Powershell script to forward alarms

Post by Horace27 » Aug 09, 2017 6:59 am

Hi Shestakov.
My goal is to forward alarm with a telegram message, which I can generate with a powershell script like this:

Invoke-WebRequest -Uri 'https://api.telegram.org/[...]'

So because of I can't use directly variables, I'm trying to configure veeam ONE to execute .cmd using variables and after will call powershell script. But the problem is that if I launch script from windows it works well, otherwise if I run script using action in veeam ONE it doesn't work.

Horace27
Novice
Posts: 5
Liked: never
Joined: May 26, 2017 12:02 pm
Contact:

Re: Powershell script to forward alarms

Post by Horace27 » Aug 10, 2017 8:19 am

I resolved issue giving execute privilege at everyone user to run .cmd script.

H.

Shestakov
Veeam Software
Posts: 6738
Liked: 681 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

Re: Powershell script to forward alarms

Post by Shestakov » Aug 10, 2017 9:04 am

Sounds interesting. Do you have notifications sent to Telegram now?

Horace27
Novice
Posts: 5
Liked: never
Joined: May 26, 2017 12:02 pm
Contact:

Re: Powershell script to forward alarms

Post by Horace27 » Aug 11, 2017 7:31 am

Yes, now I have.
For the exec privilege of .cmd, there is another way to handle whithout use of everyone?
In KB I read that user have to be machine's administrator, so it means I have to nest "Veeam ONE administrators" group in local administrator?

Thanks.
H.

Shestakov
Veeam Software
Posts: 6738
Liked: 681 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

Re: Powershell script to forward alarms

Post by Shestakov » Aug 11, 2017 10:00 am

You may add

Code: Select all

whoami > c:\user.txt

into script to check how it is executed.
Could you provide the KB number you are referring to?
Thanks!

kge8889
Novice
Posts: 5
Liked: never
Joined: Jun 12, 2017 1:34 pm
Full Name: Ken Everett
Contact:

Re: Powershell script to forward alarms

Post by kge8889 » Jan 19, 2018 10:40 pm

Shestakov - Would you be able to provide me a copy of the .bat file you wrote which executes the PowerShell? I am working through a similar problem trying to get Veeam One to run a PowerShell from an alert and it does not want to work with just a PS command.

Shestakov
Veeam Software
Posts: 6738
Liked: 681 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

Re: Powershell script to forward alarms

Post by Shestakov » Jan 23, 2018 12:23 pm

Hello Ken,
I don't have the file.
Yes, you can convert you powershell script into a batch file or create the .bat file responsible for execution your PowerShell script.

sandsturm
Expert
Posts: 110
Liked: 11 times
Joined: Mar 23, 2015 8:30 am
Contact:

Re: Powershell script to forward alarms

Post by sandsturm » Jun 12, 2018 5:46 am

Shestakov wrote:Nothing is impossible for our R&D :)
The question is when we have got time for it.
Thank you for that request, it really makes sense, I`ll add it to our road map.
Hi Shestakov

How about the unique ID for Veeam ONE? Were you able to add it to the road map or is it implemented in the meantime?

thx
sandsturm

Shestakov
Veeam Software
Posts: 6738
Liked: 681 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

Re: Powershell script to forward alarms

Post by Shestakov » Jun 12, 2018 6:29 pm

Yes, we are working on it. The feature is goring to be implemented in the next releases.
Thanks!

sandsturm
Expert
Posts: 110
Liked: 11 times
Joined: Mar 23, 2015 8:30 am
Contact:

Re: Powershell script to forward alarms

Post by sandsturm » Jun 13, 2018 8:05 am

Thank you. I would be happy if you can post here as soon as this is implemented and available.

thx
sandsturm

Shestakov
Veeam Software
Posts: 6738
Liked: 681 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

Re: Powershell script to forward alarms

Post by Shestakov » Jun 14, 2018 8:29 am

I'll try to remember. You can also find it in What's New document of the release.

sandsturm
Expert
Posts: 110
Liked: 11 times
Joined: Mar 23, 2015 8:30 am
Contact:

Re: Powershell script to forward alarms

Post by sandsturm » Apr 01, 2019 2:06 pm

Hi
Veeam ONE version 9.5 update 4 now should have an Alarm ID implemented: see page 2 of the Whats new document https://www.veeam.com/veeam_one_9_5_whats_new_wn.pdf It says: Enhanced alarms notification engine. All triggers of specific alarm objects now have unique identifiers that can be used for integration with third-party applications.
Sounds like the feature I was waiting for :-)
My question is now: how can I get this alarm ID. Until now I had 6 variables: %1 — alarm name; %2 — affected node name; %3 — alarm summary; %4 — time; %5 — alarm status; %6 — previous alarm status

I tried with %7, but didn't got anything back... how can I catch this new Alarm ID and pass it to a script?

thx,
sandsturm

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests