How to use REST Service to pause and resume database logging
Prerequisites Copied
The REST Service must be enabled on the gateway by doing the following steps:
- In the GSE, click Commands.
- Select the Advanced tab.
- In Rest service, check the box next to Enabled.
- Save change in the GSE.
Solution Copied
To pause database logging using REST API, run the following command:
curl -u username:password -X POST -s --data '{ "command" : "/DATABASELOGGING:connection:pause", "target":" /geneos/gateway/directory[(rparam(\"DBConnectionPaused\")=\"false\")]"}' http://gatewayHost:gatewayPort/rest/runCommand
If the REST API command is successful, you will see the following response on the terminal.
{ "status":"finished" }
In addition, the gateway’s database logging icon will appear red and crossed out, indicating the gateway is not connected to the database.
If you are using the Gateway-databaseLogging plug-in, you will notice the Summary dataview shows connectionPaused set to true.
The gateway log will show the command has been executed and the database connection has been paused:
2022-03-23 15:43:50.903-0400 INFO: CommandManager Executing command [/DATABASELOGGING:connection:pause] with id [116] for request id [26]
2022-03-23 15:43:50.904-0400 INFO: CommandManager Executing command '/DATABASELOGGING:connection:pause' on DataItem '/geneos/gateway[(@name="testing_gateway")]/directory', issued by user 'username' on '192.168.x.xx' using REST service
2022-03-23 15:43:50.904-0400 INFO: CommandManager Received 0 arguments for command
2022-03-23 15:43:50.906-0400 INFO: DatabaseLogging Database connection is paused [./database/database.connectionpaused.dat]
2022-03-23 15:43:51.053-0400 WARN: Event:DatabaseLogging 1648064631.053173 DatabaseLogging /geneos/gateway[@name="testing_gateway"] Connection Dropped [server01 geneos_db 3306 username:geneos_db_user]
To resume database logging, you can run the following command:
curl -u username:password -X POST -s --data '{ "command" : "/DATABASELOGGING:connection:resume", "target":" /geneos/gateway/directory[(rparam(\"DBConnectionPaused\")=\"true\")]"}' http://gatewayHost:gatewayPort/rest/runCommand
The gateway log will show the following lines saying the command has been executed and the database connection is resumed.
2022-03-23 15:58:28.682-0400 INFO: CommandManager Executing command [/DATABASELOGGING:connection:resume] with id [117] for request id [27]
2022-03-23 15:58:28.683-0400 INFO: CommandManager Executing command '/DATABASELOGGING:connection:resume' on DataItem '/geneos/gateway[(@name="testing_gateway")]/directory', issued by user 'username' on '192.168.x.xx' using REST service
2022-03-23 15:58:28.684-0400 INFO: CommandManager Received 0 arguments for command
2022-03-23 15:58:28.685-0400 INFO: DatabaseLogging Database connection is resumed
If you still see the database icon red and crossed out in the gateways dockable, and the connectionStatus still says Not Connected in the Summary view of the Gateway-databaseLogging plug-in, this is because the database is not logging anything new upon the database connection resuming.
As soon as a new item is logged to the database, the database icon will no longer appear crossed out and the connectionStatus will say Connected.
The gateway log will then show the following entry stating the database connection has been established:
2022-03-23 16:00:40.098-0400 INFO: Event:DatabaseLogging 1648065640.098452 DatabaseLogging /geneos/gateway[@name="testing_gateway"] Connection Established [server01 geneos_db 3306 username:geneos_db_user, serverVersion 5.1.44]