Fix transmission-metrics session ID parsing
Transmission doesn't support HEAD requests, so use -i flag with sed to parse only the HTTP headers (stopping at the blank line before body). Also anchor grep pattern to line start to avoid matching HTML content. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
7468023cd2
commit
0afd34590d
1 changed files with 3 additions and 1 deletions
|
|
@ -9,8 +9,10 @@ OUTPUT_FILE="{{ transmission_metrics_dir }}/transmission.prom"
|
|||
TEMP_FILE="${OUTPUT_FILE}.tmp"
|
||||
|
||||
# Get session ID (required for transmission RPC)
|
||||
# Note: transmission doesn't support HEAD requests, so we make a request and parse
|
||||
# the 409 response headers. We use sed to stop at the blank line (which has \r) before body.
|
||||
get_session_id() {
|
||||
curl -s -I "$RPC_URL" 2>/dev/null | grep -i 'X-Transmission-Session-Id' | awk '{print $2}' | tr -d '\r'
|
||||
curl -s -i "$RPC_URL" 2>/dev/null | sed '/^\r$/q' | grep -i '^X-Transmission-Session-Id:' | awk '{print $2}' | tr -d '\r'
|
||||
}
|
||||
|
||||
# Make RPC request
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue