#!/bin/sh usage(){ echo "conproxy-connections [ --start | --size ] [ --help ]" echo echo "Reports all connections managed by conproxy, including old conproxys" echo "(conproxys left running after a restart)." echo "By default, the report is sorted by 'last activity' with staled connections" echo "at the end". echo echo "--start: Sort using the 'Started' column, with older connections at the end" echo "--size : Sort using the 'Bytes sent' column, with less active connection" echo " at the end" } SORTOPT="-r -k5" while [ $# != 0 ] do case $1 in --start) SORTOPT="-r -k4" ;; --size) SORTOPT="-k3rn" ;; --help) usage exit 0 ;; *) usage exit 1 ;; esac shift done echo "ID From/to Bytes sent Started Last activity Status/Description" echo "--------- -------- ------------ ------------------- -------------------" ( conproxy-control connections for ((N=0; N<10; N++)) do conproxy-control -p /var/run/blackhole/old/conproxy.sock.old$N connections 2>/dev/null done ) | sort $SORTOPT | while read id from bytes started last status1 status2 status3 description do printf "%9d %8s %12d %s %s %s/%s\n" $id $from $bytes $started $last $status1/$status2/$status3 "$description" done