Logging Database Connection Losses

We have an Oracle database that we are shoving data into on a separate server than our Ignition gateway. We installed a local SQL Express database on our Ignition server because we want to log when there is a break in connection to our Oracle Database.

Is it possible to read the connection status to our Oracle DB with a tag in Ignition?

Short answer : Yes

Long Answer:
If you want to use a tag to check if the database is talking to your gateway you could use the ‘Available’ tag, which is in ‘System/Gateway/Database/Your_Database_Name/’ in the tag list

You could have a gateway script that polls every second or every 500 ms that checks that tag and then if the tag is inactive for longer than a set duration (like 2 s), it can log the date and time into your Local database.

There is also a function called system.db.getConnectionInfo(), which will return a dataset about the connection specified. The argument for this function is the name of the database as it shows up in your gateway.

If you were to use this, I would check both the ‘Throughput’ value(column 6) and the ‘Status’ value(column 3). The ‘Throughput’ value will read ‘-1’ once the connection drops.(even if no client is using anything in the database, the value will be ~0.1). The ‘Status’ value will read ‘Faulted’ or something other than ‘Valid’ if there is an issue with the connection.

Keep in mind both the ‘Available’ Tag and ‘Status’ value will take a while to change as the gateway has a timeout period.

If you want to track exactly when the database drops off (And possibly when it reconnects), I would personally use the ‘Throughput’ value from getConnectionInfo().

1 Like