Adding legendary haproxy-status script

Change-Id: I9a0f92eacdead912135ecbeef4b4834e9eba0cc5
diff --git a/haproxy/files/haproxy-status.sh b/haproxy/files/haproxy-status.sh
new file mode 100644
index 0000000..48fba3a
--- /dev/null
+++ b/haproxy/files/haproxy-status.sh
@@ -0,0 +1,49 @@
+{%- from "haproxy/map.jinja" import proxy with context -%}
+#!/bin/sh
+
+show_stats() {
+  echo 'show stat' | socat 'UNIX-CONNECT:{{ proxy.stats_socket }}' STDIO | awk \
+  '
+  function fillstr(string, num)
+  {
+    len=length(string);
+    if (len>=num)
+    {
+      printf("%s",substr(string,1,num));
+    }
+    else
+    {
+      printf("%s",string);
+      for(i=1; i<=num-len; i++)
+      {
+        printf(" ");
+      }
+    }
+  }
+
+  BEGIN {
+    FS = ",";
+  };
+
+  {
+    if ($1 ~ /^#/) { next };
+    if ($1 == "") { next };
+
+    status=sprintf("Status: %s",$18);
+    if ($37 != "") {
+      status=status sprintf("/%s",$37);
+    }
+    sessions=sprintf("Sessions: %s",$5);
+    rate=sprintf("Rate: %s",$34);
+
+    fillstr($1,25);
+    fillstr($2,15);
+    fillstr(status,20);
+    fillstr(sessions,15);
+    fillstr(rate,10);
+    printf("\n");
+  }
+  '
+}
+
+show_stats
diff --git a/haproxy/proxy.sls b/haproxy/proxy.sls
index 7935c62..55792c6 100644
--- a/haproxy/proxy.sls
+++ b/haproxy/proxy.sls
@@ -27,6 +27,22 @@
   - require:
     - pkg: haproxy_packages
 
+haproxy_status_packages:
+  pkg.installed:
+  - pkgs:
+    - socat
+
+haproxy_status_sh:
+  file.managed:
+  - name: /usr/bin/haproxy-status.sh
+  - user: root
+  - group: root
+  - mode: 700
+  - source: salt://haproxy/files/haproxy-status.sh
+  - template: jinja
+  - require:
+    - pkg: haproxy_status_packages
+
 {%- if grains.get('virtual_subtype', None) not in ['Docker', 'LXC'] %}
 
 net.ipv4.ip_nonlocal_bind: