I want to write a simple java program which can monitor any database (DB2, Oracle, SQL server...etc). This program should remotely collect database counters like no.of remote connections,no.of direct reads, no.of direct writes, no.of commit statements, no.of dead locks....etc.
How can I do this, without using any tool?
These parameters can be accessed from tables in the database. For examplpe, in Oracle, they will be available in V$SESSION etc. tables.
But these tables might vary from DB to DB. I am not so sure about the other databases though.
Moreover, you will need dba privileges to access these tables. Building a single application for different DB's may be tough.
They say you have to be the first, the best or different. I say, is it too much to ask for all three.
It's not going to be a simple tool I'm afraid. The logic is fairly simple, but the work needed for all databases is a lot. You'll need to connect to the various monitoring procedures, tables and views specific to each database (e.g. v$session on Oracle, sp_who2 on SQL Server etc.) and interpret their results.
I think the hardest part will be to get your hands on different types of databases . Would be great though to have such a tool .
Joined: Dec 08, 2009
Thank you all for your replies..........
I want to make this tool as simple as possible. My code should work for any database, but one at a time.I will configure the database type externally, based on this configuration it should invoke the appropriate code. I mean if I configure this tool for a client who is using DB2 as back end then I will set the database type as DB2.
The another interesting requirement is I don't want to use database drivers to connect to databases. Because I don't want to bundle drivers of all databases along with my tool. Instead I want to get the reference of data source object which resides at application server using JMX and then I will execute appropriate commands on it.
Now the problem I am facing right now is, I could not connect to the JMX agent from a remote machine even though it is enabled for the remote access. I put the following entry in the run.conf.bat file to enable the JMX agent remote access.
my server is running as a windows service using wrapper.jar.
you need to add spaces at the end, inside the quotes otherwise you mangle the settings.
Joined: Dec 08, 2009
I have got it worked by just setting the custom port number in the jboss-service.xml of jmx-remoting.sar of deployment folder. after this setting I have used the following URL to connect to JMX agent of JBoss.
So I haven't put any JAVA_OPTS in the run scripts. Does anyone know the difference between these two settings?
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com