1 #include "lwes_mondemand.h"
8 struct mondemand_client
*client
;
9 #define mondemand_inc(x) mondemand_increment_key_by_val(client, #x, stats->x)
13 if (client
==NULL
&& arg_mondemand_host
!=NULL
&& arg_mondemand_ip
!=NULL
)
15 struct mondemand_transport
*transport
= NULL
;
16 client
= mondemand_client_create("lwes-journaller");
17 mondemand_set_context(client
,"host",arg_mondemand_host
);
18 transport
= mondemand_transport_lwes_create(arg_mondemand_ip
,arg_mondemand_port
,NULL
,0,0);
21 mondemand_add_transport(client
, transport
);
25 LOG_WARN("Unable to create mondemand transport to connect to %s:%d",arg_mondemand_ip
,arg_mondemand_port
);
30 void mondemand_enqueuer_stats (const struct enqueuer_stats
* stats
, time_t now
)
33 if (client
==NULL
) return;
34 mondemand_inc(socket_errors_since_last_rotate
);
35 mondemand_inc(bytes_received_total
);
36 mondemand_inc(bytes_received_since_last_rotate
);
37 mondemand_inc(packets_received_total
);
38 mondemand_inc(packets_received_since_last_rotate
);
39 mondemand_increment_key_by_val(client
, "rotate", now
);
40 mondemand_flush_stats(client
);
43 void mondemand_dequeuer_stats (const struct dequeuer_stats
* stats
, time_t now
)
46 if (client
==NULL
) return;
47 mondemand_inc(loss_since_last_rotate
);
48 mondemand_inc(bytes_written_total
);
49 mondemand_inc(bytes_written_since_last_rotate
);
50 mondemand_inc(packets_written_total
);
51 mondemand_inc(packets_written_since_last_rotate
);
52 mondemand_inc(bytes_written_in_burst
);
53 mondemand_inc(packets_written_in_burst
);
55 mondemand_inc(hiq_start
);
56 mondemand_inc(hiq_last
);
57 mondemand_inc(hiq_since_last_rotate
);
58 mondemand_inc(bytes_written_in_burst_since_last_rotate
);
59 mondemand_inc(packets_written_in_burst_since_last_rotate
);
60 mondemand_inc(start_time
);
61 mondemand_inc(last_rotate
);
62 mondemand_increment_key_by_val(client
, "rotate", now
);
63 mondemand_flush_stats(client
);
66 static int get_mondemand_level (log_level_t level
)
81 void mondemand_log_msg (log_level_t level
, const char *fname
, int lineno
, const char *buf
)
83 const int mondemand_level
= get_mondemand_level(level
);
84 if (mondemand_level_is_enabled(client
, mondemand_level
))
86 mondemand_log_real(client
, fname
, lineno
, level
, MONDEMAND_NULL_TRACE_ID
, "%s", buf
);
90 #else /* HAVE_MONDEMAND */
92 void mondemand_enqueuer_stats (const struct enqueuer_stats
* stats
, time_t now
)
98 void mondemand_dequeuer_stats (const struct dequeuer_stats
* stats
, time_t now
)
104 void mondemand_log_msg (log_level_t level
, const char *fname
, int lineno
, const char *buf
)
112 #endif /* HAVE_MONDEMAND */