selfdiagnose
DESCRIPTION
SelfDiagnose. “who is to blame” ernest micklei, April 2007. Overview. Motivation Introduction Demo Quick steps Expert use. Motivation. Some application problems are related to: Configuration Availability Logging not always pinpoints the cause level (debug) exception encapsulation - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/1.jpg)
SelfDiagnose
“who is to blame”
ernest micklei, April 2007
![Page 2: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/2.jpg)
selfdiagnose.sourceforge.net
Overview
Motivation Introduction Demo Quick steps Expert use
![Page 3: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/3.jpg)
selfdiagnose.sourceforge.net
Motivation Some application problems are related to:
Configuration Availability
Logging not always pinpoints the cause level (debug) exception encapsulation “only when it happens”
![Page 4: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/4.jpg)
selfdiagnose.sourceforge.net
Problem causes
Non-matching names in JNDI Absent properties, files Missing bindings in JNDI No access to database,queue,host Missing classes on runtime classpath Missing System properties ….
![Page 5: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/5.jpg)
selfdiagnose.sourceforge.net
Problem revealings
An error has occurred SEVERE Could not start /myapp DB2 SQL-ERROR 10493 Log4j shutting down
![Page 6: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/6.jpg)
selfdiagnose.sourceforge.net
Who wants to know?
Development Is my configuration correct?
Application Server admin Is their configuration correct? Is my deployment script correct?
Maintenance Are all (detectable) resources available?
Functional Maintenance
![Page 7: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/7.jpg)
selfdiagnose.sourceforge.net
SelfDiagnose
SelfDiagnose is a library of diagnotistic tasks that can verify the availability of resources
Application “itself” runs diagnose
Open-source Java project since 2006 selfdiagnose.sourceforge.net
![Page 8: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/8.jpg)
selfdiagnose.sourceforge.net
Task
A DiagnosticTask verifies the availability of a resource required for the execution of an application
Availability Deployment (configuration only) Runtime (execution only)
![Page 9: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/9.jpg)
selfdiagnose.sourceforge.net
Example: Property
Configuration key present? does value matches pattern?
Availability classpath,JNDI
<checkresourceproperty name="environment.properties" property="ProviderStoreDB4O.bin" />
![Page 10: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/10.jpg)
selfdiagnose.sourceforge.net
Example: Datasource
Configuration JNDI name, Driver, User, Access
Available host reachable?, connectable?
<checkdatasourceconnectable name="jdbc/oracle/ubs_userBeheerService-ubsDs"/>
![Page 11: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/11.jpg)
selfdiagnose.sourceforge.net
Example: Table exists
Configuration Table name
implies CheckDatasourceConnectable
<checkdatabasetableexists name="UBS_CONTEXT" datasource="jdbc/oracle/ubs_userBeheerService-ubsDs“database=“oracle” />
![Page 12: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/12.jpg)
selfdiagnose.sourceforge.net
Example: JMS
JMS Queue Configuration
JNDI name, Queue name, CCSID Availability
connectable?
<checkjndibinding name="jms/mq/ubs_userBeheerServiceQCf" class="javax.jms.QueueConnectionFactory"/>
![Page 13: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/13.jpg)
selfdiagnose.sourceforge.net
Example: URL
Host reachable? Glue servlet mailserver other Webservice …
<checkurlreachable url=“http://s3browse.com"/>
![Page 14: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/14.jpg)
selfdiagnose.sourceforge.net
Example: JMX
Managed Bean property value set? does value matches pattern?
Dangerous (if accessible at all)
<checkmbeanproperty mbeanfactory="com…..AdminServiceFactory" query="WebSphere….ontvangenBLIBerichtLp,*" method="isStarted" pattern="true" />
![Page 15: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/15.jpg)
selfdiagnose.sourceforge.net
Example: MDB
EJB Message Driven Bean Configuration
JNDI Availability
process running? (currently IBM WebSphere 5+ only)
<checkwebspherejmslistenerport name="ubs_userBeheerServiceLp"/>
![Page 16: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/16.jpg)
selfdiagnose.sourceforge.net
Design
DiagnosticTask Configuration Reporting
![Page 17: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/17.jpg)
selfdiagnose.sourceforge.net
DiagnosticTask
Initialize Load configuration parameters
Setup Verifiy parameters
Run Execute check using parameters Report to DiagnosticTaskResult
![Page 18: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/18.jpg)
selfdiagnose.sourceforge.net
Configuration
XML
Java
private final static String MAPS_URL = Check.property(“environment.properties” , “google.maps.url”’);
<selfdiagnose xmlns="http://selfdiagnose.sourceforge.net"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://selfdiagnose.sourceforge.net http://selfdiagnose.sourceforge.net/selfdiagnose.xsd"> <tasks>
<!– add your tasks here --></tasks>
</selfdiagnose>
![Page 19: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/19.jpg)
selfdiagnose.sourceforge.net
Reporting
Log4j
SelfDiagnoseServlet remote invocation of SelfDiagnose.run() Formats: HTML,XML,plain
2007-Apr-16 11:03:09.050 […] INFO SelfDiagnose - JNDI binding [url/config/ubs_userBeheerService/config] of type [java.net.URL] is available in naming server - /appl/was00t/WebSphere/AppServer/installedApps/was00tcell/ubs_userBeheerService.ear/ubs_UserBeheerServiceWeb.war/selfdiagnose.xml
![Page 20: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/20.jpg)
selfdiagnose.sourceforge.net
Reporting II
for each result Task name Status {passed,failed,error} Message Requestor
= what component added the task
![Page 21: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/21.jpg)
selfdiagnose.sourceforge.net
Quickstart
Add Maven dependency Add Servlet to Web Descriptor Define selfdiagnose.xml
![Page 22: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/22.jpg)
selfdiagnose.sourceforge.net
Maven dependency
project.xml
<dependency><groupId>com.philemonworks</groupId><artifactId>selfdiagnose</artifactId><version>1.0</version><type>jar</type><properties>
<war.manifest.classpath>true</war.manifest.classpath><war.bundle>true</war.bundle>
</properties></dependency>
![Page 23: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/23.jpg)
selfdiagnose.sourceforge.net
Servlet Descriptor
<!-- ================ SELFDIAGNOSE CONFIGURATION =========== --><servlet>
<servlet-name>selfdiagnose</servlet-name><display-name>selfdiagnose</display-name><servlet-class>
com.philemonworks.selfdiagnose.SelfDiagnoseServlet</servlet-class>
</servlet>
<!-- ================ SELFDIAGNOSE CONFIGURATION =========== --><servlet-mapping>
<servlet-name>selfdiagnose</servlet-name><url-pattern>/selfdiagnose</url-pattern>
</servlet-mapping>
![Page 24: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/24.jpg)
selfdiagnose.sourceforge.net
selfdiagnose.xml (example)
<selfdiagnose> <tasks> <checkdatasourceconnectable
name="jdbc/oracle/ubs_userBeheerService-ubsDs"/> <checkdatabasetableexists
name="UBS_CONTEXT" datasource="jdbc/oracle/ubs_userBeheerService-ubsDs"/>
<checkjndibinding name="jms/mq/ubs_userBeheerServiceQCf" class="javax.jms.QueueConnectionFactory"/>
<checkwebspherejmslistenerport name="ubs_userBeheerServiceLp"/> <checkjndibinding name="mail/MailService"/> </tasks></selfdiagnose>
![Page 25: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/25.jpg)
selfdiagnose.sourceforge.net
Expert use
Variables Custom Reports Custom task
![Page 26: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/26.jpg)
selfdiagnose.sourceforge.net
Variables
Capture result of a task Do other checks on that result
<checkjndibinding name="url/config/ubs_userBeheerService/config" class="java.net.URL" var="config"/>
<checkurlreachable url="${config}"/>
![Page 27: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/27.jpg)
selfdiagnose.sourceforge.net
Custom Reporting
XML report + custom XSL
/selfdiagnose?format=xml&xsl=xsl/selfdiagnose.xsl
![Page 28: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/28.jpg)
selfdiagnose.sourceforge.net
Custom Task
package com.mybusiness.myproduct; public class MyTask extends DiagnosticTask {
public String getDescription() { … }
public void initialize(Attributes attributes) { … }
public void run(ExecutionContext ctx, DiagnosticTaskResult result) { … }}
<task class=“com.mybusiness.myproduct.MyTask”> my-parameter1=“my-value1”/>
![Page 29: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/29.jpg)
selfdiagnose.sourceforge.net
Example: CheckWSDLpublic class CheckWSDL extends DiagnosticTask {
private String url;
public String getDescription(){ return “checks that an URL refers to a WSDL”;
} public void initialize(Attributes attributes) {
url = attributes.getValue(“url”); } public void run(ExecutionContext ctx, DiagnosticTaskResult result) {
URL newURL = new URL(url);URLConnection newCon = newURL.openConnection();… result.setPassedMessage( "URL ["+newURL+"] is reachable and ” + “WSDL content could be retrieved.");
}
![Page 30: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/30.jpg)
selfdiagnose.sourceforge.net
CheckWSDL config
<task class=“CheckWSDL”> url=“/context/Money4NothingService.wsdl”/>
![Page 31: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/31.jpg)
selfdiagnose.sourceforge.net
Testing SelfDiagnose
Is my configuration correct? Add SelfTest class to your TestSuite
![Page 32: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/32.jpg)
selfdiagnose.sourceforge.net
Wrapup
SelfDiagnose provides simple means for: Auto check of configuration Auto check availability of resources On demand report on “condition” of
application
![Page 33: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/33.jpg)
selfdiagnose.sourceforge.net
Contribute
Improve tasks + new Documentation More tests Dashboard
http://selfdiagnose.sourceforge.net/mailto: [email protected]
![Page 34: SelfDiagnose](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813c7c550346895da61b43/html5/thumbnails/34.jpg)
selfdiagnose.sourceforge.net
UML
cd Class Model
DiagnosticTask
CheckDatabaseTableExists
+ run() : void
SelfDiagnose
+ run() : void
SelfDiagnoseReporter
+ createReport() : void
SelfDiagnoseServ let
+ doGet() : void
DiagnosticTaskResult
+ isPassed() : void+ setFai ledMessage() : void
+registeredT asks