Oracle Service Bus 11g: statistics projects and services with WLST – part 2

Hi all

As a follow-up on my earlier blogpost about how to list all your projects and services in your OSB domain, I’ve extended the script with some count statistics. Look at this screenshot below. I blacked out the names for the services.

Knipsel

 

In the example I’ve used I extended it with some statistic counts on some Proxy services. Now at this moment the script errors out on non monitored services, but that is because I did not implement a check if a service is monitored or not. Which should be done by checking if the value of isMonitoringEnabled in the CommonServiceConfigurationMBean is set to true.

Look below at some of the code. The first section is to get the list of projects and their proxy or business services (in my example I used proxy services). With a for loop on the getAllResourceStatistics method I filtered out the statistics I’d like to see: some counts about pipeline and SLA.

codeOSBstats

Now this is of course a beginning, you can build, customize and cosmetize your script to you own needs with all kinds of colors for high error rates. For example you can implement an if statement if your error rates raise above a certain level and colorize it with terminal colours (red '33[1;31m').

My next challenge is to filter out those services which are not enabled for monitoring, but that will be for a next time. And again, if you like to have the code, drop me an email.

OVER DE AUTEUR

Started in pharmacy, Michel made the change to IT in 1996, on a UNIX TTY terminal based computer and the MUMPS language. These days he is an Oracle Fusion Middleware Architect at Qualogy, as member of the Exalogic Squad team, with focus on technical infrastructure, Serverside solutions, installing, administering, configuring the Oracle Fusion Middleware stack. He started in 2000 as a support analyst for a big bank with BEA Tuxedo 6.5 and WebLogic 6. His experience is from integrations at telco´s. He now works mainly with Oracle WebLogic 11g and 12c, plus releases with practically all Oracle products running on top of it. In 2012 he became an Oracle ACE and wrote 2 books about WebLogic: http://www.packtpub.com/oracle-weblogic-server-11gr2-administration-essentials/book http://www.packtpub.com/oracle-weblogic-server-12c-first-look/book.

35 Reacties op Oracle Service Bus 11g: statistics projects and services with WLST – part 2

  1. Elvedin schreef:

    Hi,

    Thax for investing time in such useful things. Can you share with me the script as well.

    Thank you

  2. Enio machado schreef:

    Hi Michel,
    Can you share with me the script?

    Thank you,
    Enio

  3. Praful schreef:

    Hi Michel,

    can you please share the code for this too.

    thanks,
    Praful

  4. Norberto Enomoto schreef:

    Hi Michel,

    Excellent work.
    Can you please share the code.

    Thanks,

    Norberto Enomoto

  5. Ronen schreef:

    Hi Michel,
    can you please share the code for this too.
    thanks,
    Ronen

  6. Brian Orozco schreef:

    This is very useful. I’m beginning with WLST and could use the source from both parts 1 and 2 as a reference. Please send both.

    Thanks.

    -Brian

  7. Hi Michel schreef:

    Hi Michel

    Can you please send me the script for part 2.

    Thanks,
    Rooswald

  8. Reper Arnaud schreef:

    Nice post! Great job! I’m actually looking in howto export the pipeline alerts out of the console. Could you share me your WLST script as a starting point? Which libraries should be added to the setWLSEnv? I’m missing the ServiceDomainMBean and some other MBean.

    Tyia,

    AR

  9. Elvedin schreef:

    Hi,

    Thanx for update. Can you share script with me as well.

    Thank you

  10. ck schreef:

    please share the code
    txs for your time

  11. TML schreef:

    Very interesting. I kept running into issues using jmx in Java, so a pure WLST approach would be nice. Could you email me the script please?

  12. Luiz schreef:

    Hi Michel,

    Could you please send me the code?
    Thanks.
    Luiz.

  13. Amol Trigune schreef:

    Hi Michel,

    Could you please send me the code?
    Thanks.
    Amol Trigune

  14. Amol Trigune schreef:

    Hi Michel,

    I preparing monitoring script for our domain, but i am stuck because of following error.

    Proxy service : FinnoneCollections_OSB_Integration/Resources/AlertDestinations/polling service
    Traceback (innermost last):
    File “”, line 1, in ?
    File “OSBPROXY.py”, line 27, in ?
    com.bea.wli.monitoring.MonitoringException: [MonitoringRuntime:473057]Failed to get statistics for services due to java.rmi.UnknownHostException: Could not discover administration U
    RL for server ‘osb_server1′
    at com.bea.wli.monitoring.ServiceDomain.getStatisticsForServices(ServiceDomain.java:849)
    at com.bea.wli.monitoring.ServiceDomain.getServiceStatistics(ServiceDomain.java:684)
    at com.bea.wli.monitoring.ServiceDomain.getProxyServiceStatistics(ServiceDomain.java:428)
    at com.bea.wli.monitoring.DelegatedServiceDomainMBeanImpl.getProxyServiceStatistics(DelegatedServiceDomainMBeanImpl.java:53)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    Thanks & Regards,
    Amol Trigune

    • Michel schreef:

      Hi Amol
      It seems like either:
      Your AdminServer url is either wrong or unreachable.
      It should be t3://:
      Could you send me the content of your script?

      kind regards

      Michel
      Kind regards

  15. Michel schreef:

    format should be t3://:

  16. Amol Trigune schreef:

    Hi Michel,

    I have prepared script using your blog, Here is code of same.

    import time
    import sys
    username=’weblogic’
    password=’weblogic123′
    url = ‘t3://192.168.6.205:7001′
    connect(username, password,url)
    from com.bea.wli.sb.management.configuration import ALSBConfigurationMBean
    from com.bea.wli.config import Ref
    from java.lang import String
    from com.bea.wli.config import Ref
    from com.bea.wli.sb.util import Refs
    from com.bea.wli.sb.management.configuration import CommonServiceConfigurationMBean
    from com.bea.wli.sb.management.configuration import SessionManagementMBean
    from com.bea.wli.sb.management.configuration import ProxyServiceConfigurationMBean
    from com.bea.wli.monitoring import StatisticType
    from com.bea.wli.monitoring import ServiceDomainMBean
    from com.bea.wli.monitoring import ServiceResourceStatistic
    from com.bea.wli.monitoring import StatisticValue
    from com.bea.wli.monitoring import ResourceType
    saveout = sys.stdout
    LogFile = open(‘/home/osb/scrOutput/PROXY_SERVICES.csv’, ‘a’)
    sys.stdout = LogFile
    domainRuntime()
    alsbCore = findService(ALSBConfigurationMBean.NAME, ALSBConfigurationMBean.TYPE)
    refs=alsbCore.getRefs(Ref.DOMAIN)
    it = refs.iterator()
    while it.hasNext():
    r = it.next()
    if r.getTypeId() == Ref.PROJECT_REF:
    print “Project Nam3 : “+(r.getProjectName())
    allRefs= alsbCore.getRefs(Ref.DOMAIN)
    for ref in refs:
    typeId = ref.getTypeId()
    if typeId == “ProxyService”:
    print “Proxy Sevice : ” + ref.getFullName ()
    cd(‘domainRuntime:/DomainServices/ServiceDomain’)
    stat = cmo.getProxyServiceStatistics([ref],ResourceType.SERVICE.value(),”)
    for ps in stat[ref].getAllResourceStatistics():
    for s in ps.getStatistics():
    if s.getType() == StatisticType.COUNT:
    CType = str(s.getType())
    CCount = str(s.getCount())
    print s.getName() + “(“+str(s.getType()) +”: ” + str(s.getCount())
    if s.getType() == StatisticType.INTERVAL:
    print s.getName() + “(“+str(s.getType()) +”: ” + str(s.getMin()) + ” ” + str(s.getMax()) + ” ” + str(s.getAvrage())
    IType = str(s.getType())
    IMin = str(s.getMin())
    Imax = str(s.getMax())
    IAverage = str(s.getAvrage())
    if s.getType() == StatisticType.STATUS:
    print s.getName() + “(“+str(s.getType()) +”: ” + str(s.getCurrentStatus())
    SType = str(s.getType())
    SCrState = str(s.getCurrentStatus())
    Print ref.getFullName ()+’,’+ SType +’,’+ CCount +’,’+ IMin +’,’+ Imax +’,’+ IAverage
    sys.stdout = saveout
    LogFile.close()
    disconnect()

    Regards
    Amol Trigune

    • Michel schreef:

      Please look at url: = ‘t3://192.168.6.205:7001′

      On which host is your osb_server1 running? On the same host as the WLS AdminServer?
      If yes, is the above IP valid
      If it runs on a separate host, is it reachable?

      kind regards

      Michel

  17. Amol Trigune schreef:

    Hi Michel,

    I have solved that error. It is because of in our test environment we have configured cluster for OSB. After starting both instance script is working fine.

    Regards,
    Amol Trigune

  18. Amol Trigune schreef:

    Hi Michel,

    Using above script we get statistics collected since last reset.
    Is there any way to collect current statistics.

    Thanks and Regards,
    Amol Trigune

  19. matias schreef:

    Hi Michel,

    do you know if exist a way to enable messaging tracing from wlst?

    regards

  20. Suman schreef:

    Hi Michel,

    Can you please send me the Script code?

    Thanks and Regards,
    Suman V

  21. Rodrigo Melgar schreef:

    Hi Michel, can you please share the code for this too. you save me :D

    Thanks Man

  22. Brandon schreef:

    Another great post. Thanks for the quick response on the other request. Code for this too please. :)

  23. Najam schreef:

    Please share the script and the code

    Thanks

  24. Hello, could give me the code, including the validation if this enabled the monitoring of the service.
    Thanks.

    juliocri

  25. Saqib schreef:

    Hi
    I am getting following error while excuting upper script

    [oracle@tsi-admin-dev-1 tsi_dev]$ java weblogic.WLST script.py

    Initializing WebLogic Scripting Tool (WLST) …

    Welcome to WebLogic Server Administration Scripting Shell

    Type help() for help on available commands

    Problem invoking WLST – Traceback (innermost last):
    (no code object) at line 0
    File “/u01/app/oracle/10.3.6/user_projects/domains/tsi_dev/script.py”, line 25
    r = it.next()
    ^
    SyntaxError: invalid syntax

  26. Saqib schreef:

    It will be good if you could share script with me via email

  27. Saqib schreef:

    I just copy and paste the upper script which Amol send to you for verification

    Please send me the script and code and kindly tell me the steps how to run that. Thanks a bunch

  28. Saqib schreef:

    Hi

    First of all Thanks could you please let me know the way to run the script , i am doing following procedure to run the attached script.

    1. first i run this command

    source setDomainEnv.sh

    2. java weblogic.WLST osbstats.py

    After running the script which you sent to me i am getting following error ….. please help me in that

    Initializing WebLogic Scripting Tool (WLST) …

    Welcome to WebLogic Server Administration Scripting Shell

    Type help() for help on available commands

    Problem invoking WLST – Traceback (innermost last):
    (no code object) at line 0
    File “/u01/app/oracle/10.3.6/user_projects/domains/tsi_dev/osbstats.py”, line 65
    if s.getType() == StatisticType.STATUS:
    ^
    SyntaxError: invalid syntax

    Regards

    Saqib

  29. Saqib schreef:

    Still waiting for your kind reply on above post……….

Geef een reactie

Het e-mailadres wordt niet gepubliceerd. Verplichte velden zijn gemarkeerd met *

De volgende HTML-tags en -attributen zijn toegestaan: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Contact

Hebt u vragen of suggesties?

Mail info@qualogy.com!


De Bruyn Kopsstraat 9

2288EC Rijswijk (ZH)

The Netherlands

+31.(0)70 319 5000

  • Blog

  • Tags

  • @qualogy_news

  • @qresources

  • Reacties

  • Blijf in contact

    +31.(0)70 319 5000