Save RTCP on a call

Hi,

For the purposes of monitoring the quality (MOS/MES) of calls, we would like to save the RTCP data for each call (either in the CDR or in a plain text file).

We have the following, but it does not seem optimal, and it is using the “F” and “g” options of the dialplan:

exten => _8XXXXXX,1,NoOP()
  same => n,Dial(PJSIP/${EXTEN},60,tThHkKxXwWFg)
  same => n,Set(MES_QOS=${RTPAUDIOQOSMESBRIDGED})
  same => n,Set(MES_JITTER=${RTPAUDIOQOSJITTERBRIDGED})
  same => n,Set(MES_LOSS=${RTPAUDIOQOSLOSSBRIDGED})
  same => n,Set(MES_RTT=${RTPAUDIOQOSRTTBRIDGED})
  same => n,Set(ALL=${CHANNEL(rtcp,all)})
  same => n,System(echo "Fecha: ${STRFTIME(${EPOCH},,%d/%m/%Y)}" >> /var/log/rtcp_asterisk.log)
  same => n,System(echo "Hora: ${STRFTIME(${EPOCH},,%H:%M)}" >> /var/log/rtcp_asterisk.log)
  same => n,System(echo "CallID: ${UNIQUEID}" >> /var/log/rtcp_asterisk.log)
  same => n,System(echo "QoS: ${MES_QOS}" >> /var/log/rtcp_asterisk.log)
  same => n,System(echo "Jitter: ${MES_JITTER}" >> /var/log/rtcp_asterisk.log)
  same => n,System(echo "Loss: ${MES_LOSS}" >> /var/log/rtcp_asterisk.log)
  same => n,System(echo "RTT: ${MES_RTT}" >> /var/log/rtcp_asterisk.log)
  same => n,System(echo "<------------------------------------------------------------------------->" >> /var/log/rtcp_asterisk.log)
  same => n,System(echo " " >> /var/log/rtcp_asterisk.log)
  same => n,System(echo " " >> /var/log/rtcp_asterisk.log)
  same => n,Hangup(1)

Is there a way to make it “less” complicated and/or more optimal?

Thanks.