aboutsummaryrefslogtreecommitdiffstats
path: root/config/lcdproc-dev
diff options
context:
space:
mode:
Diffstat (limited to 'config/lcdproc-dev')
-rw-r--r--config/lcdproc-dev/lcdproc.inc156
-rw-r--r--config/lcdproc-dev/lcdproc.xml4
-rw-r--r--config/lcdproc-dev/lcdproc_client.php106
-rw-r--r--config/lcdproc-dev/lcdproc_screens.xml15
4 files changed, 235 insertions, 46 deletions
diff --git a/config/lcdproc-dev/lcdproc.inc b/config/lcdproc-dev/lcdproc.inc
index d4ff92fa..75ddb475 100644
--- a/config/lcdproc-dev/lcdproc.inc
+++ b/config/lcdproc-dev/lcdproc.inc
@@ -49,7 +49,7 @@
if((int)exec('pgrep LCDd | wc -l') > 0)
return true;
return false;
- }
+ }
function lcdproc_write_config($file, $text) {
$handle = fopen($file, 'w');
@@ -75,16 +75,16 @@
function before_form_lcdproc($pkg) {
global $config;
- config_lock();
-
+ config_lock();
+
config_unlock();
}
function before_form_lcdproc_screens($pkg) {
global $config;
- config_lock();
-
+ config_lock();
+
config_unlock();
}
@@ -149,6 +149,9 @@
case "20x4":
continue;
break;
+ case "40x2":
+ continue;
+ break;
default:
$input_errors[] = "The chosen display size is not valid";
break;
@@ -166,7 +169,9 @@
global $g;
global $config;
global $input_errors;
-
+
+ /* I just stop the package */
+ lcdproc_action('stop');
config_lock();
$lcdproc_config = $config['installedpackages']['lcdproc']['config'][0];
@@ -198,6 +203,7 @@
break;
default:
lcdproc_warn("The selected com port is not valid!");
+ config_unlock();
return;
}
@@ -228,12 +234,12 @@
$config_text .= "DownKey=Down\n";
/* lcdproc default driver definitions */
- switch($lcdproc_config[driver]) {
+ switch($lcdproc_config[driver]) {
case "bayrad":
$config_text .= "[{$lcdproc_config['driver']}]\n";
$config_text .= "Device={$realport}\n";
$config_text .= "Speed=9600\n";
- break;
+ break;
case "CFontz":
$config_text .= "[{$lcdproc_config['driver']}]\n";
$config_text .= "Device={$realport}\n";
@@ -292,6 +298,18 @@
$config_text .= "OffBrightness=0\n";
$config_text .= "Brightness=500\n";
break;
+ case "EyeboxOne":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= "Backlight=yes\n";
+ $config_text .= "Speed=19200\n";
+ break;
+ case "glk":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= "Contrast=560\n";
+ $config_text .= "Speed=19200\n";
+ break;
case "hd44780":
$config_text .= "[{$lcdproc_config['driver']}]\n";
$config_text .= "driverpath=/usr/local/lib/lcdproc/\n";
@@ -307,13 +325,78 @@
$config_text .= "DelayMult=1\n";
$config_text .= "DelayBus=true\n";
$config_text .= "Size={$lcdproc_config['size']}\n";
- break;
+ 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 .= "Brightness=255\n";
+ $config_text .= "Speed=9600\n";
+ $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 .= "Brightness=1000\n";
+ $config_text .= "OffBrightness=0\n";
+ break;
+ case "ms6931":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= "Brightness=255\n";
+ $config_text .= "Reboot=no\n";
+ break;
+ case "mtc_s16209x":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= "Brightness=255\n";
+ $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 .= "Contrast=480\n";
+ $config_text .= "Type=lcd\n";
+ $config_text .= "hasAdjustableBacklight=yes\n";
+ $config_text .= "Reboot=no\n";
+ $config_text .= "Brightness=1000\n";
+ $config_text .= "OffBrightness=0\n";
+ $config_text .= "Speed=19200\n";
+ 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;
+ break;
+ case "NoritakeVFD":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= "Size={$lcdproc_config['size']}\n";
+ $config_text .= "Brightness=1000\n";
+ $config_text .= "OffBrightness=0\n";
+ $config_text .= "Speed=9600\n";
+ $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";
@@ -336,16 +419,48 @@
$config_text .= "Device={$realport}\n";
$config_text .= "Size={$lcdproc_config['size']}\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";
+ $config_text .= "Speed=9600\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 .= "Brightness=1000\n";
+ $config_text .= "OffBrightness=0\n";
+ $config_text .= "Speed=9600\n";
+ $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 .= "Edition=2\n";
$config_text .= "Contrast=200\n";
- $config_text .= "Brightness=480\n";
+ $config_text .= "Brightness=480\n";
$config_text .= "Speed=19200\n";
break;
+ case "sli":
+ $config_text .= "[{$lcdproc_config['driver']}]\n";
+ $config_text .= "Device={$realport}\n";
+ $config_text .= "Speed=9600\n";
+ break;
default:
lcdproc_warn("The chosen lcdproc driver is not a valid choice");
unset($lcdproc_config[driver]);
@@ -369,13 +484,13 @@ EOD;
/* generate rc file start and stop */
$stop = <<<EOD
-if [ `ps auxw |awk '/LCD[d]/ {print $2}'| wc -l` != 0 ]; then
- ps auxw |awk '/LCD[d]/ {print $2}'|xargs kill
- sleep 1
-fi
if [ `ps auxw |awk '/lcdclient.s[h]/ {print $2}'| wc -l` != 0 ]; then
ps auxw |awk '/lcdclient.s[h]/ {print $2}'|xargs kill
- sleep 1
+ sleep 1
+fi
+if [ `ps auxw |awk '/LCD[d]/ {print $2}'| wc -l` != 0 ]; then
+ ps auxw |awk '/LCD[d]/ {print $2}'|xargs kill
+ sleep 1
fi
EOD;
@@ -394,11 +509,12 @@ EOD;
));
conf_mount_ro();
- /* or restart lcdproc if settings were changed */
- if(lcdproc_running($_POST['comport'])) {
+ /* or restart lcdproc if settings were changed
+ Removed because of issues during reinstall.
+ if(lcdproc_running()) {
lcdproc_notice("Restarting service lcdproc");
lcdproc_action('restart');
- }
+ } */
}
if((! $lcdproc_config['driver']) || ($lcdproc_config['comport'] == "none")) {
diff --git a/config/lcdproc-dev/lcdproc.xml b/config/lcdproc-dev/lcdproc.xml
index 16fd45b0..85e4ca23 100644
--- a/config/lcdproc-dev/lcdproc.xml
+++ b/config/lcdproc-dev/lcdproc.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<packagegui>
- <title>Services: LCDproc 0.5.4 pkg v. 0.1</title>
+ <title>Services: LCDproc 0.5.4 pkg v. 0.3</title>
<name>lcdproc</name>
- <version>0.5.4 pkg v. 0.2</version>
+ <version>0.5.4 pkg v. 0.3</version>
<savetext>Save</savetext>
<include_file>/usr/local/pkg/lcdproc.inc</include_file>
<tabs>
diff --git a/config/lcdproc-dev/lcdproc_client.php b/config/lcdproc-dev/lcdproc_client.php
index 5c0edb77..52656fdc 100644
--- a/config/lcdproc-dev/lcdproc_client.php
+++ b/config/lcdproc-dev/lcdproc_client.php
@@ -32,8 +32,9 @@
*/
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 = "";
@@ -70,25 +71,12 @@
return $memUsage;
}
- /*function array_combine($arr1, $arr2) {
- $out = array();
-
- $arr1 = array_values($arr1);
- $arr2 = array_values($arr2);
-
- foreach($arr1 as $key1 => $value1) {
- $out[(string)$value1] = $arr2[$key1];
- }
-
- return $out;
- }*/
-
/* Calculates non-idle CPU time and returns as a percentage */
function cpu_usage() {
- $duration = 1;
+ $duration = 250000;
$diff = array('user', 'nice', 'sys', 'intr', 'idle');
$cpuTicks = array_combine($diff, explode(" ", `/sbin/sysctl -n kern.cp_time`));
- sleep($duration);
+ usleep($duration);
$cpuTicks2 = array_combine($diff, explode(" ", `/sbin/sysctl -n kern.cp_time`));
$totalStart = array_sum($cpuTicks);
@@ -157,6 +145,19 @@
$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;
@@ -454,6 +455,41 @@
}
}
+ 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("%3d.1 Kbps", $speed / 125);}
+ if ($speed < 125000000)
+ {return sprintf("%3d.1 Mbps", $speed / 125000);}
+ // else
+ return sprintf("%3d.1 Gbps", $speed / 125000000);
+ }
+
function add_summary_declaration(&$lcd_cmds, $name) {
$lcdpanel_height = get_lcdpanel_height();
if ($lcdpanel_height >= "4")
@@ -466,7 +502,10 @@
function add_summary_values(&$lcd_cmds, $name, $lcd_summary_data, $lcdpanel_width) {
if ($lcd_summary_data != "")
{
- $lcd_cmds[] = "widget_set $name title_summary 1 3 $lcdpanel_width 3 h 2 \"CPU MEM STATES\"";
+ if ($lcdpanel_width > "16")
+ {$lcd_cmds[] = "widget_set $name title_summary 1 3 $lcdpanel_width 3 h 2 \"CPU MEM STATES FREQ\"";}
+ else
+ {$lcd_cmds[] = "widget_set $name title_summary 1 3 $lcdpanel_width 3 h 2 \"CPU MEM STATES\"";}
$lcd_cmds[] = "widget_set $name text_summary 1 4 $lcdpanel_width 4 h 2 \"{$lcd_summary_data}\"";
}
}
@@ -597,7 +636,15 @@
$lcd_cmds[] = "screen_set $name duration $refresh_frequency";
$lcd_cmds[] = "widget_add $name title_wdgt string";
$lcd_cmds[] = "widget_add $name text_wdgt scroller";
- break;
+ 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);
}
@@ -615,6 +662,7 @@
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;
@@ -622,7 +670,10 @@
/* 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]);
+ $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 = "";}
@@ -710,16 +761,27 @@
$lcd_cmds[] = "widget_set $name title_wdgt 1 1 \"+ CPU Frequency\"";
$lcd_cmds[] = "widget_set $name text_wdgt 1 2 $lcdpanel_width 2 h 2 \"{$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;
}
add_summary_values($lcd_cmds, $name, $lcd_summary_data, $lcdpanel_width);
- $widget_counter++;
+ if ($name != "scr_traffic_interface") {
+ $widget_counter++;
+ add_summary_values($lcd_cmds, $name, $lcd_summary_data, $lcdpanel_width);
+ }
}
send_lcd_commands($lcd, $lcd_cmds);
sleep($refresh_frequency * $widget_counter);
$i++;
}
}
-
+ /* Initialize the wan traffic counters */
+ $traffic_last_ugmt = 0;
+ $traffic_last_ifin = 0;
+ $traffic_last_ifout = 0;
/* Connect to the LCDd port and interface with the LCD */
$lcd = fsockopen(LCDPROC_HOST, LCDPROC_PORT, $errno, $errstr, 10);
if (!$lcd) {
@@ -730,4 +792,4 @@
/* loop exited? Close fd and wait for the script to kick in again */
fclose($lcd);
}
-?>
+?> \ No newline at end of file
diff --git a/config/lcdproc-dev/lcdproc_screens.xml b/config/lcdproc-dev/lcdproc_screens.xml
index e0597d58..acde02ca 100644
--- a/config/lcdproc-dev/lcdproc_screens.xml
+++ b/config/lcdproc-dev/lcdproc_screens.xml
@@ -2,7 +2,7 @@
<packagegui>
<title>Services: LCDproc: Screens</title>
<name>lcdproc_screens</name>
- <version>0.5.2_1-p9</version>
+ <version>0.5.4 pkg v. 0.3</version>
<savetext>Save</savetext>
<include_file>/usr/local/pkg/lcdproc.inc</include_file>
<tabs>
@@ -92,7 +92,18 @@
<fielddescr>Enable CPU Frequency</fielddescr>
<fieldname>scr_cpufrequency</fieldname>
<type>checkbox</type>
- </field>
+ </field>
+ <field>
+ <fielddescr>Enable Interface Traffic</fielddescr>
+ <fieldname>scr_traffic</fieldname>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr> > interface selected</fielddescr>
+ <fieldname>scr_traffic_interface</fieldname>
+ <type>interfaces_selection</type>
+ <description>If Interface Traffic is enabled, here you specify which interface to monitor</description>
+ </field>
</fields>
<custom_php_command_before_form>
before_form_lcdproc_screens(&amp;$pkg);