fix(voipctl): Fix JSON output in status command
- Fix active_calls and extensions count to output clean integers - Remove tr -cd which was causing duplicate values in JSON - Use simpler variable assignment with fallback to 0 - Prevents malformed JSON output from cmd_status() Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
4fee9e4c12
commit
c137296dcd
@ -284,17 +284,21 @@ cmd_status() {
|
||||
|
||||
if container_running; then
|
||||
running=1
|
||||
|
||||
|
||||
# Check trunk registration
|
||||
if container_exec asterisk -rx "pjsip show registrations" 2>/dev/null | grep -q "Registered"; then
|
||||
registered=1
|
||||
fi
|
||||
|
||||
|
||||
# Count active calls
|
||||
active_calls=$(container_exec asterisk -rx "core show channels" 2>/dev/null | grep -oE "^[0-9]+ active" | cut -d' ' -f1 || echo 0)
|
||||
|
||||
local calls_output
|
||||
calls_output=$(container_exec asterisk -rx "core show channels" 2>/dev/null | grep -oE "^[0-9]+ active" | head -1 | cut -d' ' -f1) || true
|
||||
active_calls=${calls_output:-0}
|
||||
|
||||
# Count extensions
|
||||
extensions=$(container_exec asterisk -rx "pjsip show endpoints" 2>/dev/null | grep -c "^[0-9]" || echo 0)
|
||||
local ext_output
|
||||
ext_output=$(container_exec asterisk -rx "pjsip show endpoints" 2>/dev/null | wc -l) || true
|
||||
extensions=${ext_output:-0}
|
||||
fi
|
||||
|
||||
cat <<EOF
|
||||
|
||||
Loading…
Reference in New Issue
Block a user