Add periodic jitter stats to CLI and manager.
authorJason Parker <jparker@digium.com>
Thu, 14 Feb 2008 18:39:51 +0000 (18:39 +0000)
committerJason Parker <jparker@digium.com>
Thu, 14 Feb 2008 18:39:51 +0000 (18:39 +0000)
(closes issue #8188)
Reported by: stevedavies
Patches:
      jblogging-trunk.patch uploaded by stevedavies
      jblogging-trunk_wmgrevent.patch uploaded by johann8384
      updated_jbloggin-trunk_mgrevent.patch uploaded by johann8384 (license 190)
      (with additional changes by me)
Tested by: stevedavies, johann8384

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@103677 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_iax2.c

index c82c88f..6418d0d 100644 (file)
@@ -7300,6 +7300,61 @@ static void save_osptoken(struct iax_frame *fr, struct iax_ies *ies)
        ast_string_field_set(iaxs[fr->callno], osptoken, full_osptoken);
 }
 
+static void log_jitterstats(unsigned short callno)
+{
+       int localjitter = -1, localdelay = 0, locallost = -1, locallosspct = -1, localdropped = 0, localooo = -1, localpackets = -1;
+       jb_info jbinfo;
+
+       ast_mutex_lock(&iaxsl[callno]);
+       if (iaxs[callno] && iaxs[callno]->owner && iaxs[callno]->owner->name) {
+               if(ast_test_flag(iaxs[callno], IAX_USEJITTERBUF)) {
+                       jb_getinfo(iaxs[callno]->jb, &jbinfo);
+                       localjitter = jbinfo.jitter;
+                       localdelay = jbinfo.current - jbinfo.min;
+                       locallost = jbinfo.frames_lost;
+                       locallosspct = jbinfo.losspct/1000;
+                       localdropped = jbinfo.frames_dropped;
+                       localooo = jbinfo.frames_ooo;
+                       localpackets = jbinfo.frames_in;
+               }
+               ast_verb(3, "JB STATS:%s ping=%d ljitterms=%d ljbdelayms=%d ltotlost=%d lrecentlosspct=%d ldropped=%d looo=%d lrecvd=%d rjitterms=%d rjbdelayms=%d rtotlost=%d rrecentlosspct=%d rdropped=%d rooo=%d rrecvd=%d\n",
+                       iaxs[callno]->owner->name,
+                       iaxs[callno]->pingtime,
+                       localjitter,
+                       localdelay,
+                       locallost,
+                       locallosspct,
+                       localdropped,
+                       localooo,
+                       localpackets,
+                       iaxs[callno]->remote_rr.jitter,
+                       iaxs[callno]->remote_rr.delay,
+                       iaxs[callno]->remote_rr.losscnt,
+                       iaxs[callno]->remote_rr.losspct/1000,
+                       iaxs[callno]->remote_rr.dropped,
+                       iaxs[callno]->remote_rr.ooo,
+                       iaxs[callno]->remote_rr.packets);
+               manager_event(EVENT_FLAG_REPORTING, "JB Stats", "Owner: %s\r\nPing: %d\r\nLocalJitter: %d\r\nLocalJBDelay: %d\t\nLocalTotalLost: %d LocalLossPercent: %d\r\nLocalDropped: %d\r\nLocalooo: %d\r\nLocalReceived: %d\r\nRemoteJitter: %d\r\nRemoteJBDelay: %d\r\nRemoteTotalLost: %d\r\nRemoteLossPercent: %d\r\nRemoteDropped: %d\r\nRemoteooo: %d\r\nRemoteReceived: %d\r\n",
+                       iaxs[callno]->owner->name,
+                       iaxs[callno]->pingtime,
+                       localjitter,
+                       localdelay,
+                       locallost,
+                       locallosspct,
+                       localdropped,
+                       localooo,
+                       localpackets,
+                       iaxs[callno]->remote_rr.jitter,
+                       iaxs[callno]->remote_rr.delay,
+                       iaxs[callno]->remote_rr.losscnt,
+                       iaxs[callno]->remote_rr.losspct/1000,
+                       iaxs[callno]->remote_rr.dropped,
+                       iaxs[callno]->remote_rr.ooo,
+                       iaxs[callno]->remote_rr.packets);
+       }
+       ast_mutex_unlock(&iaxsl[callno]);
+}
+
 static int socket_process(struct iax2_thread *thread);
 
 /*!
@@ -8464,6 +8519,9 @@ retryowner2:
                                /* save RR info */
                                save_rr(fr, &ies);
 
+                               /* Good time to write jb stats for this call */
+                               log_jitterstats(fr->callno);
+
                                if (iaxs[fr->callno]->peerpoke) {
                                        peer = iaxs[fr->callno]->peerpoke;
                                        if ((peer->lastms < 0)  || (peer->historicms > peer->maxms)) {