Skip to content

Commit a8a31a6

Browse files
committed
Fix for avoid spawning clock drift warning message too often
1 parent 8f73683 commit a8a31a6

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

include/ZMQParserInterface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class ZMQParserInterface : public ParserInterface {
3333
typedef std::map<string, u_int32_t> counters_map_t;
3434
std::unordered_map<u_int32_t, bool> cloud_flow_exporters;
3535
u_int16_t top_vlan_id;
36+
u_int32_t next_msg_time;
3637
std::unordered_map<std::string, u_int16_t> name_to_vlan;
3738
labels_map_t labels_map; /* Contains mappings between labels and integer IDs
3839
(PEN and ID) */

src/ZMQParserInterface.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ ZMQParserInterface::ZMQParserInterface(const char *endpoint,
3535
const char *custom_interface_type)
3636
: ParserInterface(endpoint, custom_interface_type) {
3737
if(trace_new_delete) ntop->getTrace()->traceEvent(TRACE_NORMAL, "[new] %s", __FILE__);
38-
38+
next_msg_time = 0;
3939
memset(&cumulative_remote_stats, 0, sizeof(cumulative_remote_stats));
4040
memset(&last_cumulative_remote_stats_update, 0, sizeof(last_cumulative_remote_stats_update));
4141

@@ -556,12 +556,18 @@ u_int8_t ZMQParserInterface::parseEvent(const char *payload, int payload_size,
556556
if (check_clock_drift /* Skip message with drops to avoid miscalculations */
557557
&& ((zrs.local_time - polling_start_time) > 5)) {
558558
if (abs(time_delta) >= 10) {
559-
ntop->getTrace()->traceEvent(TRACE_NORMAL,
560-
"Remote probe clock drift %u sec "
561-
"detected (local: %u remote: %u [%s])",
562-
abs(time_delta), zrs.local_time,
563-
zrs.remote_time,
564-
zrs.remote_probe_address);
559+
u_int32_t now = (u_int32_t)time(NULL);
560+
561+
if(next_msg_time < now) {
562+
next_msg_time = now + 10 /* silence alaert fo 10+ sec */;
563+
564+
ntop->getTrace()->traceEvent(TRACE_NORMAL,
565+
"Remote probe clock drift %u sec "
566+
"detected (local: %u remote: %u [%s])",
567+
abs(time_delta), zrs.local_time,
568+
zrs.remote_time,
569+
zrs.remote_probe_address);
570+
}
565571
}
566572
} else
567573
zrs.remote_time = zrs.local_time; /* Avoid clock drift messages during

0 commit comments

Comments
 (0)