1 #include "lwes_mondemand.h"
7 struct mondemand_client
*client
;
8 #define mondemand_inc(x) mondemand_increment_key_by_val(client, #x, stats->x)
9 #define MONDEMAND_LABEL_MAX_LENGTH 100
13 if (client
==NULL
&& arg_mondemand_label
!=NULL
&& arg_mondemand_ip
!=NULL
)
15 char label
[MONDEMAND_LABEL_MAX_LENGTH
+1];
16 struct mondemand_transport
*transport
= NULL
;
17 strncpy(label
, "lwes-journaller-", MONDEMAND_LABEL_MAX_LENGTH
);
18 strncat(label
, arg_mondemand_label
, MONDEMAND_LABEL_MAX_LENGTH
);
19 client
= mondemand_client_create(label
);
20 transport
= mondemand_transport_lwes_create(arg_mondemand_ip
,arg_mondemand_port
,NULL
,0,0);
23 mondemand_add_transport(client
, transport
);
27 LOG_WARN("Unable to create mondemand transport to connect to %s:%d",arg_mondemand_ip
,arg_mondemand_port
);
32 void mondemand_stats (const struct stats
* stats
, time_t now
)
35 if (client
==NULL
) return;
37 mondemand_inc(bytes_total
);
38 mondemand_inc(bytes_since_last_rotate
);
39 mondemand_inc(packets_total
);
40 mondemand_inc(packets_since_last_rotate
);
41 mondemand_inc(bytes_in_burst
);
42 mondemand_inc(packets_in_burst
);
44 mondemand_inc(hiq_start
);
45 mondemand_inc(hiq_last
);
46 mondemand_inc(hiq_since_last_rotate
);
47 mondemand_inc(bytes_in_burst_since_last_rotate
);
48 mondemand_inc(packets_in_burst_since_last_rotate
);
49 mondemand_inc(start_time
);
50 mondemand_inc(last_rotate
);
51 mondemand_increment_key_by_val(client
, "rotate", now
);
52 mondemand_flush_stats(client
);
55 static int get_mondemand_level (log_level_t level
)
70 void mondemand_log_msg (log_level_t level
, const char *fname
, int lineno
, const char *buf
)
72 const int mondemand_level
= get_mondemand_level(level
);
73 if (mondemand_level_is_enabled(client
, mondemand_level
))
75 mondemand_log_real(client
, fname
, lineno
, level
, MONDEMAND_NULL_TRACE_ID
, "%s", buf
);
79 #else /* HAVE_MONDEMAND */
81 void mondemand_stats (const struct stats
* stats
, time_t now
)
85 void mondemand_log_msg (log_level_t level
, const char *fname
, int lineno
, const char *buf
)
89 #endif /* HAVE_MONDEMAND */