Skip to content

Commit

Permalink
Initial JSON UDP Plugin Implementation
Browse files Browse the repository at this point in the history
This is a simple plugin that will format captured
records as JSON objects and then deliver them
to a listening UDP server.
  • Loading branch information
hawkinsw committed Jan 12, 2019
1 parent 90d17a2 commit 0c75ec6
Show file tree
Hide file tree
Showing 10 changed files with 428 additions and 0 deletions.
21 changes: 21 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,26 @@ AC_ARG_ENABLE(kafka,
)
dnl finish: Kafka handling

dnl start: JSON UDP handling
AC_MSG_CHECKING(whether to enable JSON UDP support)
AC_ARG_ENABLE(jsonudp,
[ --enable-jsonudp Enable JSON UDP support (default: no)],
[ case "$enableval" in
yes)
AC_MSG_RESULT(yes)
USING_JSONUDP="yes"
AC_DEFINE(WITH_JSONUDP, 1)
;;
no)
AC_MSG_RESULT(no)
;;
esac ],
[
AC_MSG_RESULT(no)
]
)
dnl finish JSON UDP handling

dnl start: geoip handling
AC_MSG_CHECKING(whether to enable GeoIP support)
AC_ARG_ENABLE(geoip,
Expand Down Expand Up @@ -1185,6 +1205,7 @@ AM_CONDITIONAL([WITH_SQLITE3], [test x"$USING_SQLITE3" = x"yes"])
AM_CONDITIONAL([WITH_RABBITMQ], [test x"$USING_RABBITMQ" = x"yes"])
AM_CONDITIONAL([WITH_ZMQ], [test x"$USING_ZMQ" = x"yes"])
AM_CONDITIONAL([WITH_KAFKA], [test x"$USING_KAFKA" = x"yes"])
AM_CONDITIONAL([WITH_JSONUDP], [test x"$USING_JSONUDP" = x"yes"])
AM_CONDITIONAL([USING_SQL], [test x"$USING_SQL" = x"yes"])
AM_CONDITIONAL([WITH_AVRO], [test x"$USING_AVRO" = x"yes"])
AM_CONDITIONAL([WITH_SERDES], [test x"$USING_SERDES" = x"yes"])
Expand Down
3 changes: 3 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ libdaemons_la_SOURCES += kafka_common.c kafka_common.h kafka_plugin.c kafka_plug
libdaemons_la_LIBADD += @KAFKA_LIBS@
libdaemons_la_CFLAGS += @KAFKA_CFLAGS@
endif
if WITH_JSONUDP
libdaemons_la_SOURCES += jsonudp_plugin.c jsonudp_plugin.h
endif
if USING_SQL
libdaemons_la_SOURCES += sql_common.c sql_handlers.c sql_common.h
libdaemons_la_LIBADD += -lm -lz
Expand Down
1 change: 1 addition & 0 deletions src/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ int create_plugin(char *filename, char *name, char *type)

/* searching for a valid known plugin type */
while(strcmp(plugin_types_list[index].string, "")) {
Log(LOG_ERR, "ERROR: Comparing %s with type: %s.\n", plugin_types_list[index].string, type);
if (!strcmp(type, plugin_types_list[index].string)) ptype = &plugin_types_list[index];
index++;
}
Expand Down
1 change: 1 addition & 0 deletions src/cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ struct configuration {
char *print_output_separator;
char *print_output_file;
char *print_latest_file;
char *jsonudp_server;
int nfacctd_port;
char *nfacctd_ip;
char *nfacctd_kafka_broker_host;
Expand Down
19 changes: 19 additions & 0 deletions src/cfg_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -2829,6 +2829,25 @@ int cfg_key_print_output_separator(char *filename, char *name, char *value_ptr)
return changes;
}

int cfg_key_jsonudp_server(char *filename, char *name, char *value_ptr)
{
struct plugins_list_entry *list = plugins_list;
int changes = 0;
char *endptr;

if (!name) for (; list; list = list->next, changes++) list->cfg.jsonudp_server= value_ptr;
else {
for (; list; list = list->next) {
if (!strcmp(name, list->name)) {
list->cfg.jsonudp_server = value_ptr;
changes++;
break;
}
}
}
return changes;
}

int cfg_key_num_protos(char *filename, char *name, char *value_ptr)
{
struct plugins_list_entry *list = plugins_list;
Expand Down
1 change: 1 addition & 0 deletions src/cfg_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ EXT int cfg_key_print_output_file_append(char *, char *, char *);
EXT int cfg_key_print_output_lock_file(char *, char *, char *);
EXT int cfg_key_print_output_separator(char *, char *, char *);
EXT int cfg_key_print_latest_file(char *, char *, char *);
EXT int cfg_key_jsonudp_server(char *, char *, char *);
EXT int cfg_key_nfacctd_port(char *, char *, char *);
EXT int cfg_key_nfacctd_ip(char *, char *, char *);
EXT int cfg_key_nfacctd_allow_file(char *, char *, char *);
Expand Down
Loading

0 comments on commit 0c75ec6

Please sign in to comment.