Database query

This probe performs a SQL-query to one of the following databases:

  • MySQL (4.1 - 5.7),

  • MS SQL (Microsoft SQL Server 2005 / 2008 / 2008 R2 / 2012 / 2014),

  • PostgreSQL (9.x),

  • Oracle (9.0 - 11.2),

  • HP Vertica.

Settings example

image
Field Description

Database type

Select the database type from the dropdown list.

Hostname

Localhost by default.

Port

By default:

  • MySQL - 3306,

  • PostgreSQL - 5432,

  • MS SQL - 1433,

  • Oracle - 1521,

  • HP Vertica - 5433.

Database name

Database name which the request is being made to.

Instance name

Database instance name which the request is being made to.

Login

DB username.

Password

DB password.

Encoding

SQL query encoding.

SQL query

SQL query text.

Only the SELECT command can be used, and query field is limited to 1024 characters.

Period

How often to perform the check (60 seconds by default).

Result

After the check has been done result is displayed in the Data table:

image

Field

Description

count(id)

Number of records in the column ID from the table States.

Rows is an additional field in which the array length is indicated.

Total number of rows is displayed when the array value is the result of the probe or the input data.

Command-line utility

Similar execution of this check in the terminal:

mysql -u saymon -p
mysql> show databases
    -> ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| saymondb           |
+--------------------+
2 rows in set (0.00 sec)


mysql> use saymondb
Reading table informatiom for comletion of table and colunm names
You can turn off this feature to get a quicker startup with -A


Database changed
mysql> show tables
    -> ;
+--------------------+
| Tables_in_saymondb |
+--------------------+
| class_categories   |
| classes            |
| history            |
| migration          |
| obj_prop_types     |
| object_properties  |
| objects            |
| relation_types     |
| relations          |
| state_history      |
| states             |
+--------------------+
11 rows in set (0.00 sec)


mysql> select count(id) from states;
+-----------+
| count(id) |
+-----------+
|         9 |
+-----------+
1 row in set (0.00 sec)

Known problems and errors

Sensor error! Can not issue data manipulation statements with executeQuery().

SQL query is specified incorrectly.

Sensor error! Connection refused (Connection refused)

It is necessary to check the correctness of the specified port number.

By default:

  • MySQL - 3306;

  • PostgreSQL - 5432;

  • MS SQL - 1433;

  • Oracle - 1521;

  • HP Vertica - 5433.

Sensor error! Access denied for user 'say'@'localhost'

It is necessary to check the correctness of the data which indicated in the fields Login and Password.