当前位置: 首页 > 工具软件 > RHQ > 使用案例 >

基于RHQ配置邮件预警(Email Alert)

归星驰
2023-12-01
[b]写在前面[/b]
关于Rhq的安装,请参考[url=http://xiaoborun.iteye.com/admin/blogs/781950]《RHQ简介与安装》[/url],之前安装演示中对应的版本为rhq3.0,现在配置邮件预警使用的版本为RHQ4.2,不过安装过程大同小异,还是具有参考价值的。
[b]实现原理[/b]
Rhq发送预警邮件的实现原理是通过调用其内置jboss服务器的mail服务来完成的。Rhq安装过程中会要求用户填写smtp服务器地址、smtp服务器端口以及账户信息。但是对于某些需要授权信息的邮件服务器来说,这还是不够的,还需要修改其内置服务器中关于mail服务的相关配置。
mail服务的配置文件是%RHQ_Hom%e\jbossas\server\default\deploy下的mail-service.xml文件
修改前的实例:
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: mail-service.xml 62349 2007-04-15 16:48:15Z dimitris@jboss.org $ -->
<server>

<!-- RHQ Server Mail Connection Factory -->

<mbean code="org.jboss.mail.MailService"
name="jboss:service=Mail">
<attribute name="JNDIName">java:/Mail</attribute>
<attribute name="User">nobody</attribute>
<attribute name="Password">password</attribute>
<attribute name="Configuration">
<!-- A test configuration -->
<configuration>
<!-- Change to your mail server prototocol -->
<property name="mail.store.protocol" value="pop3"/>
<property name="mail.transport.protocol" value="smtp"/>

<!-- Change to the user who will receive mail -->
<property name="mail.user" value="nobody"/>

<!-- Change to the mail server -->
<property name="mail.pop3.host" value="pop3.nosuchhost.nosuchdomain.com"/>

<!-- Change to the SMTP gateway server -->
<property name="mail.smtp.host" value="${rhq.server.email.smtp-host:127.0.0.1}"/>

<!-- The mail server port -->
<property name="mail.smtp.port" value="${rhq.server.email.smtp-port:25}"/>

<!-- Change to the address mail will be from -->
<property name="mail.from" value="${rhq.server.email.from-address:rhqadmin@127.0.0.1}"/>

<!-- Enable debugging output from the javamail classes -->
<property name="mail.debug" value="false"/>
</configuration>
</attribute>
<depends>jboss:service=Naming</depends>
</mbean>

</server>


对于需要授权的smtp服务器,我们需要修改为以下实例:
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: mail-service.xml 62349 2007-04-15 16:48:15Z dimitris@jboss.org $ -->
<server>

<!-- RHQ Server Mail Connection Factory -->

<mbean code="org.jboss.mail.MailService"
name="jboss:service=Mail">
<attribute name="JNDIName">java:/Mail</attribute>
<attribute name="User">jombowang@gmail.com</attribute>
<attribute name="Password">****<!--修改为你的密码--></attribute>
<attribute name="Configuration">
<!-- A test configuration -->
<configuration>
<property name="mail.smtp.auth" value="true"/><!--这里很关键,对于需要授权的属性,需要增加此配置-->
<!-- Change to your mail server prototocol -->
<property name="mail.store.protocol" value="pop3"/>
<property name="mail.transport.protocol" value="smtp"/>

<!-- Change to the user who will receive mail -->
<property name="mail.user" value="nobody"/>

<!-- Change to the mail server -->
<property name="mail.pop3.host" value="pop3.nosuchhost.nosuchdomain.com"/>

<!-- Change to the SMTP gateway server -->
<property name="mail.smtp.host" value="${rhq.server.email.smtp-host:127.0.0.1}"/>

<!-- The mail server port -->
<property name="mail.smtp.port" value="${rhq.server.email.smtp-port:25}"/>

<!-- Change to the address mail will be from -->
<property name="mail.from" value="${rhq.server.email.from-address:rhqadmin@127.0.0.1}"/>

<!-- Enable debugging output from the javamail classes -->
<property name="mail.debug" value="false"/>
</configuration>
</attribute>
<depends>jboss:service=Naming</depends>
</mbean>

</server>



[b]场景简介[/b]
配置演示中RHQserver的公开地址为192.168.1.118,代理端的ip为127.0.0.1(就是本机),我们要实现的场景为RHQserver监控代理端的Jboss Server5.1实例,当Jboss Server出现宕机时,通过邮件的形式通知管理员。
首先我们选择Inventory->Server,找到对应的Jboss实例,选择Alert选项卡的Definition菜单, '

[img]http://dl.iteye.com/upload/attachment/602771/60bbdc56-a071-3da2-b913-b530f38a44ee.png[/img]

[img]http://dl.iteye.com/upload/attachment/602771/60bbdc56-a071-3da2-b913-b530f38a44ee.png[/img]
然后点击左下的“New”按钮,在页面填写基本的预警信息


[img]http://dl.iteye.com/upload/attachment/602804/b29cb606-26e6-38b9-9067-b8d84924a336.png[/img]

点击“Notifications”,NotifySender选择“Direct Mail”,输入对应的Email地址

[img]http://dl.iteye.com/upload/attachment/602806/03bacd70-649d-377b-b99c-a74915e0217e.png[/img]
下面选择预警条件

[img]http://dl.iteye.com/upload/attachment/602808/89694690-e2d9-397e-b83e-826f1247195a.png[/img]
最后点击下面的保存按钮。
接下来,我们暂停对应的jboss服务器。
稍等片刻,登陆我们的邮箱吧

[img]http://dl.iteye.com/upload/attachment/602845/c19b030c-dab6-3536-97cf-7a43edc380d4.png[/img]
 类似资料: