Monitoring and reporting for Veeam Data Platform
Post Reply
Kazz
Expert
Posts: 140
Liked: 17 times
Joined: Feb 08, 2018 3:47 am
Full Name: Kazz Beck
Contact:

Alarm Management Run script

Post by Kazz »

Hi,

A blog post published here -> https://www.veeam.com/blog/one-alarms-n ... slack.html is suggesting

Code: Select all

powershell.exe "C:\YOURPATHTOTHESCRIPTS\VeeamONE-Notification-(Slack-OR-Teams).ps1" '%1' '%2' '%3' '%4' '%5' '%6' '%7'
to be used in the Value field of the action. It's not working for me as shown, however if I add -File right after powershell.exe, the script works when action is triggered. Is it supposed to work without -File option or it was missed when article was published ?

Thanks
jorgedlcruz
Veeam Software
Posts: 1372
Liked: 619 times
Joined: Jul 17, 2015 6:54 pm
Full Name: Jorge de la Cruz
Contact:

Re: Alarm Management Run script

Post by jorgedlcruz »

Hello,
I wrote that blog, geez time flies! At the time of writing, and even today, it works like that. The -File might be something to do with newer powershell versions. Which one you running?

Thanks
Jorge de la Cruz
Senior Product Manager | Veeam ONE @ Veeam Software

@jorgedlcruz
https://www.jorgedelacruz.es / https://jorgedelacruz.uk
vExpert 2014-2024 / InfluxAce / Grafana Champion
Kazz
Expert
Posts: 140
Liked: 17 times
Joined: Feb 08, 2018 3:47 am
Full Name: Kazz Beck
Contact:

Re: Alarm Management Run script

Post by Kazz »

I inherited VONE installation on an 2012 R2 server and ran in to two road blocks.

1. Script VeeamONE-Notification-Teams.ps1 would not get called unless I added -File before the file name
2. Invoke-RestMethod would be consistently denied by office.com because it was going out TLS1.0 (clearly shown in a Wireshark trace)

I had to add [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 to the script to force PS to use TLS1.2.
Don't think newer OSs have this issue.

Here is what I am showing for PS version.

Name Value
---- -----
PSVersion 4.0
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
CLRVersion 4.0.30319.42000
BuildVersion 6.3.9600.20719
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion 2.2
Kazz
Expert
Posts: 140
Liked: 17 times
Joined: Feb 08, 2018 3:47 am
Full Name: Kazz Beck
Contact:

Re: Alarm Management Run script

Post by Kazz »

I made the notification a bit more organized and easier to read.

Code: Select all

param([string]$AlarmName,[string]$NodeName,[string]$Summary,[string]$Time,[string]$Status,[string]$OldStatus,[string]$ID)


$uri = "YOUR HOOK URL"

Switch ([String]$Status) {
    None {$Colour = ''}
    Error {$Colour = 'ff0000'}
    Warning {$Colour = 'ffe100'}
    Reset/resolved {$Colour = '00ff00'}
    Default {$Colour = ''}
}


$body = ConvertTo-Json -Depth 4 @{
    Summary = 'Veeam One'
    themeColor = $Colour
    sections = @(
        @{
            title = '**' + $AlarmName + ' on ' + $NodeName + ' has been changed to: ' + $Status + '**'
            activitySubtitle = (Get-Date -UFormat "%A, %B %d, %Y") 
            facts = @(
                @{
					name = "Previous state:"   
					value = $OldStatus
				},
                @{
					name = "Details:"   
					value = $Summary
				}

            )
        }
    )
}


Invoke-RestMethod -uri $uri -Method Post -body $body -ContentType 'application/json'


jorgedlcruz
Veeam Software
Posts: 1372
Liked: 619 times
Joined: Jul 17, 2015 6:54 pm
Full Name: Jorge de la Cruz
Contact:

Re: Alarm Management Run script

Post by jorgedlcruz »

Fantastic, thanks a lot. Is this for Teams?
Jorge de la Cruz
Senior Product Manager | Veeam ONE @ Veeam Software

@jorgedlcruz
https://www.jorgedelacruz.es / https://jorgedelacruz.uk
vExpert 2014-2024 / InfluxAce / Grafana Champion
Kazz
Expert
Posts: 140
Liked: 17 times
Joined: Feb 08, 2018 3:47 am
Full Name: Kazz Beck
Contact:

Re: Alarm Management Run script

Post by Kazz »

Yep, Teams
jorgedlcruz
Veeam Software
Posts: 1372
Liked: 619 times
Joined: Jul 17, 2015 6:54 pm
Full Name: Jorge de la Cruz
Contact:

Re: Alarm Management Run script

Post by jorgedlcruz »

I will give all of this a try, and update the blog post with your great work, thanks a lot.
Jorge de la Cruz
Senior Product Manager | Veeam ONE @ Veeam Software

@jorgedlcruz
https://www.jorgedelacruz.es / https://jorgedelacruz.uk
vExpert 2014-2024 / InfluxAce / Grafana Champion
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests