项目作者: ssemyan

项目描述 :
Create classic-style Azure VM Alerts
高级语言: PowerShell
项目地址: git://github.com/ssemyan/CreateClassicAzureVmAlerts.git
创建时间: 2019-02-14T15:35:04Z
项目社区:https://github.com/ssemyan/CreateClassicAzureVmAlerts

开源协议:MIT License

下载


Create Classic Azure VM Alerts

Note: Classic Style alerts are scheduled to be depricated June 30, 2019. Read more about this here: https://docs.microsoft.com/en-us/azure/azure-monitor/platform/monitoring-classic-retirement

For an example on how to create the new-style of alerts in Azure Monitor, go here: https://github.com/ssemyan/CreateAzureMonitorVmAlerts

This PowerShell script and ARM templates will create classic-style Azure alerts that email specified addresses when:

  1. The memory usage of the VM exceeds 80% for 5 minutes
  2. The CPU usage of the VM exceeds 80% for 5 minutes
  3. The network in of the VM falls below 15K for 5 minutes

The PowerShell script will set these alerts for every VM in the specified resource groups. This requires the VM Guest Diagnostics extension to be installed. Learn more about this here:

To install the Windows VM Extension while creating the alerts, set the value of $addExtension to $TRUE and update the values for $existingdiagnosticsStorageAccountName and $existingdiagnosticsStorageResourceGroup

To only install the extension and not create alerts, set the value of $addAlerts to $FALSE

To use this script edit the details in CreateAlertsOnAllVmsInResourceGroups.ps1:

First update the list of resource groups to search:

  1. $resourceGroupsToProcess = @('my_group', 'my_group_2')

Alternatively, if you want to run against all resource groups uncomment out this line:

  1. #$resourceGroupsToProcess = @()

Then update the email(s) to send alerts to (comma-separated if more than one):

  1. $sendToEmails = 'myemail@company.com,myemail2@company.com'

Finally, run the following command in PowerShell. Note: this requires the Azure PowerShell Module and if using the new version, the script will set the AzureRm alias via Enable-AzureRmAlias.

  1. .\CreateAlertsOnAllVmsInResourceGroups.ps1