From a46f939b8886ad4cb4860b26016a7b5f0b1a7e8b Mon Sep 17 00:00:00 2001 From: PiBa-NL Date: Wed, 1 May 2013 23:54:17 +0200 Subject: haproxy-devel, add widget files.. --- config/haproxy-devel/haproxy.widget.php | 224 ++++++++++++++++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100644 config/haproxy-devel/haproxy.widget.php (limited to 'config/haproxy-devel/haproxy.widget.php') diff --git a/config/haproxy-devel/haproxy.widget.php b/config/haproxy-devel/haproxy.widget.php new file mode 100644 index 00000000..b084cc62 --- /dev/null +++ b/config/haproxy-devel/haproxy.widget.php @@ -0,0 +1,224 @@ +
"; +$in=""; +$running=""; +$stopped=""; +$log=""; +$start=""; +$stop=""; + +$clients=array(); +$clientstraffic=array(); + +$statistics = haproxy_get_statistics(); +$frontends = $statistics['frontends']; +$backends = $statistics['backends']; +$servers = $statistics['servers']; + +if ($show_clients == "YES") { + $clients = haproxy_get_clients(); +} + +echo ""; + print ""; + print ""; + print ""; + + foreach ($frontends as $fe => $fedata){ + print ""; + print ""; + if ($fedata['status'] == "OPEN") { + $fedata['status'] = $running." ".$fedata['status']; + } else { + $fedata['status'] = $stopped." ".$fedata['status']; + } + print ""; + } + + print ""; +} + +#Backends/Servers w/o clients +print ""; +print ""; +print ""; +print ""; + +foreach ($backends as $be => $bedata) { + if ($bedata['status'] == "UP") { + $statusicon = $in; + $besess = $bedata['scur']." / ".$bedata['slim']; + $bename = $bedata['pxname']; + } else { + $statusicon = $out; + $besess = "".$bedata['status'].""; + $bename = "".$bedata['pxname'].""; + } + $icondetails = " onmouseover=\"this.title='".$bedata['status']."'\""; + print ""; + print ""; + print ""; + print ""; + print ""; + + foreach ($servers as $srv => $srvdata) { + if ($srvdata['pxname'] == $bedata['pxname']) { + if ($srvdata['status'] == "UP") { + $nextaction = "stop"; + $statusicon = $in; + $acticon = $stop; + $srvname = $srvdata['svname']; + } elseif ($srvdata['status'] == "no check") { + $nextaction = "stop"; + $statusicon = $in; + $acticon = $stop; + $srvname = $srvdata['svname']; + $srvdata['scur'] = "no check"; + } elseif ($srvdata['status'] == "MAINT") { + $nextaction = "start"; + $statusicon = $out; + $acticon = $start; + $srvname = "".$srvdata['svname'].""; + $srvdata['scur'] = "".$srvdata['status'].""; + } else { + $nextaction = "stop"; + $statusicon = $out; + $acticon = $stop; + $srvname = "".$srvdata['svname'].""; + $srvdata['scur'] = "".$srvdata['status'].""; + } + $icondetails = " onmouseover=\"this.title='".$srvdata['status']."'\""; + print ""; + print ""; + print ""; + print ""; + + if ($show_clients == "YES") { + foreach ($clients as $cli => $clidata) { + if ($clidata['be'] == $bedata['pxname'] && $clidata['srv'] == $srvdata['svname']) { + print ""; + if ($show_clients_traffic == "YES") { + $clisessoutput=exec("/bin/echo 'show sess ".$clidata['sessid']."' | /usr/local/bin/socat unix-connect:/tmp/haproxy.socket stdio | /usr/bin/grep 'total=' | /usr/bin/awk '{print $5}'",$clidebug); + $i=0; + foreach($clidebug as $cliline) { + $clibytes = explode("=", $cliline); + if ($clibytes[1] >= 1024 and $clibytes[1] <= 1048576) { + $clibytes = (int)($clibytes[1]/1024)."Kb"; + } elseif ($clibytes[1] >= 1048576 and $clibytes[1] <= 10485760) { + $clibytes = round(($clibytes[1]/1048576),2)."Mb"; + } elseif ($clibytes[1] >= 10485760) { + $clibytes = round(($clibytes[1]/1048576),1)."Mb"; + } else { + $clibytes = $clibytes[1]."B"; + } + $clientstraffic[$i] = $clibytes; + $i++; + } + $clidebug=""; + print ""; + } else { + print ""; + } + } + } + } + } + } +} + +echo"
FrontEnd(s)
NameSessions
(cur/max)
Status
".$fedata['pxname']."".$fedata['scur']." / ".$fedata['slim']."
".$fedata['status']."
Backend(s)/Server(s)
Backend(s)
 Server(s)"; +if ($show_clients == "YES") { + print "
  Client(s) addr:port"; +} +print "
Sessions
(cur/max)
"; +if ($show_clients == "YES" and $show_clients_traffic != "YES") { + print "age/id"; +} elseif ($show_clients == "YES" and $show_clients_traffic == "YES") { + print "age/traffic i/o"; +} +print "
Status
/
Actions
".$bename."".$besess."
".$statusicon."
 
 ".$srvname."".$srvdata['scur']."
".$statusicon."
".$acticon."
  ".$clidata['src']." ".$log."".$clidata['age']." / ".$clientstraffic[0]." / ".$clientstraffic[1]."
".$clidata['age']." / ".$clidata['sessid']."
"; +?> + + -- cgit v1.2.3