Using Java to monitor database
Writing about web page /java/entry/share_knowledge_with/
Writing about an entry you don't have permission to view
The Java Database Connectivity (JDBC) API is the industry standard for database-independent connectivity between the Java programming language and a wide range of databases
It provides a powerful interface for managing database.
Monitor multiple database
One main advantage is that you can use a single application to monitor multiple databases.
If you are managing several dozens of databases, you do not want to put your monitoring application one every server.
What we do is to use a single application, connect to different servers in a loop, check the status of database. If something goes wrong, it will send a text message to DBA. It can show very useful message like “network connection”, “db not available”, “maximum connection exceeded”.
Monitoring multiple services
You can use one or more applications to monitor multiple services. We combined our Java application witha free tools called Nagios to monitor our services. The Java application will send output to Nagios, who will display the information in a big screen. If some services are down, it will show red line.
We depended on email to check the standby status before moving to Nagios. One problem of email is that sometimes the sendmail on the Unix server might not running and failed to notify us the urgent information. With Nagios, if something goes wrong, everyone can see it on the screen
- we can monitor the status of logical standby apply
The logical standby often stopped due to inconsistent state between primary and standby. DBA need to manually intervene at early stage.
- Monitor the availability of database
- Monitor the audit information. If unauthorized users try to connect to our server from untrusted host, we will know in a short while.