Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1342278
  • 博文数量: 464
  • 博客积分: 9399
  • 博客等级: 中将
  • 技术积分: 6364
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-19 09:15
文章分类

全部博文(464)

文章存档

2014年(12)

2013年(123)

2012年(173)

2011年(156)

我的朋友

分类: 系统运维

2013-05-29 11:21:31

我在一个公司,经营一个大的云数据中心的一个项目该组织是24 / 7和我的一些同事需要每周监测环境(备用的变化)每周一次,我们需要改变一些报警动作发出报警通知不同的电子邮件地址。因为它有很多工作要做,方面我脚本

你必须在脚本中的电子邮件地址值的改变。而自动改变定义的休息

 

1
$MailToRandom1 = "alert_random@vmpros.nl"

Here’s my script:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#====================================================================#
#   SCRIPT:        Change_Alarm_Datacenter.ps1                       #
#   FUNCTION:      Modify multiple Alarm definitions in vCenter      #
#   CREATED:       10/06/2011                                        #
#   VERSION:       v.1.1                                             #
#====================================================================#
#   CHANGELOG:                                                       #
#                                                                    #
#    v.1.1                                                           #
#    - Deleted email body                                            #
#    - Added Alarm definition                                        #
#    - Added changelog                                               #
#                                                                    #
#    v.1.0                                                           #
#    - First Release                                                 #
#                                                                    #
#====================================================================#
# Note: You only have to change the "MailToRandom1" value in "Custom #
#         Definitions" to change the alarm action                    #
#====================================================================#
# Connect vCenter server;
#--------------------------------------------------------------------#
$vCenterServer = "vcenter-server"
$user = "username"
$pass = "password"
 
if ( $DefaultVIServers.Length -lt 1 )
{
  Connect-VIServer -Server $vCenterServer -Protocol https -User $user -Password $pass -WarningAction SilentlyContinue | Out-Null
}
 
#--------------------------------------------------------------------#
# Custom Definitions;
#--------------------------------------------------------------------#
$actType = "SendEmailAction"
$MailToRandom1 = "alert_random@vmpros.nl"
$MailToDefault1 = "alert1@vmpros.nl"
$MailToDefault2 = "alert2@vmpros.nl"
$actAlarm1 = "Machine suspended"
$actAlarm2 = "Datastore usage"
$actAlarm3 = "Snapshot alarm"
$actSubject = "Get-AlarmDefinition"
#--------------------------------------------------------------------#
# Delete Alarm Trigger;
#--------------------------------------------------------------------#
Get-AlarmDefinition -Name "$actAlarm1" , "$actAlarm2" , "$actAlarm3" | Get-AlarmAction | Remove-AlarmAction -Confirm:$false
#--------------------------------------------------------------------#
# Create Alarm Trigger;
#--------------------------------------------------------------------#
Get-AlarmDefinition -Name "$actAlarm1" , "$actAlarm2" , "$actAlarm3" | New-AlarmAction -Email -To "$MailToRandom1" , "$MailToDefault1" , "$MailToDefault2"
Get-AlarmDefinition -Name "$actAlarm1" , "$actAlarm2" , "$actAlarm3" | Get-AlarmAction | New-AlarmActionTrigger -StartStatus "Green" -EndStatus "Yellow"
#--------------------------------------------------------------------#
# Disconnect vCenter server;
#--------------------------------------------------------------------#
Disconnect-VIServer -Server $vCenterServer -Force:$true -Confirm:$false
#--------------------------------------------------------------------#
阅读(1510) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~