Simon icon Simon
Flexible server monitoring

Introducing Simon 5!

Simon version 5 is now available. It is a massive update, introducing a much-requested feature: syncing the Simon data between multiple Macs, plus a Simon Status service, a Link Checker filter, improved Find filter, iMessage and Speak Error notifiers, a new app icon, and much more.

Important: please note that Simon 5 requires a minimum of macOS 10.12 (Sierra), and is a paid upgrade from Simon 4. Purchasers since September 1, 2020 automatically get a version 5 license (that also works in previous versions).

Read the Simon What's New page for details.

Oracle monitoring

Hello,

I am a new user of Simon.

I have been looking for a way to monitor that oracle servers are up and running, possibly avoiding the installation of the oracle client (thus, without tnsping).

As there does not seem to be anything for monitoring oracle databases in Simon's default tests, I have put together some pieces of code and wrote a short java class called TestDBOracle for the purpose.

Basically, using jdbc, it accepts the following parameters:

ServerName
OracleSid
ListenerPort (default 1521)
UserName
Password

and it connects to the oracle database to execute the test query:

SELECT 1 FROM DUAL;

Finally, it closes the connection.

Here is a sample output:

java TestDBOracle server SID 1521 user password
Fri Jun 17 15:34:14 WEST 2011 Before opening DB connection
Fri Jun 17 15:34:15 WEST 2011 DB connection opened
Fri Jun 17 15:34:15 WEST 2011 select 1 from dual executed

here is the source code:

import java.util.*;
import java.sql.*;

public class TestDBOracle {

  public static void main(String[] args)
      throws ClassNotFoundException, SQLException
  {
        if (args.length < 5)
        {
           System.out.println("Usage: java TestDBOracle ServerName OracleSID ListenerPort Username Password");
           System.exit(1);
        }
        Driver d = new oracle.jdbc.driver.OracleDriver();
        DriverManager.registerDriver(d);
        String url = "jdbc:oracle:thin:" + args[3] + "/" + args[4] + "@" + args[0] + ":" + args[2] + ":" + args[1];
        System.out.println(new java.util.Date() + " Before opening DB connection");
    Connection conn =
         DriverManager.getConnection(url,args[3],args[4]);
        System.out.println(new java.util.Date() + " DB connection opened");

    conn.setAutoCommit(false);
    Statement stmt = conn.createStatement();
    ResultSet rset =
         stmt.executeQuery("select 1 from dual");
    System.out.println(new java.util.Date() + " select 1 from dual executed");
    stmt.close();
    conn.close();
  }
}
/*
Arguments:
ServerName 0
OracleSid 1
ListenerPort (default 1521)
UserName 3
Password 4
*/

In order to compile the class, copy the above code in a file called "TestDBOracle.java" and issue, from the command line:

javac TestDBOracle.java

The compilation will produce the file: "TestDBOracle", which can be invoked as shown above.

I hope this can be useful to other users.

Cheers,

Sergio

David Sinclair's picture

Re: Oracle monitoring

Thank you for posting that.