datasets: add dump via unix socket

This patch adds a dataset-dump command to the list of unix socket
commands. Implementation is not optimal as we are locking the
datasets when doing the dump. But if we consider that the current
alternative from an implementation point of view is to stop Suricata
then this is far better than current state.

Ticket: #5184
pull/8097/head
Eric Leblond 4 years ago committed by Victor Julien
parent 79a78611ad
commit a480abcdd0

@ -763,6 +763,15 @@ TmEcode UnixSocketDatasetRemove(json_t *cmd, json_t* answer, void *data)
}
}
TmEcode UnixSocketDatasetDump(json_t *cmd, json_t *answer, void *data)
{
SCEnter();
SCLogDebug("Going to dump datasets");
DatasetsSave();
json_object_set_new(answer, "message", json_string("datasets dump done"));
SCReturnInt(TM_ECODE_OK);
}
/**
* \brief Command to add a tenant handler
*

@ -35,6 +35,7 @@ float MemcapsGetPressure(void);
#ifdef BUILD_UNIX_SOCKET
TmEcode UnixSocketDatasetAdd(json_t *cmd, json_t* answer, void *data);
TmEcode UnixSocketDatasetRemove(json_t *cmd, json_t* answer, void *data);
TmEcode UnixSocketDatasetDump(json_t *cmd, json_t *answer, void *data);
TmEcode UnixSocketRegisterTenantHandler(json_t *cmd, json_t* answer, void *data);
TmEcode UnixSocketUnregisterTenantHandler(json_t *cmd, json_t* answer, void *data);
TmEcode UnixSocketRegisterTenant(json_t *cmd, json_t* answer, void *data);

@ -1088,6 +1088,7 @@ int UnixManagerInit(void)
UnixManagerRegisterCommand("dataset-remove", UnixSocketDatasetRemove, &command, UNIX_CMD_TAKE_ARGS);
UnixManagerRegisterCommand(
"get-flow-stats-by-id", UnixSocketGetFlowStatsById, &command, UNIX_CMD_TAKE_ARGS);
UnixManagerRegisterCommand("dataset-dump", UnixSocketDatasetDump, NULL, 0);
return 0;
}

Loading…
Cancel
Save