7 Replies Latest reply on Jan 27, 2020 2:31 PM by Martien van den Akker

    To be notify  of  les warning Logs

    Sanae

      Hello ,

      How can I configure an e-mail notification of all warnings published in the managed_servers log level , please ?

      Like  this real case, how to configure an email notification of warnings <warning> BEA-000000 ?

        Avertissement_osb.PNG

      Thanks  in advance ,

       

      Best Regards ,

      Sanae

        • 1. Re: To be notify  of  les warning Logs
          Raj__K

          Hi, For your requirment, Oracle EM can be used. It has the capability to monitor and then alert through email channel based on a string pattern.

           

          Regards!

          • 2. Re: To be notify  of  les warning Logs
            Sanae

            Hello,

             

            How can I configure it , please ?

            We needed that a specially for a <warning> which is displayed in  the OSB and SOA  Logs .

             

            Thanks in advance ,

            Best Regards !

            • 3. Re: To be notify  of  les warning Logs
              Martien van den Akker

              Hi,

               

              I think this should be done with the Weblogic Diagnostic Framework, and precisely Policy and Actions: https://translate.google.com/translate?hl=nl&sl=en&u=https://docs.oracle.com/middleware/1221/wls/WLDFC/config_watch_noti…

              I created an example WLST script to configure a diagnostic module, with a policy and a JMS action, but I should write an article about it:

               

              #############################################################################
              # Create a diagnostic Module for WLS 12c Tuning & Troubleshooting workshop
              # Lab 06
              #
              # @author Martien van den Akker, Darwin-IT Professionals
              # @version 1.0, 2019-10-08
              #
              #############################################################################
              # Modify these values as necessary
              import os,sys, traceback
              #
              adminHost=os.environ["ADM_HOST"]
              adminPort=os.environ["ADM_PORT"]
              admServerUrl = 't3://'+adminHost+':'+adminPort
              #
              adminUser='weblogic'
              adminPwd='welcome1'
              ttServerName=os.environ["TTSVR_NAME"]
              diagModuleName='TTDiagnostics'
              #
              def getMServer(serverName):
                server=getMBean('/Servers/'+serverName)
                return server
              #
              def createDiagnosticModule(diagModuleName, targetServerName):
                module=getMBean('/WLDFSystemResources/'+diagModuleName)
                if module==None:
                  print 'Create new Diagnostic Module'+diagModuleName
                  edit()
                  startEdit()
                  cd('/')
                  module = cmo.createWLDFSystemResource(diagModuleName)
                  targetServer=getMServer(targetServerName)
                  module.addTarget(targetServer)
                  # Activate changes
                  save()
                  activate(block='true')
                  print 'Diagnostic Module created successfully.'
                else:
                  print 'Diagnostic Module'+diagModuleName+' already exists!'
                return module
              #
              def createCollector(diagModuleName, metricType, namespace, harvestedInstances,attributesCsv):
                harvesterName='/WLDFSystemResources/'+diagModuleName+'/WLDFResource/'+diagModuleName+'/Harvester/'+diagModuleName
                harvestedTypesPath=harvesterName+'/HarvestedTypes/';
                print 'Check Collector '+harvestedTypesPath+metricType
                collector=getMBean(harvestedTypesPath+metricType)
                if collector==None:
                  print 'Create new Collector for '+metricType+' in '+diagModuleName
                  edit()
                  startEdit()
                  cd(harvestedTypesPath)
                  collector=cmo.createHarvestedType(metricType)
                  cd(harvestedTypesPath+metricType)
                  attributeArray=jarray.array([String(x.strip()) for x in attributesCsv.split(',')], String)
                  collector.setHarvestedAttributes(attributeArray)
                  collector.setHarvestedInstances(harvestedInstances)
                  collector.setNamespace(namespace)
                  # Activate changes
                  save()
                  activate(block='true')
                  print 'Collector created successfully.'
                else:
                  print 'Collector '+metricType+' in '+diagModuleName+' already exists!'
                return collector
              #
              def createJmsNotificationAction(diagModuleName, actionName, destination, connectionFactory):
                policiesActionsPath='/WLDFSystemResources/'+diagModuleName+'/WLDFResource/'+diagModuleName+'/WatchNotification/'+diagModuleName
                jmsNotificationPath=policiesActionsPath+'/JMSNotifications/'
                print 'Check notification action '+jmsNotificationPath+actionName
                jmsNtfAction=getMBean(jmsNotificationPath+actionName)
                if jmsNtfAction==None:
                  print 'Create new JMS NotificationAction '+actionName+' in '+diagModuleName
                  edit()
                  startEdit()
                  cd(policiesActionsPath)
                  jmsNtfAction=cmo.createJMSNotification(actionName)
                  jmsNtfAction.setEnabled(true)
                  jmsNtfAction.setTimeout(0)
                  jmsNtfAction.setDestinationJNDIName(destination)
                  jmsNtfAction.setConnectionFactoryJNDIName(connectionFactory)
                  # Activate changes
                  save()
                  activate(block='true')
                  print 'JMS NotificationAction created successfully.'
                else:
                  print 'JMS NotificationAction '+actionName+' in '+diagModuleName+' already exists!'
                return jmsNtfAction
              def createPolicy(diagModuleName, policyName, ruleType, ruleExpression, actions):
                policiesActionsPath='/WLDFSystemResources/'+diagModuleName+'/WLDFResource/'+diagModuleName+'/WatchNotification/'+diagModuleName
                policiesPath=policiesActionsPath+'/Watches/'
                print 'Check Policy '+policiesPath +policyName
                policy=getMBean(policiesPath +policyName)
                if policy==None:
                  print 'Create new Policy '+policyName+' in '+diagModuleName
                  edit()
                  startEdit()
                  cd(policiesActionsPath)
                  policy=cmo.createWatch(policyName)
                  #cd('/WLDFSystemResources/TTDiagnostics/WLDFResource/TTDiagnostics/WatchNotification/TTDiagnostics/Watches/HiStuckThreads')
                  policy.setEnabled(true)
                  policy.setExpressionLanguage('EL')
                  policy.setRuleType(ruleType)
                  policy.setRuleExpression(ruleExpression)
                  policy.setAlarmType('AutomaticReset')
                  policy.setAlarmResetPeriod(300000)
                  cd(policiesPath +policyName)
                  set('Notifications', actions)
                  schedule=getMBean(policiesPath +policyName+'/Schedule/'+policyName)
                  #cd('/WLDFSystemResources/TTDiagnostics/WLDFResource/TTDiagnostics/WatchNotification/TTDiagnostics/Watches/HiStuckThreads/Schedule/HiStuckThreads')
                  schedule.setMinute('*')
                  schedule.setSecond('*')
                  schedule.setSecond('*/15')
                  # Activate changes
                  save()
                  activate(block='true')
                  print 'Policy created successfully.'
                else:
                  print 'Policy '+policyName+' in '+diagModuleName+' already exists!'
                return policy
              #
              def main():
                try:
                  print 'Connect to '+admServerUrl
                  connect(adminUser,adminPwd,admServerUrl)
                  createDiagnosticModule(diagModuleName, ttServerName)
                  createCollector(diagModuleName, 'weblogic.management.runtime.JDBCDataSourceRuntimeMBean','ServerRuntime', None, 'ActiveConnectionsCurrentCount,CurrCapacity,LeakedConnectionCount')
                  harvestedInstancesList=[]
                  harvestedInstancesList.append('com.bea:ApplicationRuntime=medrec,Name=TTServer_/medrec,ServerRuntime=TTServer,Type=WebAppComponentRuntime')
                  harvestedInstances=jarray.array([String(x.strip()) for x in harvestedInstancesList], String)  
                  createCollector(diagModuleName, 'weblogic.management.runtime.WebAppComponentRuntimeMBean','ServerRuntime', harvestedInstances,'OpenSessionsCurrentCount')
                  createJmsNotificationAction(diagModuleName, 'JMSAction', 'com.tt.jms.WLDFNotificationQueue', 'weblogic.jms.ConnectionFactory')
                  actionsList=[]
                  actionsList.append('com.bea:Name=JMSAction,Type=weblogic.diagnostics.descriptor.WLDFJMSNotificationBean,Parent=[TTDomain]/WLDFSystemResources[TTDiagnostics],Path=WLDFResource[TTDiagnostics]/WatchNotification[TTDiagnostics]/JMSNotifications[JMSAction]')
                  actions=jarray.array([ObjectName(action.strip()) for action in actionsList], ObjectName)  
                  createPolicy(diagModuleName,'HiStuckThreads', 'Harvester', 'wls:ServerHighStuckThreads(\"30 seconds\",\"10 minutes\",5)', actions)
                  ruleExpression='wls:ServerGenericMetricRule(\"com.bea:Name=MedRecGlobalDataSourceXA,ServerRuntime=TTServer,Type=JDBCDataSourceRuntime\",\"WaitingForConnectionHighCount\",\">\",0,\"30 seconds\",\"10 minutes\")'
                  createPolicy(diagModuleName,'OverloadedDS', 'Harvester', ruleExpression, actions)
                  disconnect()
                  print("\nExiting...")
                  exit()
                except:
                  apply(traceback.print_exception, sys.exc_info())
                  exit(exitcode=1)
              #
              #call main()
              main()
              #############################################################################
              # Create a diagnostic Module for WLS 12c Tuning & Troubleshooting workshop
              # Lab 06
              #
              # @author Martien van den Akker, Darwin-IT Professionals
              # @version 1.0, 2019-10-08
              #
              #############################################################################
              # Modify these values as necessary
              import os,sys, traceback
              #
              adminHost=os.environ["ADM_HOST"]
              adminPort=os.environ["ADM_PORT"]
              admServerUrl = 't3://'+adminHost+':'+adminPort
              #
              adminUser='weblogic'
              adminPwd='welcome1'
              ttServerName=os.environ["TTSVR_NAME"]
              diagModuleName='TTDiagnostics'
              #
              def getMServer(serverName):
                server=getMBean('/Servers/'+serverName)
                return server
              #
              def createDiagnosticModule(diagModuleName, targetServerName):
                module=getMBean('/WLDFSystemResources/'+diagModuleName)
                if module==None:
                  print 'Create new Diagnostic Module'+diagModuleName
                  edit()
                  startEdit()
                  cd('/')
                  module = cmo.createWLDFSystemResource(diagModuleName)
                  targetServer=getMServer(targetServerName)
                  module.addTarget(targetServer)
                  # Activate changes
                  save()
                  activate(block='true')
                  print 'Diagnostic Module created successfully.'
                else:
                  print 'Diagnostic Module'+diagModuleName+' already exists!'
                return module
              #
              def createCollector(diagModuleName, metricType, namespace, harvestedInstances,attributesCsv):
                harvesterName='/WLDFSystemResources/'+diagModuleName+'/WLDFResource/'+diagModuleName+'/Harvester/'+diagModuleName 
                harvestedTypesPath=harvesterName+'/HarvestedTypes/';
                print 'Check Collector '+harvestedTypesPath+metricType
                collector=getMBean(harvestedTypesPath+metricType)
                if collector==None:
                  print 'Create new Collector for '+metricType+' in '+diagModuleName
                  edit()
                  startEdit()
                  cd(harvestedTypesPath)
                  collector=cmo.createHarvestedType(metricType)
                  cd(harvestedTypesPath+metricType)
                  attributeArray=jarray.array([String(x.strip()) for x in attributesCsv.split(',')], String)
                  collector.setHarvestedAttributes(attributeArray)
                  collector.setHarvestedInstances(harvestedInstances)
                  collector.setNamespace(namespace)
                  # Activate changes
                  save()
                  activate(block='true')
                  print 'Collector created successfully.'
                else:
                  print 'Collector '+metricType+' in '+diagModuleName+' already exists!'
                return collector
              #
              def createJmsNotificationAction(diagModuleName, actionName, destination, connectionFactory):
                policiesActionsPath='/WLDFSystemResources/'+diagModuleName+'/WLDFResource/'+diagModuleName+'/WatchNotification/'+diagModuleName
                jmsNotificationPath=policiesActionsPath+'/JMSNotifications/'
                print 'Check notification action '+jmsNotificationPath+actionName
                jmsNtfAction=getMBean(jmsNotificationPath+actionName)
                if jmsNtfAction==None:
                  print 'Create new JMS NotificationAction '+actionName+' in '+diagModuleName
                  edit()
                  startEdit()
                  cd(policiesActionsPath)
                  jmsNtfAction=cmo.createJMSNotification(actionName)
                  jmsNtfAction.setEnabled(true)
                  jmsNtfAction.setTimeout(0)
                  jmsNtfAction.setDestinationJNDIName(destination)
                  jmsNtfAction.setConnectionFactoryJNDIName(connectionFactory)
                  # Activate changes
                  save()
                  activate(block='true')
                  print 'JMS NotificationAction created successfully.'
                else:
                  print 'JMS NotificationAction '+actionName+' in '+diagModuleName+' already exists!'
                return jmsNtfAction
                
              
              def createPolicy(diagModuleName, policyName, ruleType, ruleExpression, actions):  
                policiesActionsPath='/WLDFSystemResources/'+diagModuleName+'/WLDFResource/'+diagModuleName+'/WatchNotification/'+diagModuleName
                policiesPath=policiesActionsPath+'/Watches/'
                print 'Check Policy '+policiesPath +policyName
                policy=getMBean(policiesPath +policyName)
                if policy==None:
                  print 'Create new Policy '+policyName+' in '+diagModuleName
                  edit()
                  startEdit()
                  cd(policiesActionsPath)
                  policy=cmo.createWatch(policyName)
                  #cd('/WLDFSystemResources/TTDiagnostics/WLDFResource/TTDiagnostics/WatchNotification/TTDiagnostics/Watches/HiStuckThreads')
                  policy.setEnabled(true)
                  policy.setExpressionLanguage('EL')
                  policy.setRuleType(ruleType)
                  policy.setRuleExpression(ruleExpression)
                  policy.setAlarmType('AutomaticReset')
                  policy.setAlarmResetPeriod(300000)
                  cd(policiesPath +policyName)
                  set('Notifications', actions)
                  schedule=getMBean(policiesPath +policyName+'/Schedule/'+policyName)
                  #cd('/WLDFSystemResources/TTDiagnostics/WLDFResource/TTDiagnostics/WatchNotification/TTDiagnostics/Watches/HiStuckThreads/Schedule/HiStuckThreads')
                  schedule.setMinute('*')
                  schedule.setSecond('*')
                  schedule.setSecond('*/15')
                  # Activate changes
                  save()
                  activate(block='true')
                  print 'Policy created successfully.'
                else:
                  print 'Policy '+policyName+' in '+diagModuleName+' already exists!'
                return policy
              #
              def main():
                try:
                  print 'Connect to '+admServerUrl
                  connect(adminUser,adminPwd,admServerUrl)
                  createDiagnosticModule(diagModuleName, ttServerName)
                  createCollector(diagModuleName, 'weblogic.management.runtime.JDBCDataSourceRuntimeMBean','ServerRuntime', None, 'ActiveConnectionsCurrentCount,CurrCapacity,LeakedConnectionCount')
                  harvestedInstancesList=[]
                  harvestedInstancesList.append('com.bea:ApplicationRuntime=medrec,Name=TTServer_/medrec,ServerRuntime=TTServer,Type=WebAppComponentRuntime')
                  harvestedInstances=jarray.array([String(x.strip()) for x in harvestedInstancesList], String)    
                  createCollector(diagModuleName, 'weblogic.management.runtime.WebAppComponentRuntimeMBean','ServerRuntime', harvestedInstances,'OpenSessionsCurrentCount') 
                  createJmsNotificationAction(diagModuleName, 'JMSAction', 'com.tt.jms.WLDFNotificationQueue', 'weblogic.jms.ConnectionFactory')
                  actionsList=[]
                  actionsList.append('com.bea:Name=JMSAction,Type=weblogic.diagnostics.descriptor.WLDFJMSNotificationBean,Parent=[TTDomain]/WLDFSystemResources[TTDiagnostics],Path=WLDFResource[TTDiagnostics]/WatchNotification[TTDiagnostics]/JMSNotifications[JMSAction]')
                  actions=jarray.array([ObjectName(action.strip()) for action in actionsList], ObjectName)    
                  createPolicy(diagModuleName,'HiStuckThreads', 'Harvester', 'wls:ServerHighStuckThreads(\"30 seconds\",\"10 minutes\",5)', actions)
                  ruleExpression='wls:ServerGenericMetricRule(\"com.bea:Name=MedRecGlobalDataSourceXA,ServerRuntime=TTServer,Type=JDBCDataSourceRuntime\",\"WaitingForConnectionHighCount\",\">\",0,\"30 seconds\",\"10 minutes\")'
                  createPolicy(diagModuleName,'OverloadedDS', 'Harvester', ruleExpression, actions)
                  disconnect()
                  print("\nExiting...")
                  exit()
                except:
                  apply(traceback.print_exception, sys.exc_info())
                  exit(exitcode=1)
              #
              #call main()
              main()
              

               

               

              So this Creates an JMS action, and a policy to whatch a JDBC DatasourceRuntime to check the WaitingForConnectionHighCount mbean attribute. If that fires, then a jms message is writen.

              Now, in your case you should find out what warnings you want to react on, and find out a rule expression to react upon. Besides a jms action you can also create an email action. And then thigh those together.

               

              Hope this helps.

               

              Kind regards,
              Martien

              • 4. Re: To be notify  of  les warning Logs
                Raj__K

                Hi, Following is a Oracle Enterprise Manager Cloud Control link with details about how log files can be monitored and Alerts will get raised when a specific pattern is logged. Please go through it, it is easy to follow.

                    https://docs.oracle.com/cd/E73210_01/EMADM/GUID-5135BC06-BC1E-4901-9470-1E05ED0F12B9.htm#EMADM13318

                   

                Regards!

                • 5. Re: To be notify  of  les warning Logs
                  Martien van den Akker

                  That is cool. By the way, I just wrote an article about my script: http://bit.ly/2tMJ1Kv

                   

                  Kind Regards,
                  Martien

                  • 6. Re: To be notify  of  les warning Logs
                    Sanae

                    Great thanks , Martien   

                    I try to implement  your script to be notified  of the Warning  in our servers  logs .It will be more helpful for monitoring .

                    Kind regards ,

                    Sanae

                    • 7. Re: To be notify  of  les warning Logs
                      Martien van den Akker

                      You're welcome!

                       

                      If you have snippets for certain policies and email actions, I'd appreciate it if you could share them.

                      It could become a great toolset.

                       

                      Kind regards,
                      Martien

                      1 person found this helpful