fix: close caller analytics SIP integration gaps

This commit is contained in:
hectorzhao
2026-08-31 17:42:19 +08:00
parent 116e316eca
commit d78616561e
6 changed files with 27 additions and 5 deletions
@@ -21,13 +21,19 @@ for file in /etc/lisglosips/caller-analytics.env /etc/rsyslog.d/35-caller-analyt
if test -f "$file"; then cp -a "$file" "$backup/$(basename "$file")"; fi
done
changed=0
was_running=$(systemctl is-active lisglosips@caller-analytics || true)
rollback() {
rc=$?
if test "$changed" = 1; then
systemctl stop lisglosips@caller-analytics || true
cp -a "$backup/opensips.cfg" /etc/opensips/opensips.cfg
for file in /etc/lisglosips/caller-analytics.env /etc/rsyslog.d/35-caller-analytics.conf; do
if test -f "$backup/$(basename "$file")"; then cp -a "$backup/$(basename "$file")" "$file"; else rm -f "$file"; fi
done
ln -sfn "$old" /opt/lisglosips/current
systemctl restart rsyslog || true
systemctl restart opensips lisglosips@api || true
if test "$was_running" = active; then systemctl start lisglosips@caller-analytics || true; fi
fi
echo "FAILED rc=$rc backup=$backup (additive analytics tables retained)"
exit "$rc"
@@ -44,6 +50,8 @@ if grep -q 'CRA1|' "$source_cfg"; then
else
/usr/bin/node "$new/scripts/instrument-caller-analytics.mjs" "$source_cfg" "$new/opensips-candidate.cfg"
fi
python3 "$new/infra/server-b/caller-analytics/verify-hotpath.py" "$new/opensips-candidate.cfg"
systemctl start lisglosips-redis-hotpath-load.service
opensips -C -f "$new/opensips-candidate.cfg"
set -a
source /etc/lisglosips/secrets/mysql-migrate.env
+1 -1
View File
@@ -1,5 +1,5 @@
# OpenSIPS emits only analytics observations here. No network destination.
if ($programname == 'opensips' and $msg contains 'CRA1|') then {
if (($programname == 'opensips' or $syslogtag startswith '/usr/sbin/opensips[') and $msg contains 'CRA1|') then {
action(type="omfile" file="/var/log/lisglosips/caller-analytics.log"
fileOwner="syslog" fileGroup="lisglosips" fileCreateMode="0640"
queue.type="LinkedList" queue.filename="caller-analytics"
@@ -0,0 +1,14 @@
#!/usr/bin/env python3
"""Align candidate EVALSHA with the installed Lua bytes actually loaded by the loader."""
import hashlib
from pathlib import Path
import re
import sys
config = Path(sys.argv[1])
script = Path('/etc/opensips/lisglosips_hotpath.lua').read_text()
sha = hashlib.sha1(script.encode()).hexdigest()
text = config.read_text()
matches = re.findall(r'EVALSHA ([0-9a-f]{40}) 1 cfg:active_version', text)
assert len(matches) == 1, 'Unexpected hotpath layout'
config.write_text(text.replace('EVALSHA ' + matches[0], 'EVALSHA ' + sha))
print('Installed hotpath SHA:', sha, 'previous:', matches[0])