<p>
You may want to have a look at the file '<tt>doc/sqlite3.table</tt>' as an
example table including fields to log all keys from ulogd_BASE.so. Just delete
-the fields you are not interested in, and create the table.
+the fields you are not interested in, and create the table. This file contains
+two tables, one for packet-based logging and another for flow-based logging.
+
+<p>
+To create the database file with the tables, you have to invoke the following
+command: <tt>sqlite3 ulogd.sqlite3db < sqlite3.table</tt>
+
+<p>
+To check that we are logging stuff into it correctly:
+sqlite3 ulogd.sqlite3db "SELECT * from ulog_ct"
<p>
The module defines the following configuration directives:
#define CFG_BUFFER_DEFAULT 10
-/* number of colums we have (really should be configurable) */
-#define DB_NUM_COLS 11
-
#if 0
#define DEBUGP(x, args...) fprintf(stderr, x, ## args)
#else
return sqlite3_column_count(*stmt);
}
-
-/* FIXME make this configurable */
-#define SQL_CREATE_STR \
- "create table daily(ip_saddr integer, ip_daddr integer, " \
- "ip_protocol integer, l4_dport integer, raw_in_pktlen integer, " \
- "raw_in_pktcount integer, raw_out_pktlen integer, " \
- "raw_out_pktcount integer, flow_start_day integer, " \
- "flow_start_sec integer, flow_duration integer)"
-
-static int
-db_create_tbl(struct ulogd_pluginstance *pi)
-{
- struct sqlite3_priv *priv = (void *)pi->private;
- char *errmsg;
- int ret;
-
- sqlite3_exec(priv->dbh, "drop table daily", NULL, NULL, NULL);
-
- ret = sqlite3_exec(priv->dbh, SQL_CREATE_STR, NULL, NULL, &errmsg);
- if (ret != SQLITE_OK) {
- ulogd_log(ULOGD_ERROR, "SQLITE3: create table: %s\n", errmsg);
- sqlite3_free(errmsg);
-
- return -1;
- }
-
- return 0;
-}
-
-
-
/* initialize DB, possibly creating it */
static int
sqlite3_init_db(struct ulogd_pluginstance *pi)
return -1;
num_cols = db_count_cols(pi, &schema_stmt);
- if (num_cols != DB_NUM_COLS) {
- if (db_create_tbl(pi) < 0)
- return -1;
-
- num_cols = db_count_cols(pi, &schema_stmt);
+ if (num_cols <= 0) {
+ ulogd_log(ULOGD_ERROR, "table `%s' is empty or missing in "
+ "file `%s'. Did you created this "
+ "table in the database file? Please, "
+ "see ulogd2 documentation.\n",
+ table_ce(pi), db_ce(pi));
+ return -1;
}
for (col = 0; col < num_cols; col++) {