Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

daemon storage #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,5 @@ dockerbuild/

# CMake
compile_commands.json

.build/*
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ set(SENSOR_SOURCES
src/perf.h src/perf.c
src/storage.h src/storage.c
src/storage_socket.h src/storage_socket.c
src/storage_daemon.h src/storage_daemon.c
src/storage_csv.h src/storage_csv.c
src/sensor.c
)

set(SENSOR_INCLUDES "${CZMQ_STATIC_INCLUDE_DIRS}")
set(SENSOR_DEFINITIONS "${CZMQ_STATIC_DEFINITIONS}")
set(SENSOR_LIBRARIES "${CZMQ_STATIC_LIBRARIES}" pfm)
set(SENSOR_LIBRARIES "${CZMQ_STATIC_LIBRARIES}" pfm pthread)

if(WITH_MONGODB)
pkg_check_modules(BSON REQUIRED libbson-1.0)
Expand Down
5 changes: 5 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ config_validate(struct config *config)
return -1;
}

if (storage-> type == STORAGE_DAEMON && (!storage-> P_flag)) {
zsys_error ("config: the daemon storage module requires the 'P' flag to be set");
return -1;
}

#ifdef HAVE_MONGODB
if (storage->type == STORAGE_MONGODB && (!storage->U_flag || !storage->D_flag || !storage->C_flag)) {
zsys_error("config: the MongoDB storage module requires the 'U', 'D' and 'C' flags to be set");
Expand Down
7 changes: 5 additions & 2 deletions src/sensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "storage.h"
#include "storage_csv.h"
#include "storage_socket.h"
#include "storage_daemon.h"

#ifdef HAVE_MONGODB
#include "storage_mongodb.h"
Expand All @@ -68,9 +69,11 @@ setup_storage_module(struct config *config)
switch (config->storage.type)
{
case STORAGE_CSV:
return storage_csv_create(config);
return storage_csv_create(config);
case STORAGE_SOCKET:
return storage_socket_create(config);
return storage_socket_create(config);
case STORAGE_DAEMON:
return storage_daemon_create(config);
#ifdef HAVE_MONGODB
case STORAGE_MONGODB:
return storage_mongodb_create(config);
Expand Down
5 changes: 5 additions & 0 deletions src/storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const char *storage_types_name[] = {
[STORAGE_UNKNOWN] = "unknown",
[STORAGE_CSV] = "csv",
[STORAGE_SOCKET] = "socket",
[STORAGE_DAEMON] = "daemon",
#ifdef HAVE_MONGODB
[STORAGE_MONGODB] = "mongodb",
#endif
Expand All @@ -54,6 +55,10 @@ storage_module_get_type(const char *type_name)
return STORAGE_SOCKET;
}

if (strcasecmp(type_name, storage_types_name[STORAGE_DAEMON]) == 0) {
return STORAGE_DAEMON;
}

#ifdef HAVE_MONGODB
if (strcasecmp(type_name, storage_types_name[STORAGE_MONGODB]) == 0) {
return STORAGE_MONGODB;
Expand Down
1 change: 1 addition & 0 deletions src/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ enum storage_type
STORAGE_UNKNOWN,
STORAGE_CSV,
STORAGE_SOCKET,
STORAGE_DAEMON,
#ifdef HAVE_MONGODB
STORAGE_MONGODB,
#endif
Expand Down
Loading