~ubuntu-branches/ubuntu/utopic/haproxy/utopic-proposed

« back to all changes in this revision

Viewing changes to .pc/0001-Replace-bash-with-sh-and-fix-bashisms.patch/examples/stats_haproxy.sh

  • Committer: Package Import Robot
  • Author(s): Vincent Bernat, Apollon Oikonomopoulos, Vincent Bernat, Prach Pongpanich
  • Date: 2013-05-06 20:02:14 UTC
  • mfrom: (1.1.12)
  • Revision ID: package-import@ubuntu.com-20130506200214-36s6p81fsa5zqybt
Tags: 1.4.23-1
[ Apollon Oikonomopoulos ]
* New upstream version (Closes: #643650, #678953)
   + This fixes CVE-2012-2942 (Closes: #674447)
   + This fixes CVE-2013-1912 (Closes: #704611)
* Ship vim addon as vim-haproxy (Closes: #702893)
* Check for the configuration file after sourcing /etc/default/haproxy
  (Closes: #641762)
* Use /dev/log for logging by default (Closes: #649085)

[ Vincent Bernat ]
* debian/control:
   + add Vcs-* fields
   + switch maintenance to Debian HAProxy team. (Closes: #706890)
   + drop dependency to quilt: 3.0 (quilt) format is in use.
* debian/rules:
   + don't explicitly call dh_installchangelog.
   + use dh_installdirs to install directories.
   + use dh_install to install error and configuration files.
   + switch to `linux2628` Makefile target for Linux.
* debian/postrm:
   + remove haproxy user and group on purge.
* Ship a more minimal haproxy.cfg file: no `listen` blocks but `global`
  and `defaults` block with appropriate configuration to use chroot and
  logging in the expected way.

[ Prach Pongpanich ]
* debian/copyright:
   + add missing copyright holders
   + update years of copyright
* debian/rules:
   + build with -Wl,--as-needed to get rid of unnecessary depends
* Remove useless files in debian/haproxy.{docs,examples}
* Update debian/watch file, thanks to Bart Martens

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
 
 
3
## contrib by prizee.com
 
4
 
 
5
socket='/var/run/haproxy.stat'
 
6
 
 
7
if ! type socat >/dev/null 2>&1 ; then
 
8
    echo "can't find socat in PATH" 1>&2
 
9
    exit 1
 
10
fi
 
11
 
 
12
printUsage ()
 
13
{
 
14
    echo -e "Usage : $(basename $0) [options] -s section
 
15
--section -s section\t: section to use ( --list format)
 
16
Options :
 
17
--socket -S [socket]\t: socket to use (default: /var/run/haproxy.stat)
 
18
--list -l\t\t: print available sections
 
19
--help -h\t\t: print this  message"
 
20
}
 
21
 
 
22
getRawStat ()
 
23
{
 
24
    if [ ! -S $socket ] ; then
 
25
        echo "$socket socket unavailable" 1>&2
 
26
        exit 1
 
27
    fi
 
28
 
 
29
    if ! printf "show stat\n" | socat unix-connect:${socket} stdio | grep -v "^#" ; then
 
30
        echo "cannot read $socket" 1>&2
 
31
        exit 1
 
32
    fi
 
33
}
 
34
 
 
35
getStat ()
 
36
{
 
37
    stats=$(getRawStat | grep $1 | awk -F "," '{print $5" "$8}')
 
38
    export cumul=$(echo $stats | cut -d " " -f2)
 
39
    export current=$(echo $stats | cut -d " " -f1)
 
40
}
 
41
 
 
42
showList ()
 
43
{
 
44
    getRawStat | awk -F "," '{print $1","$2}'
 
45
}
 
46
 
 
47
set -- `getopt -u -l socket:,section:,list,help -- s:S:lh "$@"`
 
48
 
 
49
while true ; do
 
50
    case $1 in
 
51
        --socket|-S) socket=$2 ; shift 2 ;;
 
52
        --section|-s) section=$2 ; shift 2 ;;
 
53
        --help|-h) printUsage ; exit 0 ;;
 
54
        --list|-l) showList ; exit 0 ;;
 
55
        --) break ;;
 
56
    esac
 
57
done
 
58
 
 
59
if [ "$section" = "" ] ; then
 
60
    echo "section not specified, run '$(basename $0) --list' to know available sections" 1>&2
 
61
    printUsage
 
62
    exit 1
 
63
fi
 
64
 
 
65
cpt=0
 
66
totalrate=0
 
67
while true ; do
 
68
    getStat $section
 
69
    if [ "$cpt" -gt "0" ] ; then
 
70
        sessionrate=$(($cumul-$oldcumul))
 
71
        totalrate=$(($totalrate+$sessionrate))
 
72
        averagerate=$(($totalrate/$cpt))
 
73
        printf "$sessionrate sessions/s (avg: $averagerate )\t$current concurrent sessions\n"
 
74
    fi
 
75
    oldcumul=$cumul
 
76
    sleep 1
 
77
    cpt=$(($cpt+1))
 
78
done