I have been looking more closely at Mean Opinion Scores (MOS) (https://en.wikipedia.org/wiki/Mean_opinion_score) across my platform and put together a simple shell script to quickly show the average score over a period of time broken down by domain or just for a single domain.
Here is the script, it may be of use/help for someone, I just named it mos. As always, use/adapt at your own risk:
Here is the script, it may be of use/help for someone, I just named it mos. As always, use/adapt at your own risk:
Code:
#!/bin/bash
#settings
export PGPASSWORD="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
db_host=127.0.0.1
db_port=5432
NUMBER_REGEX='^[0-9]+$'
if [ "$#" -lt 1 ]; then
echo ""
echo "Usage: mos <hours> [domain name]"
echo ""
echo "You must supply the number of hours to look back over as a command line argument."
echo "You may optionally request a score for a single domain."
echo ""
exit 1
fi
if ! [[ $1 =~ $NUMBER_REGEX ]] ; then
echo "Error: The first argument must be a number." >&2
exit 1
fi
SQL="select b.domain_name, case when count(a.*) = 0 then 4 else avg(a.rtp_audio_in_mos) end as avg_mos\
from v_xml_cdr a join v_domains b on b.domain_uuid = a.domain_uuid\
where a.rtp_audio_in_mos is not null and a.answer_stamp > NOW() - INTERVAL '$1 hour'"
if [ "$#" -eq 2 ]; then
SQL="${SQL} and b.domain_name = '$2'"
fi
SQL="${SQL} group by b.domain_name"
echo ""
psql --host=$db_host --port=$db_port --username=fusionpbx -c "${SQL}"
exit 0
Last edited: