aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorChris Buechler <cmb@pfsense.org>2015-08-16 00:02:14 -0500
committerChris Buechler <cmb@pfsense.org>2015-08-16 00:02:14 -0500
commit5ed85bcbc0ee4a8c89b172dd1fc1c94b2cee1a3b (patch)
treee45c502d4f10e5cbd5f23ff272993c252627737b /config
parentd6d3aab86ad471c15d0f7cf42e6dafb801308f82 (diff)
parent5787201dd1be07fab90d172ea8a63ab4d4ed3d4c (diff)
downloadpfsense-packages-5ed85bcbc0ee4a8c89b172dd1fc1c94b2cee1a3b.tar.gz
pfsense-packages-5ed85bcbc0ee4a8c89b172dd1fc1c94b2cee1a3b.tar.bz2
pfsense-packages-5ed85bcbc0ee4a8c89b172dd1fc1c94b2cee1a3b.zip
Merge pull request #999 from doktornotor/patch-13
Diffstat (limited to 'config')
-rw-r--r--config/lcdproc-dev/lcdproc.inc1005
-rw-r--r--config/lcdproc-dev/lcdproc.xml197
-rw-r--r--config/lcdproc-dev/lcdproc_client.php1685
-rw-r--r--config/lcdproc-dev/lcdproc_screens.xml56
4 files changed, 1532 insertions, 1411 deletions
diff --git a/config/lcdproc-dev/lcdproc.inc b/config/lcdproc-dev/lcdproc.inc
index 95561fb6..e9656afd 100644
--- a/config/lcdproc-dev/lcdproc.inc
+++ b/config/lcdproc-dev/lcdproc.inc
@@ -1,309 +1,318 @@
<?php
-/* $Id$ */
/*
- lcdproc.inc
- Copyright (C) 2007 Seth Mos <seth.mos@xs4all.nl>,
- Copyright (C) 2012 Michele Di Maria <michele@nt2.it>
- All rights reserved.
+ lcdproc.inc
+ part of pfSense (https://www.pfSense.org/)
+ Copyright (C) 2007-2009 Seth Mos <seth.mos@dds.nl>
+ Copyright (C) 2009 Scott Ullrich
+ Copyright (C) 2012 Michele Di Maria
+ Copyright (C) 2015 ESF, LLC
+ All rights reserved.
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
+ 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.
+ 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.
+ 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.
+ 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("config.inc");
- require_once("functions.inc");
- require_once("service-utils.inc");
- /* LCDproc */
- define('LCDPROC_RCFILE', '/usr/local/etc/rc.d/lcdproc.sh');
- $pfs_version = substr(trim(file_get_contents("/etc/version")),0,3);
- if ($pfs_version == "2.1" || $pfs_version == "2.2") {
- define('LCDPROC_CONFIG', '/usr/pbi/lcdproc-' . php_uname('m') . '/local/etc/LCDd.conf');
- } else {
- define('LCDPROC_CONFIG','/usr/local/etc/LCDd.conf');
- }
- define('LCDPROC_HOST','127.0.0.1');
- define('LCDPROC_PORT','13666');
- define('LCDPROC_SERVICE_NAME','lcdproc');
- /* Functions */
- function lcdproc_notice ($msg) { syslog(LOG_NOTICE, "lcdproc: {$msg}"); }
- function lcdproc_warn ($msg) { syslog(LOG_WARNING, "lcdproc: {$msg}"); }
- function lcdproc_write_config($file, $text) {
- $handle = fopen($file, 'w');
- if(!$handle) {
- lcdproc_warn("Could not open {$file} for writing.");
- exit;
- }
- fwrite($handle, $text);
- fclose($handle);
+require_once("config.inc");
+require_once("functions.inc");
+require_once("service-utils.inc");
+
+/* LCDproc */
+define('LCDPROC_RCFILE', '/usr/local/etc/rc.d/lcdproc.sh');
+$pfs_version = substr(trim(file_get_contents("/etc/version")), 0, 3);
+if ($pfs_version == "2.1" || $pfs_version == "2.2") {
+ define('LCDPROC_CONFIG', '/usr/pbi/lcdproc-' . php_uname('m') . '/local/etc/LCDd.conf');
+} else {
+ define('LCDPROC_CONFIG', '/usr/local/etc/LCDd.conf');
+}
+define('LCDPROC_HOST', '127.0.0.1');
+define('LCDPROC_PORT', '13666');
+define('LCDPROC_SERVICE_NAME', 'lcdproc');
+
+/* Functions */
+function lcdproc_notice($msg) {
+ syslog(LOG_NOTICE, "lcdproc: {$msg}");
+}
+
+function lcdproc_warn($msg) {
+ syslog(LOG_WARNING, "lcdproc: {$msg}");
+}
+
+function lcdproc_write_config($file, $text) {
+ $handle = fopen($file, 'w');
+ if (!$handle) {
+ lcdproc_warn("Could not open {$file} for writing.");
+ exit;
}
- function lcdproc_write_script($file, $text) {
- $handle = fopen($file, 'wx');
- if(!$handle) {
- lcdproc_warn("Could not open {$file} for writing.");
- exit;
- }
- fwrite($handle, $text);
- fclose($handle);
- chmod($file, 0755);
+ fwrite($handle, $text);
+ fclose($handle);
+}
+
+function lcdproc_write_script($file, $text) {
+ $handle = fopen($file, 'wx');
+ if (!$handle) {
+ lcdproc_warn("Could not open {$file} for writing.");
+ exit;
}
- function validate_form_lcdproc($post, &$input_errors) {
- if($post['comport']) {
- switch($post['comport']) {
- case "none":
- case "com1":
- case "com2":
- case "com1a":
- case "com2a":
- case "ucom1":
- case "ucom2":
- case "lpt1":
- case "ugen0.2":
- case "ugen1.2":
- case "ugen1.3";
- case "ugen2.2":
- continue;
- break;
- default:
- $input_errors[] = "The chosen com port is not valid";
- break;
+ fwrite($handle, $text);
+ fclose($handle);
+ chmod($file, 0755);
+}
+
+function validate_form_lcdproc($post, &$input_errors) {
+ if ($post['comport']) {
+ switch($post['comport']) {
+ case "none":
+ case "com1":
+ case "com2":
+ case "com1a":
+ case "com2a":
+ case "ucom1":
+ case "ucom2":
+ case "lpt1":
+ case "ugen0.2":
+ case "ugen1.2":
+ case "ugen1.3";
+ case "ugen2.2":
+ continue;
+ break;
+ default:
+ $input_errors[] = "The chosen COM port is not valid";
+ break;
}
}
- if($post['size']) {
- switch($post['size']) {
- case "12x1":
- case "12x2":
- case "12x4":
- case "16x1":
- case "16x2":
- case "16x4":
- case "20x1":
- case "20x2":
- case "20x4":
- case "40x2":
- continue;
- break;
- default:
- $input_errors[] = "The chosen display size is not valid";
- break;
- }
+ if ($post['size']) {
+ switch($post['size']) {
+ case "12x1":
+ case "12x2":
+ case "12x4":
+ case "16x1":
+ case "16x2":
+ case "16x4":
+ case "20x1":
+ case "20x2":
+ case "20x4":
+ case "40x2":
+ continue;
+ break;
+ default:
+ $input_errors[] = "The chosen display size is not valid";
+ break;
+ }
+ }
+ if ($post['port_speed']) {
+ switch($post['port_speed']) {
+ case "0":
+ case "1200":
+ case "2400":
+ case "9600":
+ case "19200":
+ case "57600":
+ case "115200":
+ continue;
+ break;
+ default:
+ $input_errors[] = "The chosen port speed is not valid";
+ break;
}
- if($post['port_speed']) {
- switch($post['port_speed']) {
- case "0":
- case "1200":
- case "2400":
- case "9600":
- case "19200":
- case "57600":
- case "115200":
- continue;
- break;
- default:
- $input_errors[] = "The chosen port speed is not valid";
- break;
- }
- }
}
- function validate_form_lcdproc_screens($post, &$input_errors) {
- // No validation required ?!
+}
+
+function sync_package_lcdproc_screens() {
+ sync_package_lcdproc();
+}
+
+function sync_package_lcdproc() {
+ global $g;
+ global $config;
+ global $input_errors;
+
+ # Detect boot process
+ if (platform_booting()) {
+ return;
}
- function sync_package_lcdproc_screens() {
- sync_package_lcdproc();
- }
- function sync_package_lcdproc() {
- global $g;
- global $config;
- global $input_errors;
- # detect boot process
- if (is_array($_POST)){
- if (! preg_match("/\w+/",$_POST['__csrf_magic']))
+ # Continue sync package
+ lcdproc_notice("Sync: Begin package sync");
+ $lcdproc_config = $config['installedpackages']['lcdproc']['config'][0];
+ $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0];
+
+ /* Since config is written before this file invoked, we don't need to read post data */
+ if ($lcdproc_config['enable'] && ($lcdproc_config['comport'] != "none")) {
+ switch ($lcdproc_config['comport']) {
+ case "com1":
+ $realport = "/dev/cua0";
+ break;
+ case "com2":
+ $realport = "/dev/cua1";
+ break;
+ case "com1a":
+ $realport = "/dev/cuau0";
+ break;
+ case "com2a":
+ $realport = "/dev/cuau1";
+ break;
+ case "ucom1":
+ $realport = "/dev/cuaU0";
+ break;
+ case "ucom2":
+ $realport = "/dev/cuaU1";
+ break;
+ case "lpt1":
+ $realport = "/dev/lpt0";
+ break;
+ case "ugen0.2":
+ $realport = "/dev/ugen0.2";
+ break;
+ case "ugen1.2":
+ $realport = "/dev/ugen1.2";
+ break;
+ case "ugen1.3":
+ $realport = "/dev/ugen1.3";
+ break;
+ case "ugen2.2":
+ $realport = "/dev/ugen2.2";
+ break;
+ default:
+ lcdproc_warn("The selected COM port is not valid!");
return;
- }
+ }
- #continue sync package
- lcdproc_notice("Sync: Begin package sync");
- $lcdproc_config = $config['installedpackages']['lcdproc']['config'][0];
- $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0];
- /* since config is written before this file invoked we don't need to read post data */
- if($lcdproc_config['enable'] && ($lcdproc_config['comport'] != "none")) {
- switch($lcdproc_config['comport']) {
- case "com1":
- $realport = "/dev/cua0";
- break;
- case "com2":
- $realport = "/dev/cua1";
- break;
- case "com1a":
- $realport = "/dev/cuau0";
- break;
- case "com2a":
- $realport = "/dev/cuau1";
- break;
- case "ucom1":
- $realport = "/dev/cuaU0";
- break;
- case "ucom2":
- $realport = "/dev/cuaU1";
- break;
- case "lpt1":
- $realport = "/dev/lpt0";
- break;
- case "ugen0.2":
- $realport = "/dev/ugen0.2";
- break;
- case "ugen1.2":
- $realport = "/dev/ugen1.2";
- break;
- case "ugen1.3":
- $realport = "/dev/ugen1.3";
- break;
- case "ugen2.2":
- $realport = "/dev/ugen2.2";
- break;
- default:
- lcdproc_warn("The selected com port is not valid!");
- return;
- }
- $config_text = "[server]\n";
- $config_text .= "DriverPath=/usr/local/lib/lcdproc/\n";
- $config_text .= "Driver={$lcdproc_config[driver]}\n";
- $config_text .= "Bind=127.0.0.1\n";
- $config_text .= "Port=13666\n";
- $config_text .= "ReportLevel=3\n";
- $config_text .= "ReportToSyslog=yes\n";
- $config_text .= "User=nobody\n";
- $config_text .= "Foreground=no\n";
- $config_text .= "ServerScreen=no\n";
- $config_text .= "GoodBye=\"Thanks for using\"\n";
- $config_text .= "GoodBye=\" {$g['product_name']} \"\n";
- $config_text .= "WaitTime={$lcdproc_config[refresh_frequency]}\n";
- if ($lcdproc_config[backlight] != "" && $lcdproc_config[backlight] != "default")
- {
- /* Backlight setting */
- $config_text .= "Backlight={$lcdproc_config[backlight]}\n";
- }
- if ($lcdproc_config[driver] == "sdeclcd")
- {
- /* Sdeclcd Keys settings */
- $config_text .= "PrevScreenKey=Down\n";
- $config_text .= "NextScreenKey=Up\n";
- /* Sdeclcd Menu settings */
- $config_text .= "[menu]\n";
- $config_text .= "MenuKey=Left\n";
- $config_text .= "EnterKey=Right\n";
- $config_text .= "UpKey=Up\n";
- $config_text .= "DownKey=Down\n";
- }
- else
- {
- /* Generic Keys settings */
- $config_text .= "ToggleRotateKey=Enter\n";
- $config_text .= "PrevScreenKey=Left\n";
- $config_text .= "NextScreenKey=Right\n";
- $config_text .= "ScrollUpKey=Up\n";
- $config_text .= "ScrollDownKey=Down\n";
- /* Generic Menu settings */
- $config_text .= "[menu]\n";
- $config_text .= "MenuKey=Escape\n";
- $config_text .= "EnterKey=Enter\n";
- $config_text .= "UpKey=Up\n";
- $config_text .= "DownKey=Down\n";
- }
- /* lcdproc default driver definitions */
- switch($lcdproc_config[driver]) {
- case "bayrad":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "Device={$realport}\n";
- break;
- case "CFontz":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "Device={$realport}\n";
- $config_text .= "Size={$lcdproc_config['size']}\n";
- $config_text .= set_lcd_value("contrast", 1000, 350);
- $config_text .= set_lcd_value("brightness", 1000, 1000);
- $config_text .= set_lcd_value("offbrightness", 1000, 50);
- $config_text .= "NewFirmware=no\n";
- $config_text .= "Reboot=no\n";
- break;
- case "CFontz633":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "Device={$realport}\n";
- $config_text .= "Size={$lcdproc_config['size']}\n";
- $config_text .= set_lcd_value("contrast", 1000, 350);
- $config_text .= set_lcd_value("brightness", 1000, 1000);
- $config_text .= set_lcd_value("offbrightness", 1000, 50);
- $config_text .= "NewFirmware=yes\n";
- $config_text .= "Reboot=yes\n";
- break;
- case "CFontzPacket":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "Device={$realport}\n";
- $config_text .= "Model=635\n";
- $config_text .= "Size={$lcdproc_config['size']}\n";
- $config_text .= set_lcd_value("contrast", 1000, 350);
- $config_text .= set_lcd_value("brightness", 1000, 1000);
- $config_text .= set_lcd_value("offbrightness", 1000, 50);
- $config_text .= "NewFirmware=yes\n";
- $config_text .= "Reboot=yes\n";
- break;
- case "curses":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "Foreground=blue\n";
- $config_text .= "Background=cyan\n";
- $config_text .= "Backlight=red\n";
- $config_text .= "Size={$lcdproc_config['size']}\n";
- $config_text .= "TopLeftX=7\n";
- $config_text .= "TopLeftY=7\n";
- $config_text .= "UseACS=no\n";
- break;
- case "CwLnx":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "Model=12232\n";
- $config_text .= "Device={$realport}\n";
- $config_text .= "Size={$lcdproc_config['size']}\n";
- $config_text .= "Reboot=no\n";
- break;
- case "ea65":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "Device={$realport}\n";
- $config_text .= "OffBrightness=0\n";
- $config_text .= set_lcd_value("brightness", 1000, 500);
- break;
- case "EyeboxOne":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "Device={$realport}\n";
- $config_text .= "Backlight=yes\n";
- break;
- case "glk":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text = "[server]\n";
+ $config_text .= "DriverPath=/usr/local/lib/lcdproc/\n";
+ $config_text .= "Driver={$lcdproc_config[driver]}\n";
+ $config_text .= "Bind=127.0.0.1\n";
+ $config_text .= "Port=13666\n";
+ $config_text .= "ReportLevel=3\n";
+ $config_text .= "ReportToSyslog=yes\n";
+ $config_text .= "User=nobody\n";
+ $config_text .= "Foreground=no\n";
+ $config_text .= "ServerScreen=no\n";
+ $config_text .= "GoodBye=\"Thanks for using\"\n";
+ $config_text .= "GoodBye=\" {$g['product_name']} \"\n";
+ $config_text .= "WaitTime={$lcdproc_config[refresh_frequency]}\n";
+ if ($lcdproc_config[backlight] != "" && $lcdproc_config[backlight] != "default") {
+ /* Backlight setting */
+ $config_text .= "Backlight={$lcdproc_config[backlight]}\n";
+ }
+ if ($lcdproc_config[driver] == "sdeclcd") {
+ /* Sdeclcd Keys settings */
+ $config_text .= "PrevScreenKey=Down\n";
+ $config_text .= "NextScreenKey=Up\n";
+ /* Sdeclcd Menu settings */
+ $config_text .= "[menu]\n";
+ $config_text .= "MenuKey=Left\n";
+ $config_text .= "EnterKey=Right\n";
+ $config_text .= "UpKey=Up\n";
+ $config_text .= "DownKey=Down\n";
+ } else {
+ /* Generic Keys settings */
+ $config_text .= "ToggleRotateKey=Enter\n";
+ $config_text .= "PrevScreenKey=Left\n";
+ $config_text .= "NextScreenKey=Right\n";
+ $config_text .= "ScrollUpKey=Up\n";
+ $config_text .= "ScrollDownKey=Down\n";
+ /* Generic Menu settings */
+ $config_text .= "[menu]\n";
+ $config_text .= "MenuKey=Escape\n";
+ $config_text .= "EnterKey=Enter\n";
+ $config_text .= "UpKey=Up\n";
+ $config_text .= "DownKey=Down\n";
+ }
+
+ /* lcdproc default driver definitions */
+ switch($lcdproc_config[driver]) {
+ case "bayrad":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Device={$realport}\n";
+ break;
+ case "CFontz":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= "Size={$lcdproc_config['size']}\n";
+ $config_text .= set_lcd_value("contrast", 1000, 350);
+ $config_text .= set_lcd_value("brightness", 1000, 1000);
+ $config_text .= set_lcd_value("offbrightness", 1000, 50);
+ $config_text .= "NewFirmware=no\n";
+ $config_text .= "Reboot=no\n";
+ break;
+ case "CFontz633":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= "Size={$lcdproc_config['size']}\n";
+ $config_text .= set_lcd_value("contrast", 1000, 350);
+ $config_text .= set_lcd_value("brightness", 1000, 1000);
+ $config_text .= set_lcd_value("offbrightness", 1000, 50);
+ $config_text .= "NewFirmware=yes\n";
+ $config_text .= "Reboot=yes\n";
+ break;
+ case "CFontzPacket":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= "Model=635\n";
+ $config_text .= "Size={$lcdproc_config['size']}\n";
+ $config_text .= set_lcd_value("contrast", 1000, 350);
+ $config_text .= set_lcd_value("brightness", 1000, 1000);
+ $config_text .= set_lcd_value("offbrightness", 1000, 50);
+ $config_text .= "NewFirmware=yes\n";
+ $config_text .= "Reboot=yes\n";
+ break;
+ case "curses":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Foreground=blue\n";
+ $config_text .= "Background=cyan\n";
+ $config_text .= "Backlight=red\n";
+ $config_text .= "Size={$lcdproc_config['size']}\n";
+ $config_text .= "TopLeftX=7\n";
+ $config_text .= "TopLeftY=7\n";
+ $config_text .= "UseACS=no\n";
+ break;
+ case "CwLnx":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Model=12232\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= "Size={$lcdproc_config['size']}\n";
+ $config_text .= "Reboot=no\n";
+ break;
+ case "ea65":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= "OffBrightness=0\n";
+ $config_text .= set_lcd_value("brightness", 1000, 500);
+ break;
+ case "EyeboxOne":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= "Backlight=yes\n";
+ break;
+ case "glk":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= set_lcd_value("contrast", 1000, 350);
+ break;
+ case "hd44780":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "driverpath=/usr/local/lib/lcdproc/\n";
+ $config_text .= "ConnectionType={$lcdproc_config['connection_type']}\n";
+ if ($lcdproc_config['comport'] != "none") {
$config_text .= "Device={$realport}\n";
- $config_text .= set_lcd_value("contrast", 1000, 350);
- break;
- case "hd44780":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "driverpath=/usr/local/lib/lcdproc/\n";
- $config_text .= "ConnectionType={$lcdproc_config['connection_type']}\n";
- if($lcdproc_config['comport'] != "none")
- $config_text .= "Device={$realport}\n";
- $config_text .= "Port=0x378\n";
+ $config_text .= "Port=0x378\n";
$config_text .= "Speed=0\n";
$config_text .= "Keypad=yes\n";
$config_text .= set_lcd_value("contrast", 1000, 850);
@@ -315,159 +324,158 @@
$config_text .= "DelayMult=1\n";
$config_text .= "DelayBus=true\n";
$config_text .= "Size={$lcdproc_config['size']}\n";
- if ($lcdproc_config[connection_type] == "winamp")
- {
- $config_text .= "KeyDirect_1=Enter\n";
- $config_text .= "KeyDirect_2=Up\n";
- $config_text .= "KeyDirect_3=Down\n";
- $config_text .= "KeyDirect_4=Escape\n";
- }
- else
- {
- }
- break;
- case "icp_a106":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "Device={$realport}\n";
- break;
- case "IOWarrior":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "Size={$lcdproc_config['size']}\n";
- break;
- case "lb216":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "Device={$realport}\n";
- $config_text .= set_lcd_value("brightness", 255, 255);
- $config_text .= "Reboot=no\n";
- break;
- case "lcdm001":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "Device={$realport}\n";
- break;
- case "lcterm":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "Device={$realport}\n";
- $config_text .= "Size={$lcdproc_config['size']}\n";
- break;
- case "MD8800":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "Device={$realport}\n";
- $config_text .= "Size={$lcdproc_config['size']}\n";
- $config_text .= set_lcd_value("brightness", 1000, 1000);
- $config_text .= set_lcd_value("offbrightness", 1000, 0);
- break;
- case "ms6931":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "Device={$realport}\n";
- $config_text .= "Reboot=no\n";
- break;
- case "mtc_s16209x":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "Device={$realport}\n";
- $config_text .= set_lcd_value("brightness", 255, 255);
- $config_text .= "Reboot=no\n";
- break;
- case "MtxOrb":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "Device={$realport}\n";
- $config_text .= "Size={$lcdproc_config['size']}\n";
- $config_text .= "Type=lcd\n";
- $config_text .= "hasAdjustableBacklight=yes\n";
- $config_text .= "Reboot=no\n";
- $config_text .= set_lcd_value("contrast", 1000, 480);
- $config_text .= set_lcd_value("brightness", 1000, 1000);
- $config_text .= set_lcd_value("offbrightness", 1000, 0);
- break;
- case "nexcom":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "driverpath =/usr/local/lib/lcdproc/\n";
- $config_text .= "Device={$realport}\n";
- $config_text .= "Size={$lcdproc_config['size']}\n";
- break;
- case "NoritakeVFD":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "Device={$realport}\n";
- $config_text .= "Size={$lcdproc_config['size']}\n";
- $config_text .= set_lcd_value("brightness", 1000, 1000);
- $config_text .= set_lcd_value("offbrightness", 1000, 0);
- $config_text .= "Parity=0\n";
- $config_text .= "Reboot=no\n";
- break;
- case "picolcd":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "driverpath=/usr/local/lib/lcdproc/\n";
- $config_text .= "Device={$realport}\n";
- $config_text .= "Size={$lcdproc_config['size']}\n";
- $config_text .= "KeyTimeout=500\n";
- $config_text .= set_lcd_value("contrast", 1000, 1000);
- $config_text .= set_lcd_value("brightness", 1000, 1000);
- $config_text .= set_lcd_value("offbrightness", 1000, 0);
- $config_text .= "Blacklight_Timer=60\n";
- $config_text .= "Keylights=on\n";
- $config_text .= "Key0Light=on\n";
- $config_text .= "Key1Light=off\n";
- $config_text .= "Key2Light=off\n";
- $config_text .= "Key3Light=off\n";
- $config_text .= "Key4Light=off\n";
- $config_text .= "Key5Light=off\n";
- break;
- case "pyramid":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "Device={$realport}\n";
- $config_text .= "Size={$lcdproc_config['size']}\n";
- break;
- case "sdeclcd":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- break;
- case "sed1330":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- break;
- case "sed1520":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- break;
- case "serialPOS":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "Device={$realport}\n";
- $config_text .= "Size={$lcdproc_config['size']}\n";
- $config_text .= "Type=AEDEX\n";
- break;
- case "serialVFD":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "use_parallel=no\n";
- $config_text .= "Device={$realport}\n";
- $config_text .= "Size={$lcdproc_config['size']}\n";
- $config_text .= "Type=0\n"; //Just the first
- $config_text .= set_lcd_value("brightness", 1000, 1000);
- $config_text .= set_lcd_value("offbrightness", 1000, 0);
- $config_text .= "ISO_8859_1=yes\n";
- break;
- case "shuttleVFD":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- break;
- case "SureElec":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "driverpath =/usr/local/lib/lcdproc/\n";
- $config_text .= "Device={$realport}\n";
- $config_text .= "Size={$lcdproc_config['size']}\n";
- $config_text .= "Edition=2\n";
- $config_text .= set_lcd_value("contrast", 1000, 200);
- $config_text .= set_lcd_value("brightness", 1000, 480);
- break;
- case "sli":
- $config_text .= "[{$lcdproc_config['driver']}]\n";
- $config_text .= "Device={$realport}\n";
- break;
- default:
- lcdproc_warn("The chosen lcdproc driver is not a valid choice");
- unset($lcdproc_config[driver]);
- }
- /* Port speed */
- if ($lcdproc_config[port_speed] <> '' && $lcdproc_config[port_speed] <> '0') {
- $port_speed = $lcdproc_config[port_speed];
- $config_text .= "Speed={$port_speed}\n";
- }
- /* generate rc file start and stop */
- $stop = <<<EOD
+ }
+ if ($lcdproc_config[connection_type] == "winamp") {
+ $config_text .= "KeyDirect_1=Enter\n";
+ $config_text .= "KeyDirect_2=Up\n";
+ $config_text .= "KeyDirect_3=Down\n";
+ $config_text .= "KeyDirect_4=Escape\n";
+ }
+ break;
+ case "icp_a106":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Device={$realport}\n";
+ break;
+ case "IOWarrior":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Size={$lcdproc_config['size']}\n";
+ break;
+ case "lb216":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= set_lcd_value("brightness", 255, 255);
+ $config_text .= "Reboot=no\n";
+ break;
+ case "lcdm001":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Device={$realport}\n";
+ break;
+ case "lcterm":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= "Size={$lcdproc_config['size']}\n";
+ break;
+ case "MD8800":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= "Size={$lcdproc_config['size']}\n";
+ $config_text .= set_lcd_value("brightness", 1000, 1000);
+ $config_text .= set_lcd_value("offbrightness", 1000, 0);
+ break;
+ case "ms6931":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= "Reboot=no\n";
+ break;
+ case "mtc_s16209x":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= set_lcd_value("brightness", 255, 255);
+ $config_text .= "Reboot=no\n";
+ break;
+ case "MtxOrb":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= "Size={$lcdproc_config['size']}\n";
+ $config_text .= "Type=lcd\n";
+ $config_text .= "hasAdjustableBacklight=yes\n";
+ $config_text .= "Reboot=no\n";
+ $config_text .= set_lcd_value("contrast", 1000, 480);
+ $config_text .= set_lcd_value("brightness", 1000, 1000);
+ $config_text .= set_lcd_value("offbrightness", 1000, 0);
+ break;
+ case "nexcom":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "driverpath =/usr/local/lib/lcdproc/\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= "Size={$lcdproc_config['size']}\n";
+ break;
+ case "NoritakeVFD":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= "Size={$lcdproc_config['size']}\n";
+ $config_text .= set_lcd_value("brightness", 1000, 1000);
+ $config_text .= set_lcd_value("offbrightness", 1000, 0);
+ $config_text .= "Parity=0\n";
+ $config_text .= "Reboot=no\n";
+ break;
+ case "picolcd":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "driverpath=/usr/local/lib/lcdproc/\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= "Size={$lcdproc_config['size']}\n";
+ $config_text .= "KeyTimeout=500\n";
+ $config_text .= set_lcd_value("contrast", 1000, 1000);
+ $config_text .= set_lcd_value("brightness", 1000, 1000);
+ $config_text .= set_lcd_value("offbrightness", 1000, 0);
+ $config_text .= "Blacklight_Timer=60\n";
+ $config_text .= "Keylights=on\n";
+ $config_text .= "Key0Light=on\n";
+ $config_text .= "Key1Light=off\n";
+ $config_text .= "Key2Light=off\n";
+ $config_text .= "Key3Light=off\n";
+ $config_text .= "Key4Light=off\n";
+ $config_text .= "Key5Light=off\n";
+ break;
+ case "pyramid":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= "Size={$lcdproc_config['size']}\n";
+ break;
+ case "sdeclcd":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ break;
+ case "sed1330":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ break;
+ case "sed1520":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ break;
+ case "serialPOS":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= "Size={$lcdproc_config['size']}\n";
+ $config_text .= "Type=AEDEX\n";
+ break;
+ case "serialVFD":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "use_parallel=no\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= "Size={$lcdproc_config['size']}\n";
+ $config_text .= "Type=0\n"; // Just the first
+ $config_text .= set_lcd_value("brightness", 1000, 1000);
+ $config_text .= set_lcd_value("offbrightness", 1000, 0);
+ $config_text .= "ISO_8859_1=yes\n";
+ break;
+ case "shuttleVFD":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ break;
+ case "SureElec":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "driverpath =/usr/local/lib/lcdproc/\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= "Size={$lcdproc_config['size']}\n";
+ $config_text .= "Edition=2\n";
+ $config_text .= set_lcd_value("contrast", 1000, 200);
+ $config_text .= set_lcd_value("brightness", 1000, 480);
+ break;
+ case "sli":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Device={$realport}\n";
+ break;
+ default:
+ lcdproc_warn("The chosen lcdproc driver is not a valid choice");
+ unset($lcdproc_config[driver]);
+ }
+
+ /* Port speed */
+ if ($lcdproc_config[port_speed] <> '' && $lcdproc_config[port_speed] <> '0') {
+ $port_speed = $lcdproc_config[port_speed];
+ $config_text .= "Speed={$port_speed}\n";
+ }
+
+ /* Generate rc file start and stop */
+ $stop = <<<EOD
if [ `pgrep -f lcdproc_client.ph` ];then
pkill -f lcdproc_client.ph
sleep 1
@@ -478,66 +486,67 @@ if [ `pgrep -anx LCDd` ]; then
fi
EOD;
- $start = $stop ."\n";
- $start .= "\t/usr/bin/nice -20 /usr/local/sbin/LCDd -c ". LCDPROC_CONFIG ." -u nobody\n";
- $start .= "\t/usr/bin/nice -20 /usr/local/bin/php -f /usr/local/pkg/lcdproc_client.php &\n";
- /* write out the configuration */
- conf_mount_rw();
- lcdproc_write_config(LCDPROC_CONFIG, $config_text);
- write_rcfile(array(
- 'file' => 'lcdproc.sh',
- 'start' => $start,
- 'stop' => $stop
- ));
- conf_mount_ro();
- /* or restart lcdproc if settings were changed*/
- if(is_service_running(LCDPROC_SERVICE_NAME)) {
- lcdproc_notice("Sync: Restarting the service");
- restart_service(LCDPROC_SERVICE_NAME);
- }
+ $start = $stop ."\n";
+ $start .= "\t/usr/bin/nice -20 /usr/local/sbin/LCDd -c ". LCDPROC_CONFIG ." -u nobody\n";
+ $start .= "\t/usr/bin/nice -20 /usr/local/bin/php -f /usr/local/pkg/lcdproc_client.php &\n";
+
+ /* Write out the configuration */
+ conf_mount_rw();
+ lcdproc_write_config(LCDPROC_CONFIG, $config_text);
+ write_rcfile(array(
+ 'file' => 'lcdproc.sh',
+ 'start' => $start,
+ 'stop' => $stop
+ ));
+ conf_mount_ro();
+ /* Or restart lcdproc if settings were changed*/
+ if (is_service_running(LCDPROC_SERVICE_NAME)) {
+ lcdproc_notice("Sync: Restarting the service");
+ restart_service(LCDPROC_SERVICE_NAME);
}
- if((! $lcdproc_config['driver']) || (! $lcdproc_config['comport'])) {
- /* no parameters user does not want lcdproc running */
- /* lets stop the service and remove the rc file */
- if(file_exists(LCDPROC_RCFILE)) {
- if(!$lcdproc_config['enable']) {
- lcdproc_notice('Stopping service: lcdproc disabled');
- } else {
- lcdproc_notice('Stopping service: no com port selected');
- }
- stop_service(LCDPROC_SERVICE_NAME);
- conf_mount_rw();
- unlink(LCDPROC_RCFILE);
- unlink(LCDPROC_CONFIG);
- conf_mount_ro();
+ }
+
+ if ((!$lcdproc_config['driver']) || (!$lcdproc_config['comport'])) {
+ /* No parameters - user does not want lcdproc running */
+ /* Let's stop the service and remove the rc file */
+ if (file_exists(LCDPROC_RCFILE)) {
+ if (!$lcdproc_config['enable']) {
+ lcdproc_notice('Stopping service: lcdproc disabled');
+ } else {
+ lcdproc_notice('Stopping service: no COM port selected');
}
+ stop_service(LCDPROC_SERVICE_NAME);
+ conf_mount_rw();
+ unlink(LCDPROC_RCFILE);
+ unlink(LCDPROC_CONFIG);
+ conf_mount_ro();
}
- lcdproc_notice("Sync: End package sync");
}
- function set_lcd_value($fieldname, $max, $default_value) {
- global $config;
- $lcdproc_config = $config['installedpackages']['lcdproc']['config'][0];
- $value = $lcdproc_config[$fieldname];
- $returnvalue = "";
- if ($value != '' && $value != '-1') {
- $realvalue = (int)($max * $value / 100);
- }
- else
- {
- $realvalue = $default_value;
- }
- switch ($fieldname)
- {
- case "brightness":
- $returnvalue = "Brightness={$realvalue}\n";
- break;
- case "offbrightness":
- $returnvalue = "OffBrightness={$realvalue}\n";
- break;
- case "contrast":
- $returnvalue = "Contrast={$realvalue}\n";
- break;
- }
- return $returnvalue;
+ lcdproc_notice("Sync: End package sync");
+}
+
+function set_lcd_value($fieldname, $max, $default_value) {
+ global $config;
+ $lcdproc_config = $config['installedpackages']['lcdproc']['config'][0];
+ $value = $lcdproc_config[$fieldname];
+ $returnvalue = "";
+ if ($value != '' && $value != '-1') {
+ $realvalue = (int)($max * $value / 100);
+ } else {
+ $realvalue = $default_value;
}
+ switch ($fieldname) {
+ case "brightness":
+ $returnvalue = "Brightness={$realvalue}\n";
+ break;
+ case "offbrightness":
+ $returnvalue = "OffBrightness={$realvalue}\n";
+ break;
+ case "contrast":
+ $returnvalue = "Contrast={$realvalue}\n";
+ break;
+ }
+ return $returnvalue;
+}
+
?>
diff --git a/config/lcdproc-dev/lcdproc.xml b/config/lcdproc-dev/lcdproc.xml
index 273aa1b1..ce62cb5c 100644
--- a/config/lcdproc-dev/lcdproc.xml
+++ b/config/lcdproc-dev/lcdproc.xml
@@ -1,8 +1,51 @@
<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd">
+<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?>
<packagegui>
- <title>Services: LCDproc 0.5.6 pkg v. 0.9.9</title>
+ <copyright>
+<![CDATA[
+/* $Id$ */
+/* ====================================================================================== */
+/*
+ lcdproc.xml
+ part of pfSense (https://www.pfSense.org/)
+ Copyright (C) 2007-2009 Seth Mos <seth.mos@dds.nl>
+ Copyright (C) 2009 Scott Ullrich
+ Copyright (C) 2011 Michele Di Maria
+ Copyright (C) 2015 ESF, LLC
+ 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.
+*/
+/* ====================================================================================== */
+ ]]>
+ </copyright>
+ <title>Services: LCDproc</title>
<name>lcdproc</name>
- <version>0.9.12</version>
+ <version>0.9.13</version>
<savetext>Save</savetext>
<include_file>/usr/local/pkg/lcdproc.inc</include_file>
<tabs>
@@ -18,29 +61,26 @@
</tabs>
<menu>
<name>LCDproc</name>
- <tooltiptext>Set LCDproc settings such as display driver and com port</tooltiptext>
+ <tooltiptext>Set LCDproc settings such as display driver and COM port.</tooltiptext>
<section>Services</section>
<url>/pkg_edit.php?xml=lcdproc.xml&amp;id=0</url>
</menu>
<additional_files_needed>
<item>https://packages.pfsense.org/packages/config/lcdproc-dev/lcdproc.inc</item>
- <prefix>/usr/local/pkg/</prefix>
- <chmod>0755</chmod>
+ <prefix>/usr/local/pkg/</prefix>
</additional_files_needed>
<additional_files_needed>
<item>https://packages.pfsense.org/packages/config/lcdproc-dev/lcdproc_screens.xml</item>
- <prefix>/usr/local/pkg/</prefix>
- <chmod>0755</chmod>
+ <prefix>/usr/local/pkg/</prefix>
</additional_files_needed>
<additional_files_needed>
<item>https://packages.pfsense.org/packages/config/lcdproc-dev/lcdproc_client.php</item>
- <prefix>/usr/local/pkg/</prefix>
- <chmod>0755</chmod>
+ <prefix>/usr/local/pkg/</prefix>
</additional_files_needed>
<additional_files_needed>
<item>https://files.pfsense.org/misc/nexcom.so</item>
- <prefix>/usr/local/lib/lcdproc/</prefix>
- <chmod>0755</chmod>
+ <prefix>/usr/local/lib/lcdproc/</prefix>
+ <chmod>0755</chmod>
</additional_files_needed>
<service>
<name>lcdproc</name>
@@ -50,14 +90,14 @@
</service>
<fields>
<field>
- <fielddescr>Enable LCDproc at startup</fielddescr>
+ <fielddescr>Enable LCDproc</fielddescr>
<fieldname>enable</fieldname>
<type>checkbox</type>
</field>
<field>
<fieldname>comport</fieldname>
- <fielddescr>Com Port</fielddescr>
- <description>Set the com port LCDproc should use.</description>
+ <fielddescr>COM Port</fielddescr>
+ <description>Set the COM port LCDproc should use.</description>
<type>select</type>
<options>
<option>
@@ -66,27 +106,27 @@
</option>
<option>
<value>com1</value>
- <name>Serial Com port 1 (/dev/cua0)</name>
- </option>
+ <name>Serial COM port 1 (/dev/cua0)</name>
+ </option>
<option>
<value>com2</value>
- <name>Serial Com port 2 (/dev/cua1)</name>
+ <name>Serial COM port 2 (/dev/cua1)</name>
</option>
<option>
<value>com1a</value>
- <name>Serial Com port 1 alternate (/dev/cuau0)</name>
+ <name>Serial COM port 1 alternate (/dev/cuau0)</name>
</option>
<option>
<value>com2a</value>
- <name>Serial Com port 2 alternate (/dev/cuau1)</name>
- </option>
+ <name>Serial COM port 2 alternate (/dev/cuau1)</name>
+ </option>
<option>
<value>ucom1</value>
- <name>USB Com port 1 (/dev/cuaU0)</name>
+ <name>USB COM port 1 (/dev/cuaU0)</name>
</option>
<option>
<value>ucom2</value>
- <name>USB Com port 2 (/dev/cuaU1)</name>
+ <name>USB COM port 2 (/dev/cuaU1)</name>
</option>
<option>
<value>lpt1</value>
@@ -94,20 +134,20 @@
</option>
<option>
<value>ugen0.2</value>
- <name>USB Com port 1 alternate (/dev/ugen0.2)</name>
- </option>
+ <name>USB COM port 1 alternate (/dev/ugen0.2)</name>
+ </option>
<option>
<value>ugen1.2</value>
- <name>USB Com port 2 alternate (/dev/ugen1.2)</name>
+ <name>USB COM port 2 alternate (/dev/ugen1.2)</name>
</option>
<option>
<value>ugen1.3</value>
- <name>USB Com port 3 alternate (/dev/ugen1.3)</name>
+ <name>USB COM port 3 alternate (/dev/ugen1.3)</name>
</option>
<option>
<value>ugen2.2</value>
- <name>USB Com port 4 alternate (/dev/ugen2.2)</name>
- </option>
+ <name>USB COM port 4 alternate (/dev/ugen2.2)</name>
+ </option>
</options>
<default_value>ucom1</default_value>
</field>
@@ -241,7 +281,7 @@
<option>
<value>nexcom</value>
<name>nexcom (x86 only)</name>
- </option>
+ </option>
<option>
<value>NoritakeVFD</value>
<name>NoritakeVFD</name>
@@ -249,15 +289,15 @@
<option>
<value>picolcd</value>
<name>picolcd</name>
- </option>
+ </option>
<option>
<value>pyramid</value>
<name>pyramid</name>
- </option>
+ </option>
<option>
<value>sdeclcd</value>
<name>Watchguard Firebox with SDEC</name>
- </option>
+ </option>
<option>
<value>sed1330</value>
<name>sed1330</name>
@@ -277,7 +317,7 @@
<option>
<value>shuttleVFD</value>
<name>shuttleVFD</name>
- </option>
+ </option>
<option>
<value>sli</value>
<name>sli</name>
@@ -289,7 +329,7 @@
<option>
<value>SureElec</value>
<name>SureElec</name>
- </option>
+ </option>
<option>
<value>t6963</value>
<name>t6963</name>
@@ -317,7 +357,7 @@
</option>
<option>
<value>8bit</value>
- <name>8bit wiring to parallel port(lcdtime)</name>
+ <name>8bit wiring to parallel port (lcdtime)</name>
</option>
<option>
<value>winamp</value>
@@ -385,7 +425,7 @@
</option>
</options>
<default_value>lcd2usb</default_value>
- </field>
+ </field>
<field>
<fieldname>refresh_frequency</fieldname>
<fielddescr>Refresh frequency</fielddescr>
@@ -414,11 +454,16 @@
</option>
</options>
<default_value>5</default_value>
- </field>
+ </field>
<field>
<fieldname>port_speed</fieldname>
<fielddescr>Port speed</fielddescr>
- <description>Set the port speed. Caution: not all the driver or panels support all the speeds, leave "default" if unsure.</description>
+ <description>
+ <![CDATA[
+ Set the port speed.<br />
+ Caution: not all the driver or panels support all the speeds, leave "default" if unsure.
+ ]]>
+ </description>
<type>select</type>
<options>
<option>
@@ -448,14 +493,19 @@
<option>
<value>115200</value>
<name>115200 bps</name>
- </option>
+ </option>
</options>
<default_value>0</default_value>
</field>
<field>
<fieldname>brightness</fieldname>
<fielddescr>Brightness</fielddescr>
- <description>Set the brightness of the LCD panel. This option is not supported by all the LCD panels, leave "default" if unsure.</description>
+ <description>
+ <![CDATA[
+ Set the brightness of the LCD panel.<br />
+ This option is not supported by all the LCD panels, leave "default" if unsure.
+ ]]>
+ </description>
<type>select</type>
<options>
<option>
@@ -473,11 +523,11 @@
<option>
<value>20</value>
<name>20%</name>
- </option>
+ </option>
<option>
<value>30</value>
<name>30%</name>
- </option>
+ </option>
<option>
<value>40</value>
<name>40%</name>
@@ -501,18 +551,23 @@
<option>
<value>90</value>
<name>90%</name>
- </option>
+ </option>
<option>
<value>100</value>
<name>100%</name>
</option>
- </options>
+ </options>
<default_value>-1</default_value>
</field>
<field>
<fieldname>offbrightness</fieldname>
<fielddescr>Off brightness</fielddescr>
- <description>Set the off-brightness of the LCD panel. This value is used when the display is normally switched off in case LCDd is inactive. This option is not supported by all the LCD panels, leave "default" if unsure.</description>
+ <description>
+ <![CDATA[
+ Set the off-brightness of the LCD panel. This value is used when the display is normally switched off in case LCDd is inactive.<br />
+ This option is not supported by all the LCD panels, leave "default" if unsure.
+ ]]>
+ </description>
<type>select</type>
<options>
<option>
@@ -530,11 +585,11 @@
<option>
<value>20</value>
<name>20%</name>
- </option>
+ </option>
<option>
<value>30</value>
<name>30%</name>
- </option>
+ </option>
<option>
<value>40</value>
<name>40%</name>
@@ -558,18 +613,23 @@
<option>
<value>90</value>
<name>90%</name>
- </option>
+ </option>
<option>
<value>100</value>
<name>100%</name>
</option>
- </options>
+ </options>
<default_value>-1</default_value>
- </field>
+ </field>
<field>
<fieldname>contrast</fieldname>
<fielddescr>Contrast</fielddescr>
- <description>Set the contrast of the LCD panel. This option is not supported by all the LCD panels, leave "default" if unsure.</description>
+ <description>
+ <![CDATA[
+ Set the contrast of the LCD panel.<br />
+ This option is not supported by all the LCD panels, leave "default" if unsure.
+ ]]>
+ </description>
<type>select</type>
<options>
<option>
@@ -587,11 +647,11 @@
<option>
<value>20</value>
<name>20%</name>
- </option>
+ </option>
<option>
<value>30</value>
<name>30%</name>
- </option>
+ </option>
<option>
<value>40</value>
<name>40%</name>
@@ -615,18 +675,23 @@
<option>
<value>90</value>
<name>90%</name>
- </option>
+ </option>
<option>
<value>100</value>
<name>100%</name>
</option>
- </options>
+ </options>
<default_value>-1</default_value>
- </field>
+ </field>
<field>
<fieldname>backlight</fieldname>
<fielddescr>Backlight</fielddescr>
- <description>Set the backlight setting. If set to the default value, then the backlight setting of the display can be influenced by the clients. This option is not supported by all the LCD panels, leave "default" if unsure.</description>
+ <description>
+ <![CDATA[
+ Set the backlight setting. If set to the default value, then the backlight setting of the display can be influenced by the clients.<br />
+ This option is not supported by all the LCD panels, leave "default" if unsure.
+ ]]>
+ </description>
<type>select</type>
<options>
<option>
@@ -647,15 +712,19 @@
<field>
<fieldname>outputleds</fieldname>
<fielddescr>Enable Output LEDs</fielddescr>
- <description>Enable the Output LEDs present on some LCD panels. This feature is currently supported by the CFontz633 driver only. &lt;br&gt;
- Each LED can be off or show two colors: RED (alarm) or GREEN (everything ok) and shows: &lt;br&gt;
- LED1: NICs status (green: ok, red: at least one nic down);&lt;br&gt;
- LED2: CARP status (green: master, red: backup, off: CARP not implemented);&lt;br&gt;
- LED3: CPU status (green &lt; 50, red &gt; 50%);&lt;br&gt;
- LED4: Gateway status (green: ok, red: at least one gateway not responding, off: no gateway configured).</description>
+ <description>
+ <![CDATA[
+ Enable the Output LEDs present on some LCD panels. This feature is currently supported by the CFontz633 driver only.<br />
+ Each LED can be off or show two colors: RED (alarm) or GREEN (everything ok) and shows:<br />
+ LED1: NICs status (green: ok, red: at least one nic down)<br />
+ LED2: CARP status (green: master, red: backup, off: CARP not implemented)<br />
+ LED3: CPU status (green &lt; 50%, red &gt; 50%)<br />
+ LED4: Gateway status (green: ok, red: at least one gateway not responding, off: no gateway configured).
+ ]]>
+ </description>
<type>checkbox</type>
<default_value>default</default_value>
- </field>
+ </field>
</fields>
<custom_php_validation_command>
validate_form_lcdproc($_POST, $input_errors);
diff --git a/config/lcdproc-dev/lcdproc_client.php b/config/lcdproc-dev/lcdproc_client.php
index 922ed14e..6635bf7f 100644
--- a/config/lcdproc-dev/lcdproc_client.php
+++ b/config/lcdproc-dev/lcdproc_client.php
@@ -1,932 +1,935 @@
<?php
-/* $Id$ */
/*
- lcdproc_client.php
- Copyright (C) 2007 Seth Mos <seth.mos@xs4all.nl>
- Copyright (C) 2012 Michele Di Maria <michele@nt2.it>
- 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.
+ lcdproc_client.php
+ part of pfSense (https://www.pfSense.org/)
+ Copyright (C) 2007-2009 Seth Mos <seth.mos@dds.nl>
+ Copyright (C) 2009 Scott Ullrich
+ Copyright (C) 2011 Michele Di Maria
+ Copyright (C) 2015 ESF, LLC
+ 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.
*/
-
- /* trick interface into running this. we are only
- * calling from useland so this is not a security issue
- */
- require_once("config.inc");
- require_once("functions.inc");
- require_once("interfaces.inc");
- require_once("/usr/local/pkg/lcdproc.inc");
-
- function get_pfstate() {
- global $config;
- $matches = "";
- if (isset($config['system']['maximumstates']) and $config['system']['maximumstates'] > 0)
- $maxstates="/{$config['system']['maximumstates']}";
- else
- $maxstates="/". pfsense_default_state_size();
-
- $curentries = `/sbin/pfctl -si |grep current`;
- if (preg_match("/([0-9]+)/", $curentries, $matches)) {
- $curentries = $matches[1];
- }
- return $curentries . $maxstates;
+require_once("config.inc");
+require_once("functions.inc");
+require_once("interfaces.inc");
+require_once("/usr/local/pkg/lcdproc.inc");
+
+function get_pfstate() {
+ global $config;
+ $matches = "";
+ if (isset($config['system']['maximumstates']) and $config['system']['maximumstates'] > 0) {
+ $maxstates = "/{$config['system']['maximumstates']}";
+ } else {
+ $maxstates = "/". pfsense_default_state_size();
}
-
- function disk_usage() {
- $dfout = "";
- exec("/bin/df -h | /usr/bin/grep -w '/' | /usr/bin/awk '{ print $5 }' | /usr/bin/cut -d '%' -f 1", $dfout);
- $diskusage = trim($dfout[0]);
-
- return $diskusage;
+ $curentries = shell_exec('/sbin/pfctl -si | /usr/bin/grep current');
+ if (preg_match("/([0-9]+)/", $curentries, $matches)) {
+ $curentries = $matches[1];
}
-
- function mem_usage() {
- $memory = "";
- exec("/sbin/sysctl -n vm.stats.vm.v_page_count vm.stats.vm.v_inactive_count " .
- "vm.stats.vm.v_cache_count vm.stats.vm.v_free_count", $memory);
-
- $totalMem = $memory[0];
- $availMem = $memory[1] + $memory[2] + $memory[3];
- $usedMem = $totalMem - $availMem;
- $memUsage = round(($usedMem * 100) / $totalMem, 0);
-
- return $memUsage;
+ return $curentries . $maxstates;
+}
+
+function disk_usage() {
+ $dfout = "";
+ exec("/bin/df -h | /usr/bin/grep -w '/' | /usr/bin/awk '{ print $5 }' | /usr/bin/cut -d '%' -f 1", $dfout);
+ $diskusage = trim($dfout[0]);
+
+ return $diskusage;
+}
+
+function mem_usage() {
+ $memory = "";
+ exec("/sbin/sysctl -n vm.stats.vm.v_page_count vm.stats.vm.v_inactive_count " .
+ "vm.stats.vm.v_cache_count vm.stats.vm.v_free_count", $memory);
+
+ $totalMem = $memory[0];
+ $availMem = $memory[1] + $memory[2] + $memory[3];
+ $usedMem = $totalMem - $availMem;
+ $memUsage = round(($usedMem * 100) / $totalMem, 0);
+
+ return $memUsage;
+}
+
+/* Calculates non-idle CPU time and returns as a percentage */
+function cpu_usage() {
+ $duration = 250000;
+ $diff = array('user', 'nice', 'sys', 'intr', 'idle');
+ $cpuTicks = array_combine($diff, explode(" ", shell_exec('/sbin/sysctl -n kern.cp_time')));
+ usleep($duration);
+ $cpuTicks2 = array_combine($diff, explode(" ", shell_exec('/sbin/sysctl -n kern.cp_time')));
+
+ $totalStart = array_sum($cpuTicks);
+ $totalEnd = array_sum($cpuTicks2);
+
+ // Something wrapped ?!?!
+ if ($totalEnd <= $totalStart) {
+ return 0;
}
- /* Calculates non-idle CPU time and returns as a percentage */
- function cpu_usage() {
- $duration = 250000;
- $diff = array('user', 'nice', 'sys', 'intr', 'idle');
- $cpuTicks = array_combine($diff, explode(" ", `/sbin/sysctl -n kern.cp_time`));
- usleep($duration);
- $cpuTicks2 = array_combine($diff, explode(" ", `/sbin/sysctl -n kern.cp_time`));
+ // Calculate total cycles used
+ $totalUsed = ($totalEnd - $totalStart) - ($cpuTicks2['idle'] - $cpuTicks['idle']);
- $totalStart = array_sum($cpuTicks);
- $totalEnd = array_sum($cpuTicks2);
+ // Calculate the percentage used
+ $cpuUsage = floor(100 * ($totalUsed / ($totalEnd - $totalStart)));
- // Something wrapped ?!?!
- if ($totalEnd <= $totalStart)
- return 0;
+ return $cpuUsage;
+}
- // Calculate total cycles used
- $totalUsed = ($totalEnd - $totalStart) - ($cpuTicks2['idle'] - $cpuTicks['idle']);
-
- // Calculate the percentage used
- $cpuUsage = floor(100 * ($totalUsed / ($totalEnd - $totalStart)));
-
- return $cpuUsage;
+function get_uptime_stats() {
+ exec("/usr/bin/uptime", $output, $ret);
+ $temp = explode(",", $output[0]);
+ if (stristr($output[0], "day")) {
+ $status = "$temp[0] $temp[1]";
+ } else {
+ $status = "$temp[0] ";
}
-
- function get_uptime_stats() {
- exec("/usr/bin/uptime", $output, $ret);
- $temp = explode(",", $output[0]);
- if(stristr($output[0], "day")) {
- $status = "$temp[0] $temp[1]";
- } else {
- $status = "$temp[0] ";
- }
- $status = trim(str_replace(" ", " ", $status));
- $status = substr($status, strpos($status, "up ") + 3);
- return($status);
+ $status = trim(str_replace(" ", " ", $status));
+ $status = substr($status, strpos($status, "up ") + 3);
+
+ return($status);
+}
+
+function get_loadavg_stats() {
+ exec("/usr/bin/uptime", $output, $ret);
+ if (stristr($output[0], "day")) {
+ $temp = explode(" ", $output[0]);
+ $status = "$temp[11] $temp[12] $temp[13]";
+ } else {
+ $temp = explode(" ", $output[0]);
+ $status = "$temp[10] $temp[11] $temp[12]";
}
-
- function get_loadavg_stats() {
- exec("/usr/bin/uptime", $output, $ret);
- if(stristr($output[0], "day")) {
- $temp = explode(" ", $output[0]);
- $status = "$temp[11] $temp[12] $temp[13]";
+ return($status);
+}
+
+function get_mbuf_stats() {
+ exec("/usr/bin/netstat -mb | /usr/bin/grep \"mbufs in use\" | /usr/bin/awk '{ print $1 }' | /usr/bin/cut -d\"/\" -f1", $mbufs_inuse);
+ exec("/usr/bin/netstat -mb | /usr/bin/grep \"mbufs in use\" | /usr/bin/awk '{ print $1 }' | /usr/bin/cut -d\"/\" -f3", $mbufs_total);
+ $status = "$mbufs_inuse[0] \/ $mbufs_total[0]";
+ return($status);
+}
+
+function get_version() {
+ global $g;
+ $version = @file_get_contents("/etc/version");
+ $version = trim($version);
+ return("{$g['product_name']} {$version}");
+}
+
+function get_cpufrequency() {
+ $cpufreqs = "";
+ exec("/sbin/sysctl -n dev.cpu.0.freq_levels", $cpufreqs);
+ $cpufreqs = explode(" ", trim($cpufreqs[0]));
+ $maxfreq = explode("/", $cpufreqs[0]);
+ $maxfreq = $maxfreq[0];
+ $curfreq = "";
+ exec("/sbin/sysctl -n dev.cpu.0.freq", $curfreq);
+ $curfreq = trim($curfreq[0]);
+ $status = "$curfreq\/$maxfreq Mhz";
+ return($status);
+}
+
+function get_cpufrequency_perc() {
+ $cpufreqs = "";
+ exec("/sbin/sysctl -n dev.cpu.0.freq_levels", $cpufreqs);
+ $cpufreqs = explode(" ", trim($cpufreqs[0]));
+ $maxfreq = explode("/", $cpufreqs[0]);
+ $maxfreq = $maxfreq[0];
+ $curfreq = "";
+ exec("/sbin/sysctl -n dev.cpu.0.freq", $curfreq);
+ $curfreq = trim($curfreq[0]);
+ $status = $curfreq/$maxfreq * 100;
+ return($status);
+}
+
+function get_interfaces_stats() {
+ global $g;
+ global $config;
+ $ifstatus = array();
+ $i = 0;
+ $ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN');
+ for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) {
+ $ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr'];
+ }
+ foreach ($ifdescrs as $ifdescr => $ifname) {
+ $ifinfo = get_interface_info($ifdescr);
+ if ($ifinfo['status'] == "up") {
+ $online = "Up";
} else {
- $temp = explode(" ", $output[0]);
- $status = "$temp[10] $temp[11] $temp[12]";
- }
- return($status);
- }
-
- function get_mbuf_stats() {
- exec("netstat -mb | grep \"mbufs in use\" | awk '{ print $1 }' | cut -d\"/\" -f1", $mbufs_inuse);
- exec("netstat -mb | grep \"mbufs in use\" | awk '{ print $1 }' | cut -d\"/\" -f3", $mbufs_total);
- $status = "$mbufs_inuse[0] \/ $mbufs_total[0]";
- return($status);
- }
-
- function get_version() {
- global $g;
- $version = @file_get_contents("/etc/version");
- $version = trim($version);
- return("{$g['product_name']} {$version}");
- }
-
- function get_cpufrequency(){
- $cpufreqs = "";
- exec("/sbin/sysctl -n dev.cpu.0.freq_levels", $cpufreqs);
- $cpufreqs = explode(" ", trim($cpufreqs[0]));
- $maxfreq = explode("/", $cpufreqs[0]);
- $maxfreq = $maxfreq[0];
- $curfreq = "";
- exec("/sbin/sysctl -n dev.cpu.0.freq", $curfreq);
- $curfreq = trim($curfreq[0]);
- $status = "$curfreq\/$maxfreq Mhz";
- return($status);
- }
-
- function get_cpufrequency_perc(){
- $cpufreqs = "";
- exec("/sbin/sysctl -n dev.cpu.0.freq_levels", $cpufreqs);
- $cpufreqs = explode(" ", trim($cpufreqs[0]));
- $maxfreq = explode("/", $cpufreqs[0]);
- $maxfreq = $maxfreq[0];
- $curfreq = "";
- exec("/sbin/sysctl -n dev.cpu.0.freq", $curfreq);
- $curfreq = trim($curfreq[0]);
- $status = $curfreq/$maxfreq * 100;
- return($status);
- }
-
- function get_interfaces_stats() {
- global $g;
- global $config;
- $ifstatus = array();
- $i = 0;
- $ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN');
- for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) {
- $ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr'];
+ $online = "Down";
}
- foreach ($ifdescrs as $ifdescr => $ifname){
- $ifinfo = get_interface_info($ifdescr);
- if($ifinfo['status'] == "up") {
- $online = "Up";
- } else {
- $online = "Down";
- }
- if(!empty($ifinfo['ipaddr'])) {
- $ip = htmlspecialchars($ifinfo['ipaddr']);
- } else {
- $ip = "-";
- }
- $ifstatus[] = htmlspecialchars($ifname) ." [$online]";
+ if (!empty($ifinfo['ipaddr'])) {
+ $ip = htmlspecialchars($ifinfo['ipaddr']);
+ } else {
+ $ip = "-";
}
- $status = " ". implode(", ", $ifstatus);
- return($status);
+ $ifstatus[] = htmlspecialchars($ifname) ." [$online]";
}
+ $status = " ". implode(", ", $ifstatus);
+ return($status);
+}
- function get_slbd_stats() {
- global $g;
- global $config;
+function get_slbd_stats() {
+ global $g;
+ global $config;
- if (!is_array($config['load_balancer']['lbpool'])) {
- $config['load_balancer']['lbpool'] = array();
- }
- $a_pool = &$config['load_balancer']['lbpool'];
-
- $slbd_logfile = "{$g['varlog_path']}/slbd.log";
-
- $nentries = $config['syslog']['nentries'];
- if (!$nentries)
- $nentries = 50;
-
- $now = time();
- $year = date("Y");
- $pstatus = "";
- $i = 0;
- foreach ($a_pool as $vipent) {
- $pstatus[] = "{$vipent['name']}";
- if ($vipent['type'] == "gateway") {
- $poolfile = "{$g['tmp_path']}/{$vipent['name']}.pool";
- if(file_exists("$poolfile")) {
- $poolstatus = file_get_contents("$poolfile");
- } else {
- continue;
- }
- foreach ((array) $vipent['servers'] as $server) {
- $lastchange = "";
- $svr = split("\|", $server);
- $monitorip = $svr[1];
- if(stristr($poolstatus, $monitorip)) {
- $online = "Up";
- } else {
- $online = "Down";
- }
- $pstatus[] = strtoupper($svr[0]) ." [{$online}]";
- }
+ if (!is_array($config['load_balancer']['lbpool'])) {
+ $config['load_balancer']['lbpool'] = array();
+ }
+ $a_pool = &$config['load_balancer']['lbpool'];
+
+ $slbd_logfile = "{$g['varlog_path']}/slbd.log";
+
+ $nentries = $config['syslog']['nentries'];
+ if (!$nentries) {
+ $nentries = 50;
+ }
+
+ $now = time();
+ $year = date("Y");
+ $pstatus = "";
+ $i = 0;
+ foreach ($a_pool as $vipent) {
+ $pstatus[] = "{$vipent['name']}";
+ if ($vipent['type'] == "gateway") {
+ $poolfile = "{$g['tmp_path']}/{$vipent['name']}.pool";
+ if (file_exists("$poolfile")) {
+ $poolstatus = file_get_contents("$poolfile");
} else {
- $pstatus[] = "{$vipent['monitor']}";
+ continue;
}
- }
- if(count($a_pool) == 0) {
- $pstatus[] = "Disabled";
- }
- $status = implode(", ", $pstatus);
- return($status);
- }
-
- function get_carp_stats () {
- global $g;
- global $config;
-
- if(is_array($config['virtualip']['vip'])) {
- $carpint = 0;
- $initcount = 0;
- $mastercount = 0;
- $backupcount = 0;
- foreach($config['virtualip']['vip'] as $carp) {
- if ($carp['mode'] != "carp") {
- continue;
- }
- $ipaddress = $carp['subnet'];
- $password = $carp['password'];
- $netmask = $carp['subnet_bits'];
- $vhid = $carp['vhid'];
- $advskew = $carp['advskew'];
- $carp_int = find_carp_interface($ipaddress);
- $status = get_carp_interface_status($carp_int);
- switch($status) {
- case "MASTER":
- $mastercount++;
- break;
- case "BACKUP":
- $backupcount++;
- break;
- case "INIT":
- $initcount++;
- break;
+ foreach ((array) $vipent['servers'] as $server) {
+ $lastchange = "";
+ $svr = explode("|", $server);
+ $monitorip = $svr[1];
+ if (stristr($poolstatus, $monitorip)) {
+ $online = "Up";
+ } else {
+ $online = "Down";
}
+ $pstatus[] = strtoupper($svr[0]) ." [{$online}]";
}
- $status = "M/B/I {$mastercount}/{$backupcount}/{$initcount}";
} else {
- $status = "CARP Disabled";
+ $pstatus[] = "{$vipent['monitor']}";
}
- return($status);
- }
-
- function get_ipsec_tunnel_sad() {
- /* query SAD */
- if(file_exists("/usr/local/sbin/setkey"))
- $fd = @popen("/usr/local/sbin/setkey -D", "r");
- else
- $fd = @popen("/sbin/setkey -D", "r");
- $sad = array();
- if ($fd) {
- while (!feof($fd)) {
- $line = chop(fgets($fd));
- if (!$line)
- continue;
- if ($line == "No SAD entries.")
+ }
+ if (count($a_pool) == 0) {
+ $pstatus[] = "Disabled";
+ }
+ $status = implode(", ", $pstatus);
+ return($status);
+}
+
+function get_carp_stats() {
+ global $g;
+ global $config;
+
+ if (is_array($config['virtualip']['vip'])) {
+ $carpint = 0;
+ $initcount = 0;
+ $mastercount = 0;
+ $backupcount = 0;
+ foreach ($config['virtualip']['vip'] as $carp) {
+ if ($carp['mode'] != "carp") {
+ continue;
+ }
+ $ipaddress = $carp['subnet'];
+ $password = $carp['password'];
+ $netmask = $carp['subnet_bits'];
+ $vhid = $carp['vhid'];
+ $advskew = $carp['advskew'];
+ $carp_int = find_carp_interface($ipaddress);
+ $status = get_carp_interface_status($carp_int);
+ switch ($status) {
+ case "MASTER":
+ $mastercount++;
break;
- if ($line[0] != "\t") {
- if (is_array($cursa))
- $sad[] = $cursa;
- $cursa = array();
- list($cursa['src'],$cursa['dst']) = explode(" ", $line);
- $i = 0;
- } else {
- $linea = explode(" ", trim($line));
- if ($i == 1) {
- $cursa['proto'] = $linea[0];
- $cursa['spi'] = substr($linea[2], strpos($linea[2], "x")+1, -1);
- } else if ($i == 2) {
- $cursa['ealgo'] = $linea[1];
- } else if ($i == 3) {
- $cursa['aalgo'] = $linea[1];
- }
+ case "BACKUP":
+ $backupcount++;
+ break;
+ case "INIT":
+ $initcount++;
+ break;
+ }
+ }
+ $status = "M/B/I {$mastercount}/{$backupcount}/{$initcount}";
+ } else {
+ $status = "CARP Disabled";
+ }
+ return($status);
+}
+
+function get_ipsec_tunnel_sad() {
+ /* query SAD */
+ if (file_exists("/usr/local/sbin/setkey")) {
+ $fd = @popen("/usr/local/sbin/setkey -D", "r");
+ } else {
+ $fd = @popen("/sbin/setkey -D", "r");
+ }
+ $sad = array();
+ if ($fd) {
+ while (!feof($fd)) {
+ $line = chop(fgets($fd));
+ if (!$line) {
+ continue;
+ }
+ if ($line == "No SAD entries.") {
+ break;
+ }
+ if ($line[0] != "\t") {
+ if (is_array($cursa)) {
+ $sad[] = $cursa;
+ $cursa = array();
}
- $i++;
+ list($cursa['src'],$cursa['dst']) = explode(" ", $line);
+ $i = 0;
+ } else {
+ $linea = explode(" ", trim($line));
+ if ($i == 1) {
+ $cursa['proto'] = $linea[0];
+ $cursa['spi'] = substr($linea[2], strpos($linea[2], "x")+1, -1);
+ } else if ($i == 2) {
+ $cursa['ealgo'] = $linea[1];
+ } else if ($i == 3) {
+ $cursa['aalgo'] = $linea[1];
}
- if (is_array($cursa) && count($cursa))
- $sad[] = $cursa;
- pclose($fd);
+ }
+ $i++;
}
- return($sad);
- }
-
- function get_ipsec_tunnel_src($tunnel) {
- global $g, $config, $sad;
- $if = "WAN";
- if ($tunnel['interface']) {
- $if = $tunnel['interface'];
- $realinterface = convert_friendly_interface_to_real_interface_name($if);
- $interfaceip = find_interface_ip($realinterface);
+ if (is_array($cursa) && count($cursa)) {
+ $sad[] = $cursa;
}
- return $interfaceip;
+ pclose($fd);
}
-
- function output_ipsec_tunnel_status($tunnel) {
- global $g, $config, $sad;
- $if = "WAN";
- $interfaceip = get_ipsec_tunnel_src($tunnel);
- $foundsrc = false;
- $founddst = false;
-
- if(!is_array($sad)) {
- /* we have no sad array, bail */
- return(false);
- }
- foreach($sad as $sa) {
- if($sa['src'] == $interfaceip)
- $foundsrc = true;
- if($sa['dst'] == $tunnel['remote-gateway'])
- $founddst = true;
+ return($sad);
+}
+
+function get_ipsec_tunnel_src($tunnel) {
+ global $g, $config, $sad;
+ $if = "WAN";
+ if ($tunnel['interface']) {
+ $if = $tunnel['interface'];
+ $realinterface = convert_friendly_interface_to_real_interface_name($if);
+ $interfaceip = find_interface_ip($realinterface);
+ }
+ return $interfaceip;
+}
+
+function output_ipsec_tunnel_status($tunnel) {
+ global $g, $config, $sad;
+ $if = "WAN";
+ $interfaceip = get_ipsec_tunnel_src($tunnel);
+ $foundsrc = false;
+ $founddst = false;
+
+ if (!is_array($sad)) {
+ /* we have no sad array, bail */
+ return(false);
+ }
+ foreach ($sad as $sa) {
+ if ($sa['src'] == $interfaceip) {
+ $foundsrc = true;
}
- if($foundsrc && $founddst) {
- /* tunnel is up */
- $iconfn = "pass";
- return(true);
- } else {
- /* tunnel is down */
- $iconfn = "reject";
- return(false);
+ if ($sa['dst'] == $tunnel['remote-gateway']) {
+ $founddst = true;
}
}
+ if ($foundsrc && $founddst) {
+ /* tunnel is up */
+ $iconfn = "pass";
+ return(true);
+ } else {
+ /* tunnel is down */
+ $iconfn = "reject";
+ return(false);
+ }
+}
- function get_ipsec_stats() {
- global $g, $config, $sad;
- $sad = array();
- $sad = get_ipsec_tunnel_sad();
-
- $activecounter = 0;
- $inactivecounter = 0;
-
- if($config['ipsec']['tunnel']) {
- foreach ($config['ipsec']['tunnel'] as $tunnel){
- $ipsecstatus = false;
-
- $tun_disabled = "false";
- $foundsrc = false;
- $founddst = false;
-
- if (isset($tunnel['disabled'])) {
- $tun_disabled = "true";
- continue;
- }
-
- if(output_ipsec_tunnel_status($tunnel)) {
- /* tunnel is up */
- $iconfn = "true";
- $activecounter++;
- } else {
- /* tunnel is down */
- $iconfn = "false";
- $inactivecounter++;
- }
- }
- }
+function get_ipsec_stats() {
+ global $g, $config, $sad;
+ $sad = array();
+ $sad = get_ipsec_tunnel_sad();
- if (is_array($config['ipsec']['tunnel'])) {
- $status = "Up/Down $activecounter/$inactivecounter";
- } else {
- $status = "IPSEC Disabled";
- }
- return($status);
- }
+ $activecounter = 0;
+ $inactivecounter = 0;
-
- /* Define functions */
- function send_lcd_commands($lcd, $lcd_cmds) {
- if(!is_array($lcd_cmds) || (empty($lcd_cmds))) {
- lcdproc_warn("Failed to interpret lcd commands");
- return;
- }
- while (($cmd_output = fgets($lcd, 8000)) !== false) {
- if(preg_match("/^huh?/", $cmd_output)) {
- lcdproc_notice("LCDd output: \"$cmd_output\". Executed \"$lcd_cmd\"");
+ if ($config['ipsec']['tunnel']) {
+ foreach ($config['ipsec']['tunnel'] as $tunnel) {
+ $ipsecstatus = false;
+
+ $tun_disabled = "false";
+ $foundsrc = false;
+ $founddst = false;
+
+ if (isset($tunnel['disabled'])) {
+ $tun_disabled = "true";
+ continue;
}
- }
- foreach($lcd_cmds as $lcd_cmd) {
- if(! fwrite($lcd, "$lcd_cmd\n")) {
- lcdproc_warn("Connection to LCDd process lost $errstr ($errno)");
- $lcdproc_connect_errors++;
- return false;
+
+ if (output_ipsec_tunnel_status($tunnel)) {
+ /* tunnel is up */
+ $iconfn = "true";
+ $activecounter++;
+ } else {
+ /* tunnel is down */
+ $iconfn = "false";
+ $inactivecounter++;
}
}
- return true;
}
- function get_lcdpanel_width(){
- global $config;
- $lcdproc_size_config = $config['installedpackages']['lcdproc']['config'][0];
- if (is_null($lcdproc_size_config['size'])) {
- return "16";
- }
- else
- {
- $dimensions = split("x", $lcdproc_size_config['size']);
- return $dimensions[0];
- }
+ if (is_array($config['ipsec']['tunnel'])) {
+ $status = "Up/Down $activecounter/$inactivecounter";
+ } else {
+ $status = "IPSEC Disabled";
}
-
- function get_lcdpanel_height(){
- global $config;
- $lcdproc_size_config = $config['installedpackages']['lcdproc']['config'][0];
- if (is_null($lcdproc_size_config['size'])) {
- return "2";
- }
- else
- {
- $dimensions = split("x", $lcdproc_size_config['size']);
- return $dimensions[1];
- }
- }
-
- function get_lcdpanel_refresh_frequency(){
- global $config;
- $lcdproc_size_config = $config['installedpackages']['lcdproc']['config'][0];
- $value = $lcdproc_size_config['refresh_frequency'];
- if (is_null($value)) {
- return "5";
- }
- else
- {
- return $value;
+ return($status);
+}
+
+function send_lcd_commands($lcd, $lcd_cmds) {
+ if (!is_array($lcd_cmds) || (empty($lcd_cmds))) {
+ lcdproc_warn("Failed to interpret lcd commands");
+ return;
+ }
+ while (($cmd_output = fgets($lcd, 8000)) !== false) {
+ if (preg_match("/^huh?/", $cmd_output)) {
+ lcdproc_notice("LCDd output: \"$cmd_output\". Executed \"$lcd_cmd\"");
}
}
-
- function outputled_enabled_CFontz633(){
- global $config;
- $lcdproc_config = $config['installedpackages']['lcdproc']['config'][0];
- $value = $lcdproc_config['outputleds'];
- if (is_null($value))
- {return false;}
- else
- {
- if ($value && $lcdproc_config['driver'] == "CFontz633")
- {return true;}
- else if ($value && $lcdproc_config['driver'] == "CFontzPacket")
- {return true;}
- else
- {return false;}
+ foreach ($lcd_cmds as $lcd_cmd) {
+ if (! fwrite($lcd, "$lcd_cmd\n")) {
+ lcdproc_warn("Connection to LCDd process lost $errstr ($errno)");
+ $lcdproc_connect_errors++;
+ return false;
}
}
-
- function outputled_carp () {
- /* Returns the status of CARP for the box.
- Assumes ALL CARP status are the same for all the intefaces.
- -1 = CARP Disabled
- 0 = CARP on Backup
- 1 = CARP on Master */
- global $g;
- global $config;
-
- if(is_array($config['virtualip']['vip'])) {
- $carpint = 0;
- foreach($config['virtualip']['vip'] as $carp) {
- if ($carp['mode'] != "carp") {
- continue;
- }
- $carp_int = find_carp_interface($carp['subnet']);
- $status = get_carp_interface_status($carp_int);
- switch($status) {
- case "MASTER":
- return 1;
- break;
- case "BACKUP":
- return 0;
- break;
- }
- }
+ return true;
+}
+
+function get_lcdpanel_width() {
+ global $config;
+ $lcdproc_size_config = $config['installedpackages']['lcdproc']['config'][0];
+ if (is_null($lcdproc_size_config['size'])) {
+ return "16";
+ } else {
+ $dimensions = explode("x", $lcdproc_size_config['size']);
+ return $dimensions[0];
+ }
+}
+
+function get_lcdpanel_height() {
+ global $config;
+ $lcdproc_size_config = $config['installedpackages']['lcdproc']['config'][0];
+ if (is_null($lcdproc_size_config['size'])) {
+ return "2";
+ } else {
+ $dimensions = explode("x", $lcdproc_size_config['size']);
+ return $dimensions[1];
+ }
+}
+
+function get_lcdpanel_refresh_frequency() {
+ global $config;
+ $lcdproc_size_config = $config['installedpackages']['lcdproc']['config'][0];
+ $value = $lcdproc_size_config['refresh_frequency'];
+ if (is_null($value)) {
+ return "5";
+ } else {
+ return $value;
+ }
+}
+
+function outputled_enabled_CFontz633() {
+ global $config;
+ $lcdproc_config = $config['installedpackages']['lcdproc']['config'][0];
+ $value = $lcdproc_config['outputleds'];
+ if (is_null($value)) {
+ return false;
+ } else {
+ if ($value && $lcdproc_config['driver'] == "CFontz633") {
+ return true;
+ } else if ($value && $lcdproc_config['driver'] == "CFontzPacket") {
+ return true;
} else {
- return -1;
- }
- }
-
- function outputled_gateway() {
- /* Returns the status of the gateways.
- -1 = No gateway defined
- 0 = At least 1 gateway down or with issues
- 1 = All gateway up */
- global $g;
- global $config;
- $a_gateways = return_gateways_array();
- $gateways_status = array();
- $gateways_status = return_gateways_status(true);
- foreach ($a_gateways as $gname => $gateway)
- {
- if ($gateways_status[$gname]['status'] != "none")
- {
- return 0;
- }
- }
- return 1;
- }
-
- function get_traffic_stats(&$in_data, &$out_data){
- global $config;
- global $traffic_last_ugmt, $traffic_last_ifin, $traffic_last_ifout;
- $lcdproc_screen_config = $config['installedpackages']['lcdprocscreens']['config'][0];
- /* read the configured interface */
- $ifnum = $lcdproc_screen_config['scr_traffic_interface'];
- /* get the real interface name (code from ifstats.php)*/
- $realif = get_real_interface($ifnum);
- if(!$realif)
- $realif = $ifnum; // Need for IPSec case interface.
- /* get the interface stats (code from ifstats.php)*/
- $ifinfo = pfSense_get_interface_stats($realif);
- /* get the current time (code from ifstats.php)*/
- $temp = gettimeofday();
- $timing = (double)$temp["sec"] + (double)$temp["usec"] / 1000000.0;
- /* calculate the traffic stats */
- $deltatime = $timing - $traffic_last_ugmt;
- $in_data = "IN: " . formatSpeedBits(((double)$ifinfo['inbytes']-$traffic_last_ifin)/$deltatime);
- $out_data = "OUT: " . formatSpeedBits(((double)$ifinfo['outbytes']-$traffic_last_ifout)/$deltatime);
- $traffic_last_ugmt = $timing;
- $traffic_last_ifin = (double)$ifinfo['inbytes'];
- $traffic_last_ifout = (double)$ifinfo['outbytes'];
- }
-
- function formatSpeedBits($speed) {
- /* format speed in bits/sec, input: bytes/sec
- Code from: graph.php ported to PHP*/
- if ($speed < 125000)
- {return sprintf("%5.1f Kbps", $speed / 125);}
- if ($speed < 125000000)
- {return sprintf("%5.1f Mbps", $speed / 125000);}
- // else
- return sprintf("%5.1f Gbps", $speed / 125000000);
- }
-
- function add_summary_declaration(&$lcd_cmds, $name) {
- $lcdpanel_height = get_lcdpanel_height();
- $lcdpanel_width = get_lcdpanel_width();
- if ($lcdpanel_height >= "4")
- {
- $lcd_cmds[] = "widget_add $name title_summary string";
- $lcd_cmds[] = "widget_add $name text_summary string";
- if ($lcdpanel_width > "16")
- {$lcd_cmds[] = "widget_set $name title_summary 1 3 \"CPU MEM STATES FREQ\"";}
- else
- {$lcd_cmds[] = "widget_set $name title_summary 1 3 \"CPU MEM STATES\"";}
- }
- }
-
- function add_summary_values(&$lcd_cmds, $name, $lcd_summary_data) {
- if ($lcd_summary_data != "")
- {
- $lcd_cmds[] = "widget_set $name text_summary 1 4 \"{$lcd_summary_data}\"";
+ return false;
}
}
-
- function build_interface($lcd) {
- global $g;
- global $config;
- $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0];
- $refresh_frequency = get_lcdpanel_refresh_frequency() * 8;
-
- $lcd_cmds = array();
- $lcd_cmds[] = "hello";
- $lcd_cmds[] = "client_set name pfSense";
-
- /* process screens to display */
- if(is_array($lcdproc_screens_config)) {
- foreach($lcdproc_screens_config as $name => $screen) {
- if($screen == "on") {
- switch($name) {
- case "scr_version":
- $lcd_cmds[] = "screen_add $name";
- $lcd_cmds[] = "screen_set $name heartbeat off";
- $lcd_cmds[] = "screen_set $name name $name";
- $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
- $lcd_cmds[] = "widget_add $name title_wdgt string";
- $lcd_cmds[] = "widget_add $name text_wdgt scroller";
- $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"Welcome to\"";
- break;
- case "scr_time":
- $lcd_cmds[] = "screen_add $name";
- $lcd_cmds[] = "screen_set $name heartbeat off";
- $lcd_cmds[] = "screen_set $name name $name";
- $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
- $lcd_cmds[] = "widget_add $name title_wdgt string";
- $lcd_cmds[] = "widget_add $name text_wdgt scroller";
- $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Time\"";
- break;
- case "scr_uptime":
- $lcd_cmds[] = "screen_add $name";
- $lcd_cmds[] = "screen_set $name heartbeat off";
- $lcd_cmds[] = "screen_set $name name $name";
- $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
- $lcd_cmds[] = "widget_add $name title_wdgt string";
- $lcd_cmds[] = "widget_add $name text_wdgt scroller";
- $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Uptime\"";
- break;
- case "scr_hostname":
- $lcd_cmds[] = "screen_add $name";
- $lcd_cmds[] = "screen_set $name heartbeat off";
- $lcd_cmds[] = "screen_set $name name $name";
- $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
- $lcd_cmds[] = "widget_add $name title_wdgt string";
- $lcd_cmds[] = "widget_add $name text_wdgt scroller";
- $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Name\"";
- break;
- case "scr_system":
- $lcd_cmds[] = "screen_add $name";
- $lcd_cmds[] = "screen_set $name heartbeat off";
- $lcd_cmds[] = "screen_set $name name $name";
- $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
- $lcd_cmds[] = "widget_add $name title_wdgt string";
- $lcd_cmds[] = "widget_add $name text_wdgt scroller";
- $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Stats\"";
- break;
- case "scr_disk":
- $lcd_cmds[] = "screen_add $name";
- $lcd_cmds[] = "screen_set $name heartbeat off";
- $lcd_cmds[] = "screen_set $name name $name";
- $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
- $lcd_cmds[] = "widget_add $name title_wdgt string";
- $lcd_cmds[] = "widget_add $name text_wdgt scroller";
- $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Disk Use\"";
- break;
- case "scr_load":
- $lcd_cmds[] = "screen_add $name";
- $lcd_cmds[] = "screen_set $name heartbeat off";
- $lcd_cmds[] = "screen_set $name name $name";
- $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
- $lcd_cmds[] = "widget_add $name title_wdgt string";
- $lcd_cmds[] = "widget_add $name text_wdgt scroller";
- $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Load Averages\"";
- break;
- case "scr_states":
- $lcd_cmds[] = "screen_add $name";
- $lcd_cmds[] = "screen_set $name heartbeat off";
- $lcd_cmds[] = "screen_set $name name $name";
- $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
- $lcd_cmds[] = "widget_add $name title_wdgt string";
- $lcd_cmds[] = "widget_add $name text_wdgt scroller";
- $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Traffic States\"";
- break;
- case "scr_carp":
- $lcd_cmds[] = "screen_add $name";
- $lcd_cmds[] = "screen_set $name heartbeat off";
- $lcd_cmds[] = "screen_set $name name $name";
- $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
- $lcd_cmds[] = "widget_add $name title_wdgt string";
- $lcd_cmds[] = "widget_add $name text_wdgt scroller";
- $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ CARP State\"";
- break;
- case "scr_ipsec":
- $lcd_cmds[] = "screen_add $name";
- $lcd_cmds[] = "screen_set $name heartbeat off";
- $lcd_cmds[] = "screen_set $name name $name";
- $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
- $lcd_cmds[] = "widget_add $name title_wdgt string";
- $lcd_cmds[] = "widget_add $name text_wdgt scroller";
- $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ IPsec Tunnels\"";
- break;
- case "scr_slbd":
- $lcd_cmds[] = "screen_add $name";
- $lcd_cmds[] = "screen_set $name heartbeat off";
- $lcd_cmds[] = "screen_set $name name $name";
- $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
- $lcd_cmds[] = "widget_add $name title_wdgt string";
- $lcd_cmds[] = "widget_add $name text_wdgt scroller";
- $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Load Balancer\"";
- break;
- case "scr_interfaces":
- $lcd_cmds[] = "screen_add $name";
- $lcd_cmds[] = "screen_set $name heartbeat off";
- $lcd_cmds[] = "screen_set $name name $name";
- $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
- $lcd_cmds[] = "widget_add $name title_wdgt string";
- $lcd_cmds[] = "widget_add $name text_wdgt scroller";
- $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Interfaces\"";
- break;
- case "scr_mbuf":
- $lcd_cmds[] = "screen_add $name";
- $lcd_cmds[] = "screen_set $name heartbeat off";
- $lcd_cmds[] = "screen_set $name name $name";
- $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
- $lcd_cmds[] = "widget_add $name title_wdgt string";
- $lcd_cmds[] = "widget_add $name text_wdgt scroller";
- $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ MBuf Usage\"";
- break;
- case "scr_cpufrequency":
- $lcd_cmds[] = "screen_add $name";
- $lcd_cmds[] = "screen_set $name heartbeat off";
- $lcd_cmds[] = "screen_set $name name $name";
- $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
- $lcd_cmds[] = "widget_add $name title_wdgt string";
- $lcd_cmds[] = "widget_add $name text_wdgt scroller";
- $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ CPU Frequency\"";
- break;
- case "scr_traffic":
- $lcd_cmds[] = "screen_add $name";
- $lcd_cmds[] = "screen_set $name heartbeat off";
- $lcd_cmds[] = "screen_set $name name $name";
- $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
- $lcd_cmds[] = "widget_add $name title_wdgt string";
- $lcd_cmds[] = "widget_add $name text_wdgt string";
- break;
- }
- add_summary_declaration($lcd_cmds, $name);
- }
+}
+
+function outputled_carp() {
+ /* Returns the status of CARP for the box.
+ Assumes ALL CARP status are the same for all the intefaces.
+ -1 = CARP Disabled
+ 0 = CARP on Backup
+ 1 = CARP on Master */
+ global $g;
+ global $config;
+
+ if (is_array($config['virtualip']['vip'])) {
+ $carpint = 0;
+ foreach ($config['virtualip']['vip'] as $carp) {
+ if ($carp['mode'] != "carp") {
+ continue;
}
- }
- send_lcd_commands($lcd, $lcd_cmds);
- }
-
- function loop_status($lcd) {
- global $g;
- global $config;
- global $lcdproc_connect_errors;
- $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0];
- $lcdpanel_width = get_lcdpanel_width();
- $lcdpanel_height = get_lcdpanel_height();
- if(empty($g['product_name'])) {
- $g['product_name'] = "pfSense";
- }
-
- $refresh_frequency = get_lcdpanel_refresh_frequency();
- /* keep a counter to see how many times we can loop */
- $i = 1;
- while($i) {
- /* prepare the summary data */
- if ($lcdpanel_height >= "4") {
- $summary_states = split("/",get_pfstate());
- $lcd_summary_data = sprintf("%02d%% %02d%% %6d", cpu_usage(), mem_usage(), $summary_states[0]);
- if ($lcdpanel_width > "16") {
- $lcd_summary_data = $lcd_summary_data . sprintf(" %3d%%", get_cpufrequency_perc());
- }
- }
- else {
- $lcd_summary_data = "";}
-
- $lcd_cmds = array();
-
- /* initializes the widget counter */
- $widget_counter = 0;
-
- /* controls the output leds */
- if (outputled_enabled_CFontz633())
- {
- $led_output_value = 0;
- /* LED 1: Interface status */
- if (substr_count(get_interfaces_stats(), "Down") > 0 )
- {$led_output_value = $led_output_value + pow(2, 4);}
- else
- {$led_output_value = $led_output_value + pow(2, 0);}
- /* LED 2: CARP status */
- switch (outputled_carp())
- {
- case -1:/* CARP disabled */
- break;
- case 0: /* CARP on Backup */
- $led_output_value = $led_output_value + pow(2, 1);
+ $carp_int = find_carp_interface($carp['subnet']);
+ $status = get_carp_interface_status($carp_int);
+ switch($status) {
+ case "MASTER":
+ return 1;
break;
- case 1: /* CARP on Master */
- $led_output_value = $led_output_value + pow(2, 5);
- }
- /* LED 3: CPU Usage */
- if (cpu_usage() > 50)
- {$led_output_value = $led_output_value + pow(2, 6);}
- else
- {$led_output_value = $led_output_value + pow(2, 2);}
- /* LED 4: Gateway status */
- switch (outputled_gateway())
- {
- case -1:/* Gateways not configured */
- break;
- case 0: /* Gateway down or with issues */
- $led_output_value = $led_output_value + pow(2, 7);
+ case "BACKUP":
+ return 0;
break;
- case 1: /* All Gateways up */
- $led_output_value = $led_output_value + pow(2, 3);
- }
- /* Sends the command to the panel */
- $lcd_cmds[] = "output {$led_output_value}";
}
-
- /* process screens to display */
- foreach((array) $lcdproc_screens_config as $name => $screen) {
- if($screen != "on") {
- continue;
- }
+ }
+ } else {
+ return -1;
+ }
+}
+
+function outputled_gateway() {
+ /* Returns the status of the gateways.
+ -1 = No gateway defined
+ 0 = At least 1 gateway down or with issues
+ 1 = All gateway up */
+ global $g;
+ global $config;
+ $a_gateways = return_gateways_array();
+ $gateways_status = array();
+ $gateways_status = return_gateways_status(true);
+ foreach ($a_gateways as $gname => $gateway) {
+ if ($gateways_status[$gname]['status'] != "none") {
+ return 0;
+ }
+ }
+ return 1;
+}
+
+function get_traffic_stats(&$in_data, &$out_data){
+ global $config;
+ global $traffic_last_ugmt, $traffic_last_ifin, $traffic_last_ifout;
+ $lcdproc_screen_config = $config['installedpackages']['lcdprocscreens']['config'][0];
+ /* read the configured interface */
+ $ifnum = $lcdproc_screen_config['scr_traffic_interface'];
+ /* get the real interface name (code from ifstats.php)*/
+ $realif = get_real_interface($ifnum);
+ if (!$realif) {
+ $realif = $ifnum;
+ }
+ // Need for IPSec case interface.
+ /* get the interface stats (code from ifstats.php)*/
+ $ifinfo = pfSense_get_interface_stats($realif);
+ /* get the current time (code from ifstats.php)*/
+ $temp = gettimeofday();
+ $timing = (double)$temp["sec"] + (double)$temp["usec"] / 1000000.0;
+ /* calculate the traffic stats */
+ $deltatime = $timing - $traffic_last_ugmt;
+ $in_data = "IN: " . formatSpeedBits(((double)$ifinfo['inbytes']-$traffic_last_ifin)/$deltatime);
+ $out_data = "OUT: " . formatSpeedBits(((double)$ifinfo['outbytes']-$traffic_last_ifout)/$deltatime);
+ $traffic_last_ugmt = $timing;
+ $traffic_last_ifin = (double)$ifinfo['inbytes'];
+ $traffic_last_ifout = (double)$ifinfo['outbytes'];
+}
+
+function formatSpeedBits($speed) {
+ /* format speed in bits/sec, input: bytes/sec
+ Code from: graph.php ported to PHP */
+ if ($speed < 125000) {
+ return sprintf("%5.1f Kbps", $speed / 125);
+ }
+ if ($speed < 125000000) {
+ return sprintf("%5.1f Mbps", $speed / 125000);
+ }
+ return sprintf("%5.1f Gbps", $speed / 125000000);
+}
+
+function add_summary_declaration(&$lcd_cmds, $name) {
+ $lcdpanel_height = get_lcdpanel_height();
+ $lcdpanel_width = get_lcdpanel_width();
+ if ($lcdpanel_height >= "4") {
+ $lcd_cmds[] = "widget_add $name title_summary string";
+ $lcd_cmds[] = "widget_add $name text_summary string";
+ if ($lcdpanel_width > "16") {
+ $lcd_cmds[] = "widget_set $name title_summary 1 3 \"CPU MEM STATES FREQ\"";
+ } else {
+ $lcd_cmds[] = "widget_set $name title_summary 1 3 \"CPU MEM STATES\"";
+ }
+ }
+}
+
+function add_summary_values(&$lcd_cmds, $name, $lcd_summary_data) {
+ if ($lcd_summary_data != "") {
+ $lcd_cmds[] = "widget_set $name text_summary 1 4 \"{$lcd_summary_data}\"";
+ }
+}
+
+function build_interface($lcd) {
+ global $g;
+ global $config;
+ $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0];
+ $refresh_frequency = get_lcdpanel_refresh_frequency() * 8;
+
+ $lcd_cmds = array();
+ $lcd_cmds[] = "hello";
+ $lcd_cmds[] = "client_set name pfSense";
+
+ /* process screens to display */
+ if (is_array($lcdproc_screens_config)) {
+ foreach ($lcdproc_screens_config as $name => $screen) {
+ if ($screen == "on") {
switch($name) {
case "scr_version":
- $version = get_version();
- $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$version}\"";
- break;
+ $lcd_cmds[] = "screen_add $name";
+ $lcd_cmds[] = "screen_set $name heartbeat off";
+ $lcd_cmds[] = "screen_set $name name $name";
+ $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
+ $lcd_cmds[] = "widget_add $name title_wdgt string";
+ $lcd_cmds[] = "widget_add $name text_wdgt scroller";
+ $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"Welcome to\"";
+ break;
case "scr_time":
- $time = date("n/j/Y H:i");
- $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$time}\"";
+ $lcd_cmds[] = "screen_add $name";
+ $lcd_cmds[] = "screen_set $name heartbeat off";
+ $lcd_cmds[] = "screen_set $name name $name";
+ $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
+ $lcd_cmds[] = "widget_add $name title_wdgt string";
+ $lcd_cmds[] = "widget_add $name text_wdgt scroller";
+ $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Time\"";
break;
case "scr_uptime":
- $uptime = get_uptime_stats();
- $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$uptime}\"";
+ $lcd_cmds[] = "screen_add $name";
+ $lcd_cmds[] = "screen_set $name heartbeat off";
+ $lcd_cmds[] = "screen_set $name name $name";
+ $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
+ $lcd_cmds[] = "widget_add $name title_wdgt string";
+ $lcd_cmds[] = "widget_add $name text_wdgt scroller";
+ $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Uptime\"";
break;
case "scr_hostname":
- exec("/bin/hostname", $output, $ret);
- $hostname = $output[0];
- $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$hostname}\"";
+ $lcd_cmds[] = "screen_add $name";
+ $lcd_cmds[] = "screen_set $name heartbeat off";
+ $lcd_cmds[] = "screen_set $name name $name";
+ $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
+ $lcd_cmds[] = "widget_add $name title_wdgt string";
+ $lcd_cmds[] = "widget_add $name text_wdgt scroller";
+ $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Name\"";
break;
case "scr_system":
- $processor = cpu_usage();
- $memory = mem_usage();
- $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"CPU {$processor}%, Mem {$memory}%\"";
+ $lcd_cmds[] = "screen_add $name";
+ $lcd_cmds[] = "screen_set $name heartbeat off";
+ $lcd_cmds[] = "screen_set $name name $name";
+ $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
+ $lcd_cmds[] = "widget_add $name title_wdgt string";
+ $lcd_cmds[] = "widget_add $name text_wdgt scroller";
+ $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ System Stats\"";
break;
case "scr_disk":
- $disk = disk_usage();
- $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"Disk {$disk}%\"";
+ $lcd_cmds[] = "screen_add $name";
+ $lcd_cmds[] = "screen_set $name heartbeat off";
+ $lcd_cmds[] = "screen_set $name name $name";
+ $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
+ $lcd_cmds[] = "widget_add $name title_wdgt string";
+ $lcd_cmds[] = "widget_add $name text_wdgt scroller";
+ $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Disk Use\"";
break;
case "scr_load":
- $loadavg = get_loadavg_stats();
- $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$loadavg}\"";
+ $lcd_cmds[] = "screen_add $name";
+ $lcd_cmds[] = "screen_set $name heartbeat off";
+ $lcd_cmds[] = "screen_set $name name $name";
+ $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
+ $lcd_cmds[] = "widget_add $name title_wdgt string";
+ $lcd_cmds[] = "widget_add $name text_wdgt scroller";
+ $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Load Averages\"";
break;
case "scr_states":
- $states = get_pfstate();
- $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"Cur/Max {$states}\"";
+ $lcd_cmds[] = "screen_add $name";
+ $lcd_cmds[] = "screen_set $name heartbeat off";
+ $lcd_cmds[] = "screen_set $name name $name";
+ $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
+ $lcd_cmds[] = "widget_add $name title_wdgt string";
+ $lcd_cmds[] = "widget_add $name text_wdgt scroller";
+ $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Traffic States\"";
break;
case "scr_carp":
- $carp = get_carp_stats();
- $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$carp}\"";
+ $lcd_cmds[] = "screen_add $name";
+ $lcd_cmds[] = "screen_set $name heartbeat off";
+ $lcd_cmds[] = "screen_set $name name $name";
+ $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
+ $lcd_cmds[] = "widget_add $name title_wdgt string";
+ $lcd_cmds[] = "widget_add $name text_wdgt scroller";
+ $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ CARP State\"";
break;
case "scr_ipsec":
- $ipsec = get_ipsec_stats();
- $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$ipsec}\"";
+ $lcd_cmds[] = "screen_add $name";
+ $lcd_cmds[] = "screen_set $name heartbeat off";
+ $lcd_cmds[] = "screen_set $name name $name";
+ $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
+ $lcd_cmds[] = "widget_add $name title_wdgt string";
+ $lcd_cmds[] = "widget_add $name text_wdgt scroller";
+ $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ IPsec Tunnels\"";
break;
case "scr_slbd":
- $slbd = get_slbd_stats();
- $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$slbd}\"";
+ $lcd_cmds[] = "screen_add $name";
+ $lcd_cmds[] = "screen_set $name heartbeat off";
+ $lcd_cmds[] = "screen_set $name name $name";
+ $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
+ $lcd_cmds[] = "widget_add $name title_wdgt string";
+ $lcd_cmds[] = "widget_add $name text_wdgt scroller";
+ $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Load Balancer\"";
break;
case "scr_interfaces":
- $interfaces = get_interfaces_stats();
- $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$interfaces}\"";
+ $lcd_cmds[] = "screen_add $name";
+ $lcd_cmds[] = "screen_set $name heartbeat off";
+ $lcd_cmds[] = "screen_set $name name $name";
+ $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
+ $lcd_cmds[] = "widget_add $name title_wdgt string";
+ $lcd_cmds[] = "widget_add $name text_wdgt scroller";
+ $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ Interfaces\"";
break;
case "scr_mbuf":
- $mbufstats = get_mbuf_stats();
- $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$mbufstats}\"";
+ $lcd_cmds[] = "screen_add $name";
+ $lcd_cmds[] = "screen_set $name heartbeat off";
+ $lcd_cmds[] = "screen_set $name name $name";
+ $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
+ $lcd_cmds[] = "widget_add $name title_wdgt string";
+ $lcd_cmds[] = "widget_add $name text_wdgt scroller";
+ $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ MBuf Usage\"";
break;
case "scr_cpufrequency":
- $cpufreq = get_cpufrequency();
- $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$cpufreq}\"";
+ $lcd_cmds[] = "screen_add $name";
+ $lcd_cmds[] = "screen_set $name heartbeat off";
+ $lcd_cmds[] = "screen_set $name name $name";
+ $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
+ $lcd_cmds[] = "widget_add $name title_wdgt string";
+ $lcd_cmds[] = "widget_add $name text_wdgt scroller";
+ $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ CPU Frequency\"";
break;
case "scr_traffic":
- get_traffic_stats($in_data, $out_data);
- $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"{$in_data}\"";
- $lcd_cmds[] = "widget_set $name text_wdgt 1 2 \"{$out_data}\"";
- break;
- }
- if ($name != "scr_traffic_interface") {
- $widget_counter++;
- add_summary_values($lcd_cmds, $name, $lcd_summary_data);
+ $lcd_cmds[] = "screen_add $name";
+ $lcd_cmds[] = "screen_set $name heartbeat off";
+ $lcd_cmds[] = "screen_set $name name $name";
+ $lcd_cmds[] = "screen_set $name duration $refresh_frequency";
+ $lcd_cmds[] = "widget_add $name title_wdgt string";
+ $lcd_cmds[] = "widget_add $name text_wdgt string";
+ break;
}
- }
- if (send_lcd_commands($lcd, $lcd_cmds)) {
- $lcdproc_connect_errors = 0; // Reset the error counter
+ add_summary_declaration($lcd_cmds, $name);
}
- else { //an error occurred
- return;
+ }
+ }
+ send_lcd_commands($lcd, $lcd_cmds);
+}
+
+function loop_status($lcd) {
+ global $g;
+ global $config;
+ global $lcdproc_connect_errors;
+ $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0];
+ $lcdpanel_width = get_lcdpanel_width();
+ $lcdpanel_height = get_lcdpanel_height();
+ if (empty($g['product_name'])) {
+ $g['product_name'] = "pfSense";
+ }
+
+ $refresh_frequency = get_lcdpanel_refresh_frequency();
+ /* keep a counter to see how many times we can loop */
+ $i = 1;
+ while ($i) {
+ /* prepare the summary data */
+ if ($lcdpanel_height >= "4") {
+ $summary_states = explode("/", get_pfstate());
+ $lcd_summary_data = sprintf("%02d%% %02d%% %6d", cpu_usage(), mem_usage(), $summary_states[0]);
+ if ($lcdpanel_width > "16") {
+ $lcd_summary_data = $lcd_summary_data . sprintf(" %3d%%", get_cpufrequency_perc());
}
- if (($refresh_frequency * $widget_counter) > 5) {
- sleep(5);
+ } else {
+ $lcd_summary_data = "";
+ }
+
+ $lcd_cmds = array();
+
+ /* initializes the widget counter */
+ $widget_counter = 0;
+
+ /* controls the output leds */
+ if (outputled_enabled_CFontz633()) {
+ $led_output_value = 0;
+ /* LED 1: Interface status */
+ if (substr_count(get_interfaces_stats(), "Down") > 0 ) {
+ $led_output_value = $led_output_value + pow(2, 4);
+ } else {
+ $led_output_value = $led_output_value + pow(2, 0);
}
- else {
- sleep($refresh_frequency * $widget_counter);
+ /* LED 2: CARP status */
+ switch (outputled_carp()) {
+ /* CARP disabled */
+ case -1:
+ break;
+ /* CARP on Backup */
+ case 0:
+ $led_output_value = $led_output_value + pow(2, 1);
+ break;
+ /* CARP on Master */
+ case 1:
+ $led_output_value = $led_output_value + pow(2, 5);
}
- $i++;
+ /* LED 3: CPU Usage */
+ if (cpu_usage() > 50) {
+ $led_output_value = $led_output_value + pow(2, 6);
+ } else {
+ $led_output_value = $led_output_value + pow(2, 2);
+ }
+ /* LED 4: Gateway status */
+ switch (outputled_gateway()) {
+ /* Gateways not configured */
+ case -1:
+ break;
+ /* Gateway down or with issues */
+ case 0:
+ $led_output_value = $led_output_value + pow(2, 7);
+ break;
+ /* All Gateways up */
+ case 1:
+ $led_output_value = $led_output_value + pow(2, 3);
+ }
+ /* Sends the command to the panel */
+ $lcd_cmds[] = "output {$led_output_value}";
+ }
+
+ /* process screens to display */
+ foreach ((array) $lcdproc_screens_config as $name => $screen) {
+ if ($screen != "on") {
+ continue;
+ }
+ switch($name) {
+ case "scr_version":
+ $version = get_version();
+ $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$version}\"";
+ break;
+ case "scr_time":
+ $time = date("n/j/Y H:i");
+ $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$time}\"";
+ break;
+ case "scr_uptime":
+ $uptime = get_uptime_stats();
+ $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$uptime}\"";
+ break;
+ case "scr_hostname":
+ exec("/bin/hostname", $output, $ret);
+ $hostname = $output[0];
+ $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$hostname}\"";
+ break;
+ case "scr_system":
+ $processor = cpu_usage();
+ $memory = mem_usage();
+ $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"CPU {$processor}%, Mem {$memory}%\"";
+ break;
+ case "scr_disk":
+ $disk = disk_usage();
+ $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"Disk {$disk}%\"";
+ break;
+ case "scr_load":
+ $loadavg = get_loadavg_stats();
+ $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$loadavg}\"";
+ break;
+ case "scr_states":
+ $states = get_pfstate();
+ $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"Cur/Max {$states}\"";
+ break;
+ case "scr_carp":
+ $carp = get_carp_stats();
+ $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$carp}\"";
+ break;
+ case "scr_ipsec":
+ $ipsec = get_ipsec_stats();
+ $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$ipsec}\"";
+ break;
+ case "scr_slbd":
+ $slbd = get_slbd_stats();
+ $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$slbd}\"";
+ break;
+ case "scr_interfaces":
+ $interfaces = get_interfaces_stats();
+ $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$interfaces}\"";
+ break;
+ case "scr_mbuf":
+ $mbufstats = get_mbuf_stats();
+ $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$mbufstats}\"";
+ break;
+ case "scr_cpufrequency":
+ $cpufreq = get_cpufrequency();
+ $lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 4 \"{$cpufreq}\"";
+ break;
+ case "scr_traffic":
+ get_traffic_stats($in_data, $out_data);
+ $lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"{$in_data}\"";
+ $lcd_cmds[] = "widget_set $name text_wdgt 1 2 \"{$out_data}\"";
+ break;
+ }
+ if ($name != "scr_traffic_interface") {
+ $widget_counter++;
+ add_summary_values($lcd_cmds, $name, $lcd_summary_data);
+ }
+ }
+ if (send_lcd_commands($lcd, $lcd_cmds)) {
+ $lcdproc_connect_errors = 0; // Reset the error counter
+ } else {
+ //an error occurred
+ return;
}
+ if (($refresh_frequency * $widget_counter) > 5) {
+ sleep(5);
+ } else {
+ sleep($refresh_frequency * $widget_counter);
+ }
+ $i++;
}
- /* Initialize the wan traffic counters */
- $traffic_last_ugmt = 0;
- $traffic_last_ifin = 0;
- $traffic_last_ifout = 0;
- /* Initialize the global error counter */
- $lcdproc_connect_errors = 0;
- $lcdproc_max_connect_errors = 3;
- /* Connect to the LCDd port and interface with the LCD */
- while ($lcdproc_connect_errors <= $lcdproc_max_connect_errors)
- {
- lcdproc_warn("Start client procedure. Error counter: ($lcdproc_connect_errors)");
- sleep(1);
- $lcd = fsockopen(LCDPROC_HOST, LCDPROC_PORT, $errno, $errstr, 10);
- stream_set_timeout($lcd, 0 , 25000); // Sets the socket timeout as 25ms
- if (!$lcd) {
- lcdproc_warn("Failed to connect to LCDd process $errstr ($errno)");
- $lcdproc_connect_errors++;
- } else {
- /* Allow the script to run forever (0) */
- set_time_limit(0);
- build_interface($lcd);
- loop_status($lcd);
- fclose($lcd);
- }
- }
- if ($lcdproc_connect_errors >= $lcdproc_max_connect_errors)
- {
- lcdproc_warn("Too many errors, the client ends.");
+}
+
+/* Initialize the wan traffic counters */
+$traffic_last_ugmt = 0;
+$traffic_last_ifin = 0;
+$traffic_last_ifout = 0;
+/* Initialize the global error counter */
+$lcdproc_connect_errors = 0;
+$lcdproc_max_connect_errors = 3;
+/* Connect to the LCDd port and interface with the LCD */
+while ($lcdproc_connect_errors <= $lcdproc_max_connect_errors) {
+ lcdproc_warn("Start client procedure. Error counter: ($lcdproc_connect_errors)");
+ sleep(1);
+ $lcd = fsockopen(LCDPROC_HOST, LCDPROC_PORT, $errno, $errstr, 10);
+ stream_set_timeout($lcd, 0 , 25000); // Sets the socket timeout as 25ms
+ if (!$lcd) {
+ lcdproc_warn("Failed to connect to LCDd process $errstr ($errno)");
+ $lcdproc_connect_errors++;
+ } else {
+ /* Allow the script to run forever (0) */
+ set_time_limit(0);
+ build_interface($lcd);
+ loop_status($lcd);
+ fclose($lcd);
}
+}
+if ($lcdproc_connect_errors >= $lcdproc_max_connect_errors) {
+ lcdproc_warn("Too many errors, the client ends.");
+}
?>
diff --git a/config/lcdproc-dev/lcdproc_screens.xml b/config/lcdproc-dev/lcdproc_screens.xml
index 1e4e0857..c3ba7aa1 100644
--- a/config/lcdproc-dev/lcdproc_screens.xml
+++ b/config/lcdproc-dev/lcdproc_screens.xml
@@ -1,8 +1,51 @@
<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd">
+<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?>
<packagegui>
+ <copyright>
+<![CDATA[
+/* $Id$ */
+/* ====================================================================================== */
+/*
+ lcdproc_screens.xml
+ part of pfSense (https://www.pfSense.org/)
+ Copyright (C) 2007-2009 Seth Mos <seth.mos@dds.nl>
+ Copyright (C) 2009 Scott Ullrich
+ Copyright (C) 2011 Michele Di Maria
+ Copyright (C) 2015 ESF, LLC
+ 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.
+*/
+/* ====================================================================================== */
+ ]]>
+ </copyright>
<title>Services: LCDproc: Screens</title>
<name>lcdproc_screens</name>
- <version>0.9.12</version>
+ <version>0.9.13</version>
<savetext>Save</savetext>
<include_file>/usr/local/pkg/lcdproc.inc</include_file>
<tabs>
@@ -18,7 +61,7 @@
</tabs>
<menu>
<name>LCDproc</name>
- <tooltiptext>Set LCDproc settings such as display driver and com port</tooltiptext>
+ <tooltiptext>Set LCDproc settings such as display driver and COM port.</tooltiptext>
<section>Services</section>
<url>/pkg_edit.php?xml=lcdproc.xml&amp;id=0</url>
</menu>
@@ -27,7 +70,7 @@
<fielddescr>Enable Version</fielddescr>
<fieldname>scr_version</fieldname>
<type>checkbox</type>
- </field>
+ </field>
<field>
<fielddescr>Enable Time</fielddescr>
<fieldname>scr_time</fieldname>
@@ -87,7 +130,7 @@
<fielddescr>Enable Mbuf</fielddescr>
<fieldname>scr_mbuf</fieldname>
<type>checkbox</type>
- </field>
+ </field>
<field>
<fielddescr>Enable CPU Frequency</fielddescr>
<fieldname>scr_cpufrequency</fieldname>
@@ -103,11 +146,8 @@
<fieldname>scr_traffic_interface</fieldname>
<type>interfaces_selection</type>
<description>If Interface Traffic is enabled, here you specify which interface to monitor</description>
- </field>
+ </field>
</fields>
- <custom_php_validation_command>
- validate_form_lcdproc_screens($_POST, $input_errors);
- </custom_php_validation_command>
<custom_php_resync_config_command>
sync_package_lcdproc_screens();
</custom_php_resync_config_command>