Skip to content

Commit c7ac754

Browse files
Adrian Duriskasedmicha
authored andcommitted
IPFIX output: Introduce support for periodic message
1 parent 56ac434 commit c7ac754

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

src/plugins/output/ipfix/src/IPFIXOutput.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,19 @@ IPFIXOutput::on_session_message(ipx_msg_session *message)
527527
}
528528
}
529529

530+
void
531+
IPFIXOutput::on_periodic_message(ipx_msg_periodic_t *message)
532+
{
533+
if (config->split_on_export_time) {
534+
return;
535+
}
536+
// Start a new file, if needed
537+
std::time_t time_now = std::time(NULL);
538+
if (should_start_new_file(time_now)) {
539+
new_file(time_now); // This will make sure that templates will be written to the file
540+
}
541+
}
542+
530543
IPFIXOutput::IPFIXOutput(const Config *config, const ipx_ctx *ctx) : plugin_context(ctx), config(config)
531544
{
532545
buffer.reset(new uint8_t[UINT16_MAX]);

src/plugins/output/ipfix/src/IPFIXOutput.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ class IPFIXOutput {
120120
*/
121121
void
122122
on_session_message(ipx_msg_session *message);
123+
124+
/**
125+
* \brief Processes an incoming periodic message from the collector
126+
* \param[in] message The periodic message
127+
*/
128+
void
129+
on_periodic_message(ipx_msg_periodic_t *message);
123130
};
124131

125132

src/plugins/output/ipfix/src/IPFIXOutputPlugin.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ IPX_API struct ipx_plugin_info ipx_plugin_info = {
7171
int
7272
ipx_plugin_init(ipx_ctx_t *ctx, const char *params)
7373
{
74-
ipx_msg_mask_t mask = IPX_MSG_IPFIX | IPX_MSG_SESSION;
74+
ipx_msg_mask_t mask = IPX_MSG_IPFIX | IPX_MSG_SESSION | IPX_MSG_PERIODIC;
7575
if (ipx_ctx_subscribe(ctx, &mask, nullptr) != IPX_OK) {
7676
IPX_CTX_ERROR(ctx, "Error subscribing to messages", 0);
7777
return IPX_ERR_DENIED;
@@ -124,6 +124,8 @@ ipx_plugin_process(ipx_ctx_t *ctx, void *cfg, ipx_msg_t *msg)
124124
instance->ipfix_output->on_session_message(ipx_msg_base2session(msg));
125125
} else if (msg_type == IPX_MSG_IPFIX) {
126126
instance->ipfix_output->on_ipfix_message(ipx_msg_base2ipfix(msg));
127+
} else if (msg_type == IPX_MSG_PERIODIC) {
128+
instance->ipfix_output->on_periodic_message(ipx_msg_base2periodic(msg));
127129
}
128130

129131
} catch (std::exception &ex) {

0 commit comments

Comments
 (0)