CALM DB Export tool.

This tool allows logs to be exported from databases into plain log files so that the
CALM agent can process them and upload to CALM.

The following databases are supported:

Sqlite3
Mysql / Mariadb
Postgres
Microsoft SQL Server
Oracle

Usage:

java -jar calm-db-export.jar config.json

Run this from Windows Task Scheduler, or a cron job on Linux to run every 5 or 10 minutes
depending on requirements.

The config.json specifies what the tool needs to export. An annotated sample is below:

{
        "db_url": "jdbc:mysql://localhost/db_name",
        "db_user": "username",
        "db_pass": "abc",

        "db_query": {

		// Which fields to extract from the DB
                "fields": ["id", "title", "created", "model", "model_id", "action", "user_id", "change", "email", "org", "description", "ip"],

		// Multiple tables can be specified, allowing joins (in combination with WHERE clause to define the join)
                "tables": ["logs"],

		// A custom WHERE condition can be applied to filter specific logs, or do joins
                "where_clause": null
        },

	// To ensure that only new logs are retrieved, we need to define these.
	// The state is maintained so that only new logs are processed each run
        "stateFields": [
                {
			// Type can be date, int or long
                        "type": "date"
			// The field must be included in the list of fields in the db_query above
                        "field": "created",
                }
        ],

	// Where to save the state data
        "stateDir": "c:\\calm-db-export\\state",

	// Where to output the log files
        "outDir": "c:\\calm-db-export\\output"
}

