This article will demonstrate a application developed by me which gives real time statistics[1 min interval] of Oracle Application server's availability. The
following application can be used to check any applications [SAP, Oracle Database, custom build application etc] availability also. This application can be used to know whether oracle database, oracle apps is up and running or not.
following application can be used to check any applications [SAP, Oracle Database, custom build application etc] availability also. This application can be used to know whether oracle database, oracle apps is up and running or not.
We need one application which will track whether the oacle application is up or down. Also we need to calculate the server availability % for this application. If a application is down this application will show whether database is down or not.
The following is a screen shots of final application ->
Overview Page -> This Page is used for checking all servers availability overview such as whether the instances are Up or Down, last 24 hrs availability, last 1months or 1 years availability, availability between particular dates.
All details page -> This page can be used for further information on the server like when the server is down or what is status of a particular instance between two times.
Server setup page -> Configure new servers IP and port in this page.
Design and way of development
There are basically two applications.
Application 1. One servlet application which is running in synchronized thread which is basically trying to connect with server's IP and port using telnet. If it connects successfully that means the server is running ok else if there are some exception which means the server is not respondind properly.
Application 2. A view application developed by oracle ADF which basically shows the above screens.
Application 1
First create the following tables ->
create table xxx_SERVER_SETUP
(
INST_NAME VARCHAR2(20) not null,
IP VARCHAR2(20) not null,
PORT VARCHAR2(10) not null,
PORT_TYPE VARCHAR2(100) not null
)
create table xxx_SERVER_STATUS
(
INST_NAME VARCHAR2(20) not null,
IP VARCHAR2(20) not null,
PORT VARCHAR2(10) not null,
PORT_TYPE VARCHAR2(100),
DATE_TIME TIMESTAMP(6) not null,
SERVER_STATUS VARCHAR2(8) not null
)
You need to add the following jar files in LIB ->
a. jakarta-oro-2.0.8.jar
b. oro-2.0.8.jar
c. classes12.jar
Servlet code ->
package servermonitor;
import org.apache.commons.net.telnet.TelnetClient;
import java.sql.* ;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.*;
import javax.servlet.http.*;
public class serverMonitorServlet extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
static TelnetClient tc = null;
static Connection con ;
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {response.setContentType(CONTENT_TYPE);
new serverMonitorThread();
}
}
serverMonitorThread java code ->
package servermonitor;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import org.apache.commons.net.telnet.TelnetClient;
public class serverMonitorThread extends Thread {
static TelnetClient tc = null;
static Connection con ;
public serverMonitorThread() {
start();
}
public void run() {
System.out.println("Inside Thread");
servMonitor();
}
public static synchronized void servMonitor(){
Statement stmt;
int i=0;
//while(i<10){
while(true){
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@xxxx:1571:xxxx", "xxxxxx", "xxxxxpw");
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from xxfff.xxx_server_setup");
while(rs.next()) {
String inst_name=rs.getString("INST_NAME");
String ip=rs.getString("IP");
String port=rs.getString("PORT");
String port_type=rs.getString("PORT_TYPE");
//String status=this.check_server_availability(ip,port);
//System.out.println( "inst_name = " +inst_name +" ip = "+ip+" port = "+port+" port_type = "+port_type+" server_status "+status );
String status;
tc = new TelnetClient();
int rp= new Integer(port);
try{
tc.connect(ip, rp);
tc.disconnect();
status= "Up";
}catch(Exception xe){
status= "Down";
}
Statement in_stmt;
in_stmt= con.createStatement();
String insert_stmt="INSERT INTO xxxxx.xxx_server_status (inst_name,ip,port,port_type,date_time,server_status) VALUES ('"+inst_name+"','"+ip+"','"+port+"','"+port_type+"',SYSDATE,'"+status+"')";
System.out.println(insert_stmt);
in_stmt.executeUpdate(insert_stmt);
in_stmt.close();
}
con.commit();
stmt.close();
con.close();
}
catch(Exception x){
System.out.println("Error during database access. " );
x.printStackTrace();
}
i++;
try {
sleep(60*1000*10);
} catch (InterruptedException e) {
// TODO
}
}
}
}
After deploying the application1 we need to run the following url in browser to start the server monitoring application. Multiple url hit will not start the application multiple time as it is written in one synchronized thread class.
http://xxxxxxx/serverMonitor/servermonitorservlet
Application 2 ->
This is a full adf application downloadable from here. The application is developed on Oracle Jdeveloper 10.1.3.5 and running on oracle application server 10g.
Put the following jar files in library ->
a. adf-faces-impl.jar
b. jsf-impl.jar
1 comment :
good tool....
Post a Comment