aboutsummaryrefslogtreecommitdiffstats
path: root/config/haproxy-devel
diff options
context:
space:
mode:
authorErmal Luçi <eri@pfsense.org>2014-02-17 08:36:00 +0100
committerErmal Luçi <eri@pfsense.org>2014-02-17 08:36:00 +0100
commitb23398b68fabefebd8b9c4715b81772df7c6228c (patch)
treee0004e3d7a9ce073ca74f76a5ffe0d288bc6cf3c /config/haproxy-devel
parent01434bbdb83f14546eb39fb96760708a5a4322e3 (diff)
parent46ea54e1b550fcac78752b70f3419a0bf1eb7ec4 (diff)
downloadpfsense-packages-b23398b68fabefebd8b9c4715b81772df7c6228c.tar.gz
pfsense-packages-b23398b68fabefebd8b9c4715b81772df7c6228c.tar.bz2
pfsense-packages-b23398b68fabefebd8b9c4715b81772df7c6228c.zip
Merge pull request #589 from PiBa-NL/hap_statspage
haproxy-devel, integrated stats page with stick-table info WebGUI
Diffstat (limited to 'config/haproxy-devel')
-rw-r--r--config/haproxy-devel/haproxy.inc36
-rw-r--r--config/haproxy-devel/haproxy.xml10
-rwxr-xr-xconfig/haproxy-devel/haproxy_global.php25
-rw-r--r--config/haproxy-devel/haproxy_listeners.php8
-rw-r--r--config/haproxy-devel/haproxy_listeners_edit.php8
-rw-r--r--config/haproxy-devel/haproxy_pool_edit.php8
-rw-r--r--config/haproxy-devel/haproxy_pools.php8
-rw-r--r--config/haproxy-devel/haproxy_socketinfo.inc25
-rw-r--r--config/haproxy-devel/haproxy_stats.php256
-rw-r--r--config/haproxy-devel/pkg_haproxy_tabs.inc25
10 files changed, 377 insertions, 32 deletions
diff --git a/config/haproxy-devel/haproxy.inc b/config/haproxy-devel/haproxy.inc
index d4b2ab2c..5ae86bb9 100644
--- a/config/haproxy-devel/haproxy.inc
+++ b/config/haproxy-devel/haproxy.inc
@@ -628,6 +628,21 @@ function haproxy_writeconf($configpath) {
}
}
fwrite ($fd, "\n");
+
+ $localstatsport = $a_global['localstatsport'];
+ if ($localstatsport){
+ fwrite ($fd, "listen HAProxyLocalStats\n");
+ fwrite ($fd, "\tbind 127.0.0.1:$localstatsport\n");
+ fwrite ($fd, "\tmode http\n");
+ fwrite ($fd, "\tstats enable\n");
+ fwrite ($fd, "\tstats refresh 10\n");
+ fwrite ($fd, "\tstats admin if TRUE\n");
+ fwrite ($fd, "\tstats uri /haproxy_stats.php?haproxystats=1\n");
+ fwrite ($fd, "\ttimeout client 5000\n");
+ fwrite ($fd, "\ttimeout connect 5000\n");
+ fwrite ($fd, "\ttimeout server 5000\n");
+ fwrite ($fd, "\n");
+ }
}
// Try and get a unique array for address:port as frontends can duplicate
@@ -1249,4 +1264,25 @@ function haproxy_escape_acl_name($aclname) {
return preg_replace_callback('([^A-Za-z0-9\._\-\:])', function($match){return "_".dechex(ord($match[0]));}, $aclname);
}
+function haproxy_find_create_certificate($certificatename) {
+ global $g;
+ $cert = lookup_cert_by_name($certificatename);
+ if (is_array($cert))
+ return $cert;
+ global $config;
+ $a_cert =& $config['cert'];
+ $cert = array();
+ $cert['refid'] = uniqid();
+ $cert['descr'] = gettext($certificatename);
+ mwexec("/usr/local/bin/openssl genrsa 1024 > {$g['tmp_path']}/ssl.key");
+ mwexec("/usr/local/bin/openssl req -new -x509 -nodes -sha256 -days 2000 -key {$g['tmp_path']}/ssl.key > {$g['tmp_path']}/ssl.crt");
+ $crt = file_get_contents("{$g['tmp_path']}/ssl.crt");
+ $key = file_get_contents("{$g['tmp_path']}/ssl.key");
+ unlink("{$g['tmp_path']}/ssl.key");
+ unlink("{$g['tmp_path']}/ssl.crt");
+ cert_import($cert, $crt, $key);
+ $a_cert[] = $cert;
+ return $cert;
+}
+
?>
diff --git a/config/haproxy-devel/haproxy.xml b/config/haproxy-devel/haproxy.xml
index 6b25dd46..bbc32575 100644
--- a/config/haproxy-devel/haproxy.xml
+++ b/config/haproxy-devel/haproxy.xml
@@ -90,6 +90,11 @@
<item>http://www.pfsense.com/packages/config/haproxy-devel/haproxy_pool_edit.php</item>
</additional_files_needed>
<additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>077</chmod>
+ <item>http://www.pfsense.com/packages/config/haproxy-devel/haproxy_stats.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
<prefix>/usr/local/pkg/</prefix>
<chmod>077</chmod>
<item>http://www.pfsense.com/packages/config/haproxy-devel/haproxy_socketinfo.inc</item>
@@ -119,6 +124,11 @@
<chmod>0755</chmod>
<item>http://www.pfsense.org/packages/config/haproxy-devel/pkg_haproxy.inc</item>
</additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>077</chmod>
+ <item>http://www.pfsense.com/packages/config/haproxy-devel/pkg_haproxy_tabs.inc</item>
+ </additional_files_needed>
<custom_delete_php_command>
</custom_delete_php_command>
<custom_add_php_command>
diff --git a/config/haproxy-devel/haproxy_global.php b/config/haproxy-devel/haproxy_global.php
index 0a92cde7..8264558f 100755
--- a/config/haproxy-devel/haproxy_global.php
+++ b/config/haproxy-devel/haproxy_global.php
@@ -34,6 +34,7 @@ require_once("guiconfig.inc");
require_once("haproxy.inc");
require_once("haproxy_utils.inc");
require_once("globals.inc");
+require_once("pkg_haproxy_tabs.inc");
if (!is_array($config['installedpackages']['haproxy']))
$config['installedpackages']['haproxy'] = array();
@@ -65,6 +66,9 @@ if ($_POST) {
if ($_POST['maxconn'] && (!is_numeric($_POST['maxconn'])))
$input_errors[] = "The maximum number of connections should be numeric.";
+
+ if ($_POST['localstatsport'] && (!is_numeric($_POST['localstatsport'])))
+ $input_errors[] = "The local stats port should be numeric.";
/*if($_POST['synchost1'] && !is_ipaddr($_POST['synchost1']))
$input_errors[] = "Synchost1 needs to be an IPAddress.";
@@ -86,6 +90,7 @@ if ($_POST) {
$config['installedpackages']['haproxy']['loglevel'] = $_POST['loglevel'] ? $_POST['loglevel'] : false;
$config['installedpackages']['haproxy']['carpdev'] = $_POST['carpdev'] ? $_POST['carpdev'] : false;
//$config['installedpackages']['haproxy']['syncpassword'] = $_POST['syncpassword'] ? $_POST['syncpassword'] : false;
+ $config['installedpackages']['haproxy']['localstatsport'] = $_POST['localstatsport'] ? $_POST['localstatsport'] : false;
$config['installedpackages']['haproxy']['advanced'] = $_POST['advanced'] ? base64_encode($_POST['advanced']) : false;
$config['installedpackages']['haproxy']['nbproc'] = $_POST['nbproc'] ? $_POST['nbproc'] : false;
touch($d_haproxyconfdirty_path);
@@ -106,6 +111,7 @@ $pconfig['remotesyslog'] = $config['installedpackages']['haproxy']['remotesyslog
$pconfig['logfacility'] = $config['installedpackages']['haproxy']['logfacility'];
$pconfig['loglevel'] = $config['installedpackages']['haproxy']['loglevel'];
$pconfig['carpdev'] = $config['installedpackages']['haproxy']['carpdev'];
+$pconfig['localstatsport'] = $config['installedpackages']['haproxy']['localstatsport'];
$pconfig['advanced'] = base64_decode($config['installedpackages']['haproxy']['advanced']);
$pconfig['nbproc'] = $config['installedpackages']['haproxy']['nbproc'];
@@ -148,12 +154,7 @@ function enable_change(enable_change) {
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td class="tabnavtbl">
<?php
- /* active tabs */
- $tab_array = array();
- $tab_array[] = array("Settings", true, "haproxy_global.php");
- $tab_array[] = array("Frontend", false, "haproxy_listeners.php");
- $tab_array[] = array("Backend", false, "haproxy_pools.php");
- display_top_tabs($tab_array);
+ haproxy_display_top_tabs_active($haproxy_tab_array['haproxy'], "settings");
?>
</td></tr>
<tr>
@@ -339,6 +340,18 @@ function enable_change(enable_change) {
</td>
</tr>
<tr>
+ <td colspan="2" valign="top" class="listtopic">Stats tab, 'internal' stats port</td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell">Internal stats port</td>
+ <td class="vtable">
+ <input name="localstatsport" type="text" <?if(isset($pconfig['localstatsport'])) echo "value=\"{$pconfig['localstatsport']}\"";?> size="10" maxlength="5" /> EXAMPLE: 2200<br/>
+ Sets the internal port to be used for the stats tab.
+ This is bound to 127.0.0.1 so will not be directly exposed on any LAN/WAN/other interface. It is used to internally pass through the stats page.
+ Leave this setting empty to remove the "HAProxyLocalStats" item from the stats page and save a little on recources.
+ </td>
+ </tr>
+ <tr>
<td colspan="2" valign="top" class="listtopic">Global Advanced pass thru</td>
</tr>
<tr>
diff --git a/config/haproxy-devel/haproxy_listeners.php b/config/haproxy-devel/haproxy_listeners.php
index 3ff53cea..2a1f12e6 100644
--- a/config/haproxy-devel/haproxy_listeners.php
+++ b/config/haproxy-devel/haproxy_listeners.php
@@ -34,6 +34,7 @@ require_once("guiconfig.inc");
require_once("haproxy.inc");
require_once("certs.inc");
require_once("haproxy_utils.inc");
+require_once("pkg_haproxy_tabs.inc");
if (!is_array($config['installedpackages']['haproxy']['ha_backends']['item'])) {
$config['installedpackages']['haproxy']['ha_backends']['item'] = array();
@@ -91,12 +92,7 @@ include("head.inc");
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td class="tabnavtbl">
<?php
- /* active tabs */
- $tab_array = array();
- $tab_array[] = array("Settings", false, "haproxy_global.php");
- $tab_array[] = array("Frontend", true, "haproxy_listeners.php");
- $tab_array[] = array("Backend", false, "haproxy_pools.php");
- display_top_tabs($tab_array);
+ haproxy_display_top_tabs_active($haproxy_tab_array['haproxy'], "frontend");
?>
</td></tr>
<tr>
diff --git a/config/haproxy-devel/haproxy_listeners_edit.php b/config/haproxy-devel/haproxy_listeners_edit.php
index 3c62ec3a..bd0f93d5 100644
--- a/config/haproxy-devel/haproxy_listeners_edit.php
+++ b/config/haproxy-devel/haproxy_listeners_edit.php
@@ -34,6 +34,7 @@ require("guiconfig.inc");
require_once("haproxy.inc");
require_once("haproxy_utils.inc");
require_once("haproxy_htmllist.inc");
+require_once("pkg_haproxy_tabs.inc");
/* Compatibility function for pfSense 2.0 */
if (!function_exists("cert_get_purpose")) {
@@ -373,12 +374,7 @@ $interfaces = haproxy_get_bindable_interfaces();
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td class="tabnavtbl">
<?php
- /* active tabs */
- $tab_array = array();
- $tab_array[] = array("Settings", false, "haproxy_global.php");
- $tab_array[] = array("Frontend", true, "haproxy_listeners.php");
- $tab_array[] = array("Backend", false, "haproxy_pools.php");
- display_top_tabs($tab_array);
+ haproxy_display_top_tabs_active($haproxy_tab_array['haproxy'], "frontend");
?>
</td></tr>
<tr>
diff --git a/config/haproxy-devel/haproxy_pool_edit.php b/config/haproxy-devel/haproxy_pool_edit.php
index 93fa20dc..4eb280ca 100644
--- a/config/haproxy-devel/haproxy_pool_edit.php
+++ b/config/haproxy-devel/haproxy_pool_edit.php
@@ -34,6 +34,7 @@ require("guiconfig.inc");
require_once("haproxy.inc");
require_once("haproxy_utils.inc");
require_once("haproxy_htmllist.inc");
+require_once("pkg_haproxy_tabs.inc");
$d_haproxyconfdirty_path = $g['varrun_path'] . "/haproxy.conf.dirty";
@@ -325,12 +326,7 @@ foreach($simplefields as $field){
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td class="tabnavtbl">
<?php
- /* active tabs */
- $tab_array = array();
- $tab_array[] = array("Settings", false, "haproxy_global.php");
- $tab_array[] = array("Frontend", false, "haproxy_listeners.php");
- $tab_array[] = array("Backend", true, "haproxy_pools.php");
- display_top_tabs($tab_array);
+ haproxy_display_top_tabs_active($haproxy_tab_array['haproxy'], "backend");
?>
</td></tr>
<tr>
diff --git a/config/haproxy-devel/haproxy_pools.php b/config/haproxy-devel/haproxy_pools.php
index 39009633..01655006 100644
--- a/config/haproxy-devel/haproxy_pools.php
+++ b/config/haproxy-devel/haproxy_pools.php
@@ -32,6 +32,7 @@
$shortcut_section = "haproxy";
require_once("guiconfig.inc");
require_once("haproxy.inc");
+require_once("pkg_haproxy_tabs.inc");
if (!is_array($config['installedpackages']['haproxy']['ha_pools']['item'])) {
@@ -86,12 +87,7 @@ include("head.inc");
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td class="tabnavtbl">
<?php
- /* active tabs */
- $tab_array = array();
- $tab_array[] = array("Settings", false, "haproxy_global.php");
- $tab_array[] = array("Frontend", false, "haproxy_listeners.php");
- $tab_array[] = array("Backend", true, "haproxy_pools.php");
- display_top_tabs($tab_array);
+ haproxy_display_top_tabs_active($haproxy_tab_array['haproxy'], "backend");
?>
</td></tr>
<tr>
diff --git a/config/haproxy-devel/haproxy_socketinfo.inc b/config/haproxy-devel/haproxy_socketinfo.inc
index eeaba8b6..5c6e847d 100644
--- a/config/haproxy-devel/haproxy_socketinfo.inc
+++ b/config/haproxy-devel/haproxy_socketinfo.inc
@@ -57,15 +57,36 @@ function haproxy_set_server_enabled($backend, $server, $enable) {//"enable be/se
return haproxy_socket_command("$enablecommand server $backend/$server");
}
+function haproxy_get_tables(){// "show table"
+ $result = array();
+ $cmdresult = haproxy_socket_command("show table");
+ foreach($cmdresult as $line) {
+ if (trim($line) == "")
+ continue;
+ list($table,$type,$size,$used) = explode(",", $line);
+ $table = explode(":", $table);
+ $type = explode(":", $type);
+ $size = explode(":", $size);
+ $used = explode(":", $used);
+ $newtable = array();
+ $tablename = trim($table[1]);
+ $newtable['type'] = trim($type[1]);
+ $newtable['size'] = $size[1];
+ $newtable['used'] = $used[1];
+ $result[$tablename] = $newtable;
+ }
+ return $result;
+}
+
function haproxy_get_statistics(){// "show stat"
$result = array();
$frontends=array();
$backends=array();
$servers=array();
- $result = haproxy_socket_command("show stat");
+ $cmdresult = haproxy_socket_command("show stat");
- foreach($result as $line) {
+ foreach($cmdresult as $line) {
list($pxname,$svname,$qcur,$qmax,$scur,$smax,$slim,$stot,$bin,$bout,$dreq,$dresp,$ereq,$econ,$eresp,$wretr,$wredis,$status,$weight,$act,$bck,$chkfail,$chkdown,$lastchg,$downtime,$qlimit,$pid,$iid,$sid,$throttle,$lbtot,$tracked,$type,$rate,$rate_lim,$rate_max,$check_status,$check_code,$check_duration,$hrsp_1xx,$hrsp_2xx,$hrsp_3xx,$hrsp_4xx,$hrsp_5xx,$hrsp_other,$hanafail,$req_rate,$req_rate_max,$req_tot,$cli_abrt,$srv_abrt,$comp_in,$comp_out,$comp_byp,$comp_rsp) = explode(",", $line);
#Retrieve data
switch ($svname) {
diff --git a/config/haproxy-devel/haproxy_stats.php b/config/haproxy-devel/haproxy_stats.php
new file mode 100644
index 00000000..8ad04c92
--- /dev/null
+++ b/config/haproxy-devel/haproxy_stats.php
@@ -0,0 +1,256 @@
+<?php
+/*
+ haproxy_stats.php
+ part of pfSense (http://www.pfsense.com/)
+ Copyright (C) 2013 PiBa-NL
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+require_once("authgui.inc");
+require_once("config.inc");
+require_once("haproxy_socketinfo.inc");
+
+$pconfig = $config['installedpackages']['haproxy'];
+if (isset($_GET['haproxystats']) || isset($_GET['scope']) || (isset($_POST) && isset($_POST['action']))){
+ $fail = false;
+ try{
+ $request = "";
+ if (is_array($_GET)){
+ foreach($_GET as $key => $arg)
+ $request .= ";$key=$arg";
+ }
+ $options = array(
+ 'http'=>array(
+ 'method'=>"POST",
+ 'header'=>"Accept-language: en\r\n".
+ "Content-type: application/x-www-form-urlencoded\r\n",
+ 'content'=>http_build_query($_POST)
+ ));
+ $context = stream_context_create($options);
+ $response = file_get_contents("http://127.0.0.1:{$pconfig['localstatsport']}/haproxy_stats.php?haproxystats=1".$request, false, $context);
+ if (is_array($http_response_header)){
+ foreach($http_response_header as $header){
+ if (strpos($header,"Refresh: ") == 0)
+ header($header);
+ }
+ }
+ $fail = $response === false;
+ } catch (Exception $e) {
+ $fail = true;
+ }
+ if ($fail)
+ $response = "<br/><br/>Make sure HAProxy settings are applied and HAProxy is enabled and running";
+ echo $response;
+ exit(0);
+}
+require_once("guiconfig.inc");
+if (isset($_GET['showsticktablecontent'])){
+ header("Refresh: 2");
+}
+$shortcut_section = "haproxy";
+require_once("haproxy.inc");
+require_once("certs.inc");
+require_once("haproxy_utils.inc");
+require_once("pkg_haproxy_tabs.inc");
+
+if (!is_array($config['installedpackages']['haproxy']['ha_backends']['item'])) {
+ $config['installedpackages']['haproxy']['ha_backends']['item'] = array();
+}
+$a_frontend = &$config['installedpackages']['haproxy']['ha_backends']['item'];
+
+function haproxy_add_stats_example() {
+ global $config, $d_haproxyconfdirty_path;
+ $a_backends = &$config['installedpackages']['haproxy']['ha_pools']['item'];
+ $a_frontends = &$config['installedpackages']['haproxy']['ha_backends']['item'];
+ $webcert = haproxy_find_create_certificate("HAProxy stats default");
+
+ $backend = array();
+ $backend["name"] = "HAProxy_stats_ssl_backend";
+ $backend["stats_enabled"] = "yes";
+ $backend["stats_uri"] = "/";
+ $backend["stats_refresh"] = "10";
+ $a_backends[] = $backend;
+ $changecount++;
+
+ $frontend = array();
+ $frontend["name"] = "HAProxy_stats_ssl_frontend";
+ $frontend["status"] = "active";
+ $frontend["type"] = "http";
+ $frontend["port"] = "444";
+ $frontend["extaddr"] = "lan_ipv4";
+ $frontend["ssloffload"] = "yes";
+ $frontend["ssloffloadcert"] = $webcert['refid'];
+ $frontend["backend_serverpool"] = $backend["name"];
+ $a_frontends[] = $frontend;
+ $changecount++;
+ $changedesc = "add new HAProxy stats example";
+
+ if ($changecount > 0) {
+ echo "touching: $d_haproxyconfdirty_path";
+ touch($d_haproxyconfdirty_path);
+ write_config($changedesc);
+ }
+}
+
+if (isset($_GET['add_stats_example'])) {
+ haproxy_add_stats_example();
+ write_config();
+ touch($d_haproxyconfdirty_path);
+ header("Location: haproxy_listeners.php");
+ exit;
+}
+
+if ($_POST) {
+ if ($_POST['apply']) {
+ $result = haproxy_check_and_run($savemsg, true);
+ if ($result)
+ unlink_if_exists($d_haproxyconfdirty_path);
+ }
+}
+
+$pfSversion = str_replace("\n", "", file_get_contents("/etc/version"));
+if(strstr($pfSversion, "1.2"))
+ $one_two = true;
+
+$pgtitle = "Services: HAProxy: Stats";
+include("head.inc");
+
+?>
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<form action="haproxy_stats.php" method="post">
+<?php if($one_two): ?>
+<p class="pgtitle"><?=$pgtitle?></p>
+<?php endif; ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+<?php if (file_exists($d_haproxyconfdirty_path)): ?>
+<?php print_info_box_np("The haproxy configuration has been changed.<br/>You must apply the changes in order for them to take effect.");?><br/>
+<?php endif; ?>
+</form>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr><td class="tabnavtbl">
+ <?php
+ haproxy_display_top_tabs_active($haproxy_tab_array['haproxy'], "stats");
+ ?>
+ </td></tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" height="100%" cellspacing="0">
+ <tr>
+ <?
+if (isset($_GET['showsticktablecontent'])){
+ $sticktablename = $_GET['showsticktablecontent'];
+echo "<td colspan='2'>";
+ echo "TESTJe<br/>";
+ $res = haproxy_socket_command("show table $sticktablename");
+ foreach($res as $line){
+ echo "<br/>".print_r($line,true);
+ }
+echo "</td>";
+} else {
+?>
+ <td colspan="2">
+ This page contains a 'stats' page available from haproxy accessible through the pfSense gui.<br/>
+ <br/>
+ As the page is forwarded through the pfSense gui, this might cause some functionality to not work.<br/>
+ Though the normal haproxy stats page can be tweaked more, and doesn't use a user/pass from pfSense itself.<br/>
+ Some examples are configurable automatic page refresh,<br/>
+ only showing certain servers, not providing admin options, and can be accessed from wherever the associated frontend is accessible.(as long as rules permit access)<br/>
+ To use this or for simply an example how to use SSL-offloading configure stats on either a real backend while utilizing the 'stats uri'.
+ Or create a backend specifically for serving stats, for that you can start with the 'stats example' template below.<br/>
+ </td>
+ </tr>
+ <tr>
+ <td>&nbsp;</td>
+ </tr>
+ <tr>
+ <td colspan="2" valign="top" class="listtopic">Stats example template</td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell">Example</td>
+ <td class="vtable">
+ As an basic example you can use the link below to create a 'stats' frontend/backend page which offers with more options like setting user/password and 'admin mode' when you go to the backend settings.<br/>
+ <a href="haproxy_stats.php?add_stats_example=1">TEMPLATE: Create stats example configuration using a frontend/backend combination with ssl</a><br/>
+ <br/>
+ After applying the changes made by the template use this link to visit the stats page: <a target="_blank" href="https://<?=get_interface_ip("lan");?>:444">https://pfSense-LAN-ip:444/</a>
+ </td>
+ </tr>
+ <tr>
+ <td>&nbsp;</td>
+ </tr>
+ <tr>
+ <td colspan="2" valign="top" class="listtopic">HAProxy stick-tables</td>
+ </tr>
+ <tr>
+ <td colspan="2" valign="top" class="vncell">
+ These tables are used to store information for session persistence and can be used with ssl-session-id information, application-cookies, or other information that is used to persist a user to a server.
+ <table class="tabcont sortable" id="sortabletable" width="100%" cellspacing="0" cellpadding="6" border="0">
+ <head>
+ <td class="listhdrr">Stick-table</td>
+ <td class="listhdrr">Type</td>
+ <td class="listhdrr">Size</td>
+ <td class="listhdrr">Used</td>
+ </head>
+ <? $tables = haproxy_get_tables();
+ foreach($tables as $key => $table) { ?>
+ <tr>
+ <td class="listlr"><a href="/haproxy_stats.php?showsticktablecontent=<?=$key;?>"><?=$key;?></td>
+ <td class="listr"><?=$table['type'];?></td>
+ <td class="listr"><?=$table['size'];?></td>
+ <td class="listr"><?=$table['used'];?></td>
+ </tr>
+ <? } ?>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>&nbsp;</td>
+ </tr>
+ <tr>
+ <td colspan="2" valign="top" class="listtopic">HAProxy stats</td>
+ </tr>
+ <tr>
+ <td colspan="2" valign="top" class="vncell"><a href="/haproxy_stats.php?haproxystats=1" target="_blank">Fullscreen stats page</a></td>
+ </tr>
+ <tr>
+ <td colspan="2" class="listlr">
+ <? if (isset($pconfig['enable']) && $pconfig['localstatsport'] && is_numeric($pconfig['localstatsport'])){?>
+ <iframe id="frame_haproxy_stats" width="1000px" height="1500px" seamless=1 src="/haproxy_stats.php?haproxystats=1<?=$request;?>"></iframe>
+ <? } else { ?>
+ <br/>
+ In the "Settings" configure a internal stats port and enable haproxy for this to be functional.<br/>
+ <br/>
+ <? } ?>
+<?}?>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+</table>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/config/haproxy-devel/pkg_haproxy_tabs.inc b/config/haproxy-devel/pkg_haproxy_tabs.inc
new file mode 100644
index 00000000..8cb280f8
--- /dev/null
+++ b/config/haproxy-devel/pkg_haproxy_tabs.inc
@@ -0,0 +1,25 @@
+<?php
+
+//require_once("guiconfig.inc"); DO NOT REQUIRE THIS!
+
+// DO NOT REQUIRE guiconfig.inc HERE! though it contains the function display_top_tabs needed below.
+// however if included it will hang filter rule generation, and might cause pf to not load any rules.
+// This happens when /usr/local/pkg/*.inc files are dynamically loaded during package generation from filter.inc with function discover_pkg_rules(x).
+
+global $haproxy_tab_array;
+
+$haproxy_tab_array['haproxy'] = array();
+$haproxy_tab_array['haproxy']['settings'] = Array(name => "Settings", url => "haproxy_global.php");
+$haproxy_tab_array['haproxy']['frontend'] = Array(name => "Frontend", url => "haproxy_listeners.php");
+$haproxy_tab_array['haproxy']['backend'] = Array(name => "Backend", url => "haproxy_pools.php");
+$haproxy_tab_array['haproxy']['stats'] = Array(name => "Stats", url => "haproxy_stats.php");
+
+function haproxy_display_top_tabs_active($top_tabs, $activetab) {
+ $tab_array = array();
+ foreach($top_tabs as $key => $tab_item){
+ $tab_array[] = array($tab_item['name'], $key == $activetab, $tab_item['url']);
+ }
+ display_top_tabs($tab_array);
+}
+
+?>