Browse Source

MT#55283 add new `summary` mqtt option

Change-Id: I7e4a2327f6aca2c73349b3ae02d4184460575e89
pull/1614/head
Richard Fuchs 3 years ago
parent
commit
64d7a12701
6 changed files with 29 additions and 6 deletions
  1. +12
    -2
      daemon/codec.c
  2. +3
    -1
      daemon/main.c
  3. +7
    -0
      daemon/mqtt.c
  4. +4
    -3
      daemon/rtpengine.pod
  5. +1
    -0
      include/main.h
  6. +2
    -0
      include/mqtt.h

+ 12
- 2
daemon/codec.c View File

@ -1419,6 +1419,13 @@ static void __mqtt_timer_run_global(struct codec_timer *ct) {
__codec_mqtt_timer_schedule(mqt);
mqtt_timer_run_global();
}
static void __mqtt_timer_run_summary(struct codec_timer *ct) {
struct mqtt_timer *mqt = (struct mqtt_timer *) ct;
if (!*mqt->self)
return;
__codec_mqtt_timer_schedule(mqt);
mqtt_timer_run_summary();
}
static void __codec_mqtt_timer_schedule(struct mqtt_timer *mqt) {
timeval_add_usec(&mqt->ct.next, rtpe_config.mqtt_publish_interval * 1000);
timerthread_obj_schedule_abs(&mqt->ct.tt_obj, &mqt->ct.next);
@ -1439,8 +1446,11 @@ void mqtt_timer_start(struct mqtt_timer **mqtp, struct call *call, struct call_m
mqt->ct.timer_func = __mqtt_timer_run_media;
else if (call)
mqt->ct.timer_func = __mqtt_timer_run_call;
else
mqt->ct.timer_func = __mqtt_timer_run_global;
else {
// global or summary
mqt->ct.timer_func = mqtt_publish_scope() == MPS_GLOBAL
? __mqtt_timer_run_global : __mqtt_timer_run_summary;
}
__codec_mqtt_timer_schedule(mqt);
}


+ 3
- 1
daemon/main.c View File

@ -572,7 +572,7 @@ static void options(int *argc, char ***argv) {
{ "mqtt-publish-qos",0,0,G_OPTION_ARG_INT, &rtpe_config.mqtt_publish_qos,"Mosquitto publish QoS", "0|1|2"},
{ "mqtt-publish-topic",0,0,G_OPTION_ARG_STRING, &rtpe_config.mqtt_publish_topic,"Mosquitto publish topic", "STRING"},
{ "mqtt-publish-interval",0,0,G_OPTION_ARG_INT, &rtpe_config.mqtt_publish_interval,"Publish timer interval", "MILLISECONDS"},
{ "mqtt-publish-scope",0,0,G_OPTION_ARG_STRING, &mqtt_publish_scope, "Scope for published mosquitto messages","global|call|media"},
{ "mqtt-publish-scope",0,0,G_OPTION_ARG_STRING, &mqtt_publish_scope, "Scope for published mosquitto messages","global|summary|call|media"},
#endif
{ "mos",0,0, G_OPTION_ARG_STRING, &mos, "Type of MOS calculation","CQ|LQ"},
{ "measure-rtp",0,0, G_OPTION_ARG_NONE, &rtpe_config.measure_rtp,"Enable measuring RTP statistics and VoIP metrics",NULL},
@ -845,6 +845,8 @@ static void options(int *argc, char ***argv) {
rtpe_config.mqtt_publish_scope = MPS_CALL;
else if (!strcmp(mqtt_publish_scope, "media"))
rtpe_config.mqtt_publish_scope = MPS_MEDIA;
else if (!strcmp(mqtt_publish_scope, "summary"))
rtpe_config.mqtt_publish_scope = MPS_SUMMARY;
else
die("Invalid --mqtt-publish-scope option ('%s')", mqtt_publish_scope);
}


+ 7
- 0
daemon/mqtt.c View File

@ -569,6 +569,13 @@ void mqtt_timer_run_global(void) {
__mqtt_timer_outro(json);
}
void mqtt_timer_run_summary(void) {
JsonBuilder *json = __mqtt_timer_intro();
mqtt_global_stats(json);
__mqtt_timer_outro(json);
}


+ 4
- 3
daemon/rtpengine.pod View File

@ -1049,10 +1049,11 @@ string.
Interval in milliseconds to publish to Mosquitto. Defaults to 5000 (5 seconds).
=item B<--mqtt-publish-scope=>B<global>|B<call>|B<media>
=item B<--mqtt-publish-scope=>B<global>|B<summary>|B<call>|B<media>
When set to B<global>, one message will be published to Mosquitto every
I<interval> milliseconds containing global stats plus a list of all running
When set to B<summary>, one message will be published to Mosquitto every
I<interval> milliseconds containing all global stats. A setting of B<global>
has the same effect as B<summary> but will also contain a list of all running
calls with stats for each call. When set to B<call>, one message per call will
be published to Mosquitto with stats for that call every I<interval>
milliseconds, plus one message every I<interval> milliseconds with global


+ 1
- 0
include/main.h View File

@ -153,6 +153,7 @@ struct rtpengine_config {
MPS_GLOBAL = 0,
MPS_CALL,
MPS_MEDIA,
MPS_SUMMARY,
} mqtt_publish_scope;
enum {
MOS_CQ = 0,


+ 2
- 0
include/mqtt.h View File

@ -18,6 +18,7 @@ void mqtt_publish(char *);
void mqtt_timer_run_media(struct call *, struct call_media *);
void mqtt_timer_run_call(struct call *);
void mqtt_timer_run_global(void);
void mqtt_timer_run_summary(void);
#else
@ -30,6 +31,7 @@ INLINE int mqtt_publish_scope(void) { return MPS_NONE; };
INLINE void mqtt_timer_run_media(struct call *c, struct call_media *m) { }
INLINE void mqtt_timer_run_call(struct call *c) { }
INLINE void mqtt_timer_run_global(void) { }
INLINE void mqtt_timer_run_summary(void) { }
#endif
#endif

Loading…
Cancel
Save