Monitoring and reporting for Veeam Data Platform
sandsturm
Veteran
Posts: 291
Liked: 25 times
Joined: Mar 23, 2015 8:30 am
Contact:

Powershell script to forward alarms

Post by sandsturm »

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
Veteran
Posts: 7328
Liked: 781 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

Re: Powershell script to forward alarms

Post by Shestakov »

Hi sandsturm,
Could you describe your use case?
In the alarm`s "Actions" you may choose an option to run script.
Thanks!
Vitaliy S.
VP, Product Management
Posts: 27377
Liked: 2800 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Powershell script to forward alarms

Post by Vitaliy S. »

You can review script variables in this KB article, scroll down below to the More Information section.
sandsturm
Veteran
Posts: 291
Liked: 25 times
Joined: Mar 23, 2015 8:30 am
Contact:

Re: Powershell script to forward alarms

Post by sandsturm »

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.
VP, Product Management
Posts: 27377
Liked: 2800 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Powershell script to forward alarms

Post by Vitaliy S. »

Yes, it does. Have you tried to review how parameters are passed in the batch scripts from the KB article?
sandsturm
Veteran
Posts: 291
Liked: 25 times
Joined: Mar 23, 2015 8:30 am
Contact:

Re: Powershell script to forward alarms

Post by sandsturm »

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
Veteran
Posts: 7328
Liked: 781 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

Re: Powershell script to forward alarms

Post by Shestakov »

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
Veteran
Posts: 291
Liked: 25 times
Joined: Mar 23, 2015 8:30 am
Contact:

Re: Powershell script to forward alarms

Post by sandsturm »

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
Veteran
Posts: 7328
Liked: 781 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

Re: Powershell script to forward alarms

Post by Shestakov »

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
Veteran
Posts: 291
Liked: 25 times
Joined: Mar 23, 2015 8:30 am
Contact:

Re: Powershell script to forward alarms

Post by sandsturm »

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
Veteran
Posts: 7328
Liked: 781 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

Re: Powershell script to forward alarms

Post by Shestakov »

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
Veteran
Posts: 291
Liked: 25 times
Joined: Mar 23, 2015 8:30 am
Contact:

Re: Powershell script to forward alarms

Post by sandsturm »

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
Veteran
Posts: 7328
Liked: 781 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

Re: Powershell script to forward alarms

Post by Shestakov »

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
Veteran
Posts: 291
Liked: 25 times
Joined: Mar 23, 2015 8:30 am
Contact:

Re: Powershell script to forward alarms

Post by sandsturm »

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
Veteran
Posts: 7328
Liked: 781 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

Re: Powershell script to forward alarms

Post by Shestakov »

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
Veteran
Posts: 291
Liked: 25 times
Joined: Mar 23, 2015 8:30 am
Contact:

Re: Powershell script to forward alarms

Post by sandsturm » 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 »

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
Veteran
Posts: 7328
Liked: 781 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

Re: Powershell script to forward alarms

Post by Shestakov »

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 »

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 »

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

H.
Shestakov
Veteran
Posts: 7328
Liked: 781 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

Re: Powershell script to forward alarms

Post by Shestakov »

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 »

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
Veteran
Posts: 7328
Liked: 781 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

Re: Powershell script to forward alarms

Post by Shestakov »

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: 6
Liked: never
Joined: Jun 12, 2017 1:34 pm
Full Name: Ken Everett
Contact:

Re: Powershell script to forward alarms

Post by kge8889 »

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
Veteran
Posts: 7328
Liked: 781 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

Re: Powershell script to forward alarms

Post by Shestakov »

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
Veteran
Posts: 291
Liked: 25 times
Joined: Mar 23, 2015 8:30 am
Contact:

Re: Powershell script to forward alarms

Post by sandsturm »

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
Veteran
Posts: 7328
Liked: 781 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

Re: Powershell script to forward alarms

Post by Shestakov »

Yes, we are working on it. The feature is goring to be implemented in the next releases.
Thanks!
sandsturm
Veteran
Posts: 291
Liked: 25 times
Joined: Mar 23, 2015 8:30 am
Contact:

Re: Powershell script to forward alarms

Post by sandsturm »

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

thx
sandsturm
Shestakov
Veteran
Posts: 7328
Liked: 781 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

Re: Powershell script to forward alarms

Post by Shestakov »

I'll try to remember. You can also find it in What's New document of the release.
sandsturm
Veteran
Posts: 291
Liked: 25 times
Joined: Mar 23, 2015 8:30 am
Contact:

Re: Powershell script to forward alarms

Post by sandsturm »

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