Hi,
Here is a Simple way to use WLDF (WebLogic Diagnostic Framework) to get E-Mail Notification…If the FreeHeapPercentage of the JVM goes less than 10 %.
Complete Steps can be Devided into 3-parts
A). Configuring a Mail-Session
B). Configuring WLDF Module
C). Configuring Watch And Notification
Part-A***Configuring a Mail-Session
Step1). We Need to create a Mail-Session From Admin Console:
Name: MyMailSession
MailSession JNDI Name: MyMailSessionJNDI
JavaMail Properties: (In your OutLook Options you will find the mailHost & UserName)
mail.smtp.host=myMailHost
mail.smtp.user=myMailUserName
Step2). Target your Mail Session to Any Server
AdminServer
Part-B *Configuring WLDF Module
Step1). From Admin Console Left Panel Navigate to Diagnostics–>Diagnostic Modules
Create a New DiagnosticModule
Name: MyDiagnosticModule —> Finish
Now Change the Tagret of MyDiagnosticModule to “AdminServer”
Step2). now click on newly created “MyDiagnosticModule” you will find a TAB in the new Page “Collected Metrics”
Create a New Collection Matrics- – – click on – – – NEXT
MBean Server location: ServerRuntime – – – NEXT
Select an MBean Type from the following list
MBean Type: weblogic.management.runtime.JVMRuntimeMBean – – – NEXT
Collected Attributes: Available HeapFreePercentage (choose) – – – NEXT – – –
Collected Instances: – Use the Arrow Button to Move the “com.bea:Name=AdminServer,ServerRuntime=AdminServer,Type=JVMRuntime”
– – FINISH
Now Change the Target of this (Collection Mertix) to AdminServer (Activate Changes/save)
Part-C Configuring Watch And Notification
Step1). In Admin Console (click on Lock & Edit Button) Now navigate to
Diagnostics–>Diagnostic Modules –> MyDiagnosticModule –> Watches and Notifications
Click on “Notifications” Tab to create a New Notofication click on :New” Button
Notification Name: MyNotification
Type: SMTP (E-Mail)
Enable Notification (Check the CheckBox) – – – NEXT
Mail Session Name: MyMailSession (remember we have Created this mail Session earlier in Part-A)
E-Mail Recipients: : i.am.recipient@company.com (Enter recipient’s Valid E-Mail Id Here)
FINISH Click on (Activate Changes/save Button)
Step2). In Admin Console (click on Lock & Edit Button) and navigate to
Diagnostics–>Diagnostic Modules –> MyDiagnosticModule –> Watches and Notifications
Click on “Watches” Tab to create a New Notofication click on :New” Button
Watch Name: MyWatch
Watch Type: Collection Metrics
Enable Watch (Check) – – – NEXT
In the Next page click on “Add Expressions” Button
MBean Server location: ServerRuntime – – – NEXT
Select an MBean Type from the following list (radio Button) :
MBean Type: weblogic.management.runtime.JVMRuntimeMBean – – – NEXT
Select an Instance from the following list: com.bea:Name=AdminServer,ServerRuntime=AdminServer,Type=JVMRuntime – – – NEXT
Select an attribute from the following list:
Message Attribute: HeapFreeCurrent
Operator: =
Value: 10
– – – FINISH
(It means we should get Alerts if the FreeHeapPercentage will be 10 . U can select any other operator as well like > < <= )
You will find the Current Watch Rule: Something like this: (${ServerRuntime//http://weblogic.management.runtime.JVMRuntimeMBeancom.bea:Name=AdminServer,ServerRuntime=AdminServer,Type=JVMRuntime//HeapFreeCurrent} = 10)
– – – NEXT (click on)
Use an automatic reset alarm (select the Radio Button) – – – NEXT
Notifications: Available MyNotification (Remember we have created this Notification) – – – FINISH
Press Activate Changes Button
.
.
———————————-
Thanks
Jay SenSharma
January 19th, 2010 on 6:13 pm
Hi Jay,
How can we configure WLDF notifications to check if the Admin Server is up? or not.
Also how can we configure the notifications in a scenario where we have only server in our domain???
Thanks,
Tanmay
January 26th, 2010 on 4:49 pm
bataya to tha phone par…
October 31st, 2017 on 8:14 pm
Hello Joy can you please help me out with this error we are getting on weblogic ..very important
We have been getting a stack trace error on all three servers what causes this acceptation and send me your conclusion.very imp we are not able to figure what is issue from 3 months
January 27th, 2010 on 8:35 pm
Hi Jay
Actually I am trying to set E-Mail Notification Using WLDF. But when I am trying to create the Notification, It doesnt allow me to write down anything on mail session name.
And i cant finish notification without giving any name to mail session. So you have any idea how to resolve it?
January 28th, 2010 on 8:46 am
Hi Pradeep,
I again tried ..following the Same steps…mentioned in the Blog…I am able to enter the Text Notification Name…
Anyway i have made some additional changes in the Steps mentioned in the Post sothat it would be easier for you to try it once again…Hope this time it will be OK.
Thanks
Jay SenSharma
January 27th, 2010 on 8:38 pm
And I really like the comment “bataya to tha phone par…’…..
And I really appreciate the way you are helping guys like me….
April 27th, 2010 on 8:31 pm
i am trying to configure email-notification when the instances including admin server goes down.
used Run time MBean: ServerRuntimeMBean
I am able to see that WLDF is generating and gathering this data, but it is unable to send notification to my smtp server. mailx from my solaris is working.
Immediate help is greatly appreciated.
April 27th, 2010 on 10:00 pm
Hi Mahesh,
WLDF is targeted to any perticular server. Suppose in your Case it is targeted to your AdminServer. As u want the E-Mail notification should be sent even when AdminServer goes down….which is not possible…because as soon as AdminServer starts shutting down it’s MBeans will start Deregistering.
But as an alternate way u can do the following:
Step 1). Write a CronJob in your Unix Based OS to execute the following Command at regular interval…to ping the Server/Servers….
java weblogic.Admin -url AdminHostName:7001 -username weblogic -password weblogic PING
java weblogic.Admin -url MS1HostName:7002 -username weblogic -password weblogic PING
Step 2). If you are not able to Ping the Server/Servers then using “mailx” utility Notify the Admins.
Please correct me if my understanding about your Issue is not correct.
.
.
Thanks
Jay SenSharma
April 28th, 2010 on 11:23 am
Below command basically uses “mailx” from Unix Os, so please check if this command exists on your system before executing below command.
You need to write exception handling try …catch there in the below script sothat as soon we are not able to connect to the Server…it will go to Catch block and Trigger an E-Mail…set a CRONJOB to run this script at a regular interval…
## START OF SCRIPT ##
connect(‘TestAdmin’,’TestAdminPassword’,’t3://localhost:7001′)
import os
os.system(‘mailx -s “CheckServer May not be Running” your@gmail.com < /tmp/ServerStatusMail.txt')
## END OF SCRIPT ##
April 28th, 2010 on 11:25 am
Hi Mahesh,
Below command basically uses “mailx” from Unix Os, so please check if this command exists on your system before executing below command.
You need to write exception handling try …catch there in the below script sothat as soon we are not able to connect to the Server…it will go to Catch block and Trigger an E-Mail…set a CRONJOB to run this script at a regular interval…
## START OF SCRIPT ##
connect(‘TestAdmin’,’TestAdminPassword’,’t3://localhost:7001′)
import os
os.system(‘mailx -s “CheckServer May not be Running” your@gmail.com < /tmp/ServerStatusMail.txt')
## END OF SCRIPT ##
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
April 29th, 2010 on 1:12 am
Hi Jay,
Can we target multiple modules to same server?
Is there any way to get the notifications if any one of the MS shutsdown or crashed?
Appreciate you reply.
Thanks,
Nilesh
April 29th, 2010 on 2:53 pm
Hi Nilesh,
Please configure the follwoing MailSession throusg AdminConsole
“config.xml”:
<mail-session>
<name>MailSession-0</name>
<target>AdminServer</target>
<jndi-name>MailSessionJNDI</jndi-name>
<properties>mail.smtp.user=jay.sensharma@oracle.com;mail.smtp.host=mail.oracle.com</properties>
</mail-session>
<admin-server-name>AdminServer</admin-server-name>
<wldf-system-resource>
<name>Module-0</name>
<descriptor-file-name>diagnostics/Module-0-3905.xml</descriptor-file-name>
<description></description>
</wldf-system-resource>
=================
The module file should look like following:
“diagnostics/Module-0-3905.xml”:
<?xml version=’1.0′ encoding=’UTF-8′?>
<wldf-resource xmlns=”http://www.bea.com/ns/weblogic/weblogic-diagnostics” xmlns:sec=”http://www.bea.com/ns/weblogic/90/security” xmlns:wls=”http://www.bea.com/ns/weblogic/90/security/wls” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”http://www.bea.com/ns/weblogic/weblogic-diagnostics http://www.bea.com/ns/weblogic/weblogic-diagnostics/1.1/weblogic-diagnostics.xsd“>
<name>Module-0</name>
<harvester>
<harvested-type>
<name>weblogic.management.runtime.ServerRuntimeMBean</name>
<harvested-attribute>ShuttingDown</harvested-attribute>
<harvested-instance>com.bea:Name=AdminServer,Type=ServerRuntime</harvested-instance>
<harvested-instance>com.bea:Location=AdminServer,Name=MS1,Type=ServerRuntime</harvested-instance>
<namespace>DomainRuntime</namespace>
</harvested-type>
</harvester>
<watch-notification>
<smtp-notification>
<name>MyNotification</name>
<enabled>true</enabled>
<mail-session-jndi-name>MailSessionJNDI</mail-session-jndi-name>
<subject>ALERT: Please Check Server may Be Shutting Down</subject>
<body xsi:nil=”true”></body>
<recipient>jay.sensharma@oracle.com</recipient>
</smtp-notification>
</watch-notification>
</wldf-resource>
.
.
Keep posting 🙂
Thanks
Jay SenSharma
May 9th, 2010 on 3:26 am
Sir,
I got the same problem which Nilesh is facing.
I tried the above config.xml and diag_module settings. But it didn’t work.
Should we define a watch for this??
As, When the conditions of a watch rule are met, the associated notification or notifications are sent.
I went ahead and while creating a watch for the same, in the last part
i.e.
Message Attribute: ShuttingDown
Operator: =
Value: MS1
– – – FINISH
But I am not sure about the Value: MS1 here.
here’s my diag_module.xml part
W1
true
Harvester
(${ServerRuntime//[weblogic.management.runtime.ServerRuntimeMBean]com.bea:Name=AdminServer,Type=ServerRuntime//ShuttingDown} = ‘MS1’) OR (${ServerRuntime//[weblogic.management.runtime.ServerRuntimeMBean]com.bea:Name=AdminServer,Type=ServerRuntime//ShuttingDown} = ‘MS2’)
AutomaticReset
30000
notify
notify
true
MS1
ALERT: Please Check Server may Be Shutting Down
shivam.saraiya@gmail.com
April 29th, 2010 on 3:13 pm
I Forgot to mention one thing in the XMl file…..Just Target “module-0” to the AdminServer as well.. then restart the Env.
April 29th, 2010 on 1:16 am
Just to be more specific ,is there any way to get notifications if any of the MS of the cluster shuts down?
Thanks,
Nilesh
May 14th, 2010 on 6:15 am
Thanks for your sharing, I try your solution as steps, but i want to monitor server site’s exception. then has two issues:
1.only Admin server’s exception was catched, other server like SOA,BAM are not.
2.my SMTP sever has password for user, how should I config?
October 26th, 2010 on 4:40 pm
Bravo, its working.
Just now tested on local James mail server it is working fine.
Do we have such feature on JBoss?
Thanks,
Tanmoy Roy
October 26th, 2010 on 6:00 pm
Ok, now it is working on JBoss.
Here is the link
http://community.jboss.org/wiki/JBossMonitoring
Thanks,
Tanmoy Roy
February 8th, 2012 on 2:19 pm
Hi,
I created a similar module but checking the log for Stuck Thread (MSGID = ‘BEA-000337’) but it never worked. The error would be there in the admin log but the watch rule would not detect it. I tested with other codes such as shutting down a MS and the watch rule worked.
Think I will use WLST Scripts to do this.
August 5th, 2013 on 1:00 am
I am not getting instances of running severs while configuring collected metrics.
Eg: com.bea:Name=AdminServer,ServerRuntime=AdminServer,Type=JVMRuntime
Please help.
September 3rd, 2013 on 12:02 pm
Good Day Jay!
Thanks for you instruction. It was helpful.
I have problem, e-mail notification do not send to my mail address.
I checked what smtp works on OS (Solaris).
How can i understand why not work notification?
Using WLDF i try to check state BAM Server. Server state must be shutdown then send notification.
With best regards Alexander!
September 30th, 2015 on 3:09 pm
Hi, i have been reading articles from your page looking for an answer to my problem. But still no luck.
Im currently using WLS 10.3.6.0 and i need to setup a Watch and Notification (SMTP)
I finally got it all working without any errors on the log, the watch is being triggered, no Mail Session errors, it looks like an E-mail is beint sent but i still can’t receive no emails. Do you have a solution for this? Im hoping you could help me. Thank you.
April 5th, 2017 on 5:21 am
Hi Joy,
I have configured the mail session , watch and notification and done the appropriate targeting.
But when a node goes down not its not trigging any email notification.
As a checked used the telnet command from the server and getting the emails.
=================
telnet smtp.xxxx.yyy.com 25
MAIL FROM:xxxx@gmail.com
RCPT TO:sanjib@gmail.com
DATA
=====================
Notice the below error at weblogic level while starting.
Do we need to configure javamail api. Can you share the details.
===================
DEBUG: JavaMail version 1.4ea
DEBUG: java.io.FileNotFoundException: /opt/local/jre1.6.0_29/lib/javamail.providers (No such file or directory)
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.providers
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}
DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]}
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.address.map
DEBUG: java.io.FileNotFoundException: /opt/local/jre1.6.0_29/lib/javamail.address.map (No such file or directory)
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
April 5th, 2017 on 6:18 am
Hello Sanjib,
In your posted log snippet i only see the DEBUG messages (No Error), Those debug messages are fine (even though you see some exception there) those are ignorable as we can see such debug message in any working setup as well.
Looks like you are using incorrect port for gmail smtp server. Please make sure to use the following properties (Specially the port as 587 instead of using default port 25)
Regards
Jay SenSharma
April 12th, 2017 on 3:26 am
Hi Jay,
Thanks for your reply.
I am not using gmail id for notification. Instead its the client mail id and it uses default smtp port 25.
So can you suggest any other troubleshooting step.
Thanks
Sanjib