The SQL Query test monitors the amount of time required to connect to any database that supports JDBC and can execute SQL queries. It supports queries for Oracle, Microsoft SQL Server, and other databases.
Before you begin creating SQL Query tests, verify that the appropriate JDBC driver is available. If necessary, install the JDBC driver files that are specific to the database you are trying to test.
Copy the JAR files to the jre/lib/ext directory under the SystemEDGE installation directory (for exampl, /opt/SystemEDGE/jre/lib/ext [UNIX] or drive:\sysedge\jre\lib\ext [Windows]). To obtain JDBC driver jar files for your database, check the Corporate Web site of the company that distributes the database.
Example to verify the availability of the SQL JDBC driver
If the SQL JDBC is not available, perform the following steps:
Options and Arguments
SQL Query tests require the following specific options and arguments:
Note: For Oracle and MSSQL, SRM creates a dynamic SQL connect string using a default JDBC driver installed with SRM. For any other JDBC driver that you download, regardless of the database vendor, you must obtain the Java class name of the driver and an appropriate SQL connect string from the vendor and provide specific keywords (see below).
Note: IPv6 addresses can be used, but they must be embedded in brackets, for example [0aff::230:6eff:fe4b:51db]:8080. Here 0aff::230:6eff:fe4b:51db represents the IPv6 address and 8080 represents the port number.
Examples:
com.microsoft.sqlserver.jdbc.SQLServerDriver oracle.jdbc.OracleDriver com.mysql.jdbc.Driver
Note: The format of an SQL connect string varies depending on the database driver from a particular vendor. Refer to your database vendor's web site to obtain the appropriate connect string for your JDBC driver or refer to your JDBC driver documentation.
The connect string from your database vendor contains a sequence of fields, some of which you can replace with explicit keywords, such as a unameValue, pwdValue, hostnameValue, and portValue. When you enter the connect string in the GUI, type in "unameValue" and "pwdValue" and let the agent do the substitution. The vendor-specific connect string should stipulate where in the connect to place the keywords. (SRM does this automatically if you use the default JDBC driver for Oracle or MSSQL.) When an SRM test runs, the following SRM keywords in the connect string get replaced by the values that you specify:
Examples:
jdbc:oracle:thin:unameValue/pwdValue@hostnameValue:portValue:orcl (connects with orcl) jdbc:sqlserver://hostnameValue:portValue;databaseName=vasdb;user=unameValue;password=pwdValue (connects with vasdb) jdbc:sqlserver://hostnameValue:portValue;user=unameValue;password=pwdValue (connects with default database) jdbc:mysql://hostnameValue:portValue/mydb?user=unameValue&password=pwdValue (connects with mydb)
Specify these options and arguments when you create or modify tests.
Example 1: Testing an Oracle Database
Use this example to create a test that logs into an Oracle database and performs a query to retrieve the table names from the user tables once every 300 seconds. The test waits up to 10 seconds for a successful response and calculates response time and availability statistics over the last 1800 seconds (30 minutes).
To create a new test in a policy
The New test pane appears.
When you commit your changes, SRM adds an entry similar to the following to the svcrsp.cf file:
{ index=11 type=sql desc="SQLQuery_OrcaleTest" dest="OracleTest:1521" username="OracleUser" encoded=yes password="aW1vdXJhdmlldg" args="query=select table_name from user_tables&dbtype=oracle&dbname=MYDB" interval=300 samples=1 timeout=10 window=1800 tos=0 limit=0 status=active name="Oracle Test" class="" context="" flags="1" loglevel=2 }
Example 2: Testing a Microsoft SQL Server Database
Use this example to create a test that logs into a Microsoft SQL database and performs a query to retrieve the table names from the user tables once every 60 seconds. The test waits up to 10 seconds for a successful response and calculates response time and availability statistics over the last 120 seconds.
To create a new test in a policy
The New test pane appears.
When you commit your changes, SRM adds an entry similar to the following to the svcrsp.cf file:
{ index=11 type=sql desc="SQLQuery.SQLServer" dest="mySQLServer:1433" username="SQLUser" encoded=yes password="bWnvTRPJhdmll" args="query=select * from categories"&dbtype=mssql&dbname=Northwind" interval=60 samples=1 timeout=10 window=120 tos=0 limit=0 status=active name="SQL Test" class="" context="" flags="1" loglevel=1 }
For information about errors you may encounter when running SQL Query tests, see SQL Query Test Error Codes.
Copyright © 2013 CA. All rights reserved. |
|