Author Topic: Powerline USP Active / Total  (Read 3822 times)

Offline NZBmets

  • Prolific Indexer
  • ****
  • Posts: 260
  • Helpful: +11/-0
Powerline USP Active / Total
« on: 2014-04-25, 06:24:42 am »
In the scheme of tmux this is trivial, but if anyone knows how to correct it I'd love to  ....

The USP connection info in the tmux Poweline never seems to be accurate, mostly reading A0 T0. There are brief moments where that changes. The USP Connections in the window 0.0 does seem to catch the current connections.

Offline NZBmets

  • Prolific Indexer
  • ****
  • Posts: 260
  • Helpful: +11/-0
Re: Powerline USP Active / Total
« Reply #1 on: 2014-04-25, 07:00:24 am »
Managed to sort it as follows:

file ../tmux/powerline/powerline/segments/uspsetting.sh

Modified:
Code: [Select]
# Get info about primary NNTP connections.
    mainusp=`( dig ${uspsetting} A +short | tail -n1; \
dig ${uspsetting} AAAA +short | tail -n1 ) \
| head -n1`
grepusp=$(echo "${mainusp[@]}" | sed 's/ /|/g')
maincount=$(ss -n | awk '/ESTAB/ {printf"%s %s\n",$1,$6}' | egrep "$grepusp" | grep -c ${uspsetting[1]})
tmaincount=$(ss -n | awk '{printf"%s %s\n",$1,$6}' | egrep "$grepusp" | grep -c ${uspsetting[1]})

    # Check to see if have an alt USP set, if so get those connections too.
    if [[ -n "${uspsetting[3]}" ]]; then
        #altusp=( $(dig ${uspsetting[2]} | awk '/    A   / {print $5}') )
altusp=`( dig ${uspsetting[2]} A +short | tail -n1; \
dig ${uspsetting[2]} AAAA +short | tail -n1 ) \
| head -n1`
        grepausp=$(echo "${altusp[@]}" | sed 's/ /|/g')
        altcount=$(ss -n | awk '/ESTAB/ {printf"%s %s\n",$1,$6}' | egrep "$grepausp" | grep -c ${uspsetting[3]})
        taltcount=$(ss -n | awk '{printf"%s %s\n",$1,$6}' | egrep "$grepausp" | grep -c ${uspsetting[3]})

Post Update:
05/24/14 Added fix for alternate USP
« Last Edit: 2014-05-24, 01:11:40 pm by NZBmets »