diff options
-rw-r--r-- | config/lcdproc-dev/lcdproc.inc | 58 | ||||
-rw-r--r-- | config/lcdproc-dev/lcdproc.xml | 41 | ||||
-rw-r--r-- | config/lcdproc-dev/lcdproc_client.php | 104 | ||||
-rw-r--r-- | config/lcdproc-dev/lcdproc_screens.xml | 2 |
4 files changed, 170 insertions, 35 deletions
diff --git a/config/lcdproc-dev/lcdproc.inc b/config/lcdproc-dev/lcdproc.inc index 14e5dc73..cfea30f3 100644 --- a/config/lcdproc-dev/lcdproc.inc +++ b/config/lcdproc-dev/lcdproc.inc @@ -240,18 +240,38 @@ $config_text .= "DriverPath=/usr/local/lib/lcdproc/\n"; $config_text .= "GoodBye=\"Thanks for using\"\n"; $config_text .= "GoodBye=\" {$g['product_name']} \"\n"; - /* FIXME: Specific to the pyramid project */ - $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"; - /* FIXME: pyramid test menu */ - $config_text .= "[menu]\n"; - $config_text .= "MenuKey=Escape\n"; - $config_text .= "EnterKey=Enter\n"; - $config_text .= "UpKey=Up\n"; - $config_text .= "DownKey=Down\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": @@ -338,20 +358,6 @@ $config_text .= "DelayBus=true\n"; $config_text .= "Size={$lcdproc_config['size']}\n"; break; - case "hd44780 fast": - $config_text .= "[{$lcdproc_config['driver']}]\n"; - $config_text .= "ConnectionType=lcd2usb\n"; - $config_text .= "Charmap=hd44780_default\n"; - $config_text .= "Keypad=yes\n"; - $config_text .= set_lcd_value("contrast", 1000, 850); - $config_text .= set_lcd_value("brightness", 1000, 800); - $config_text .= set_lcd_value("offbrightness", 1000, 0); - $config_text .= "Backlight=yes\n"; - $config_text .= "OutputPort=no\n"; - $config_text .= "DelayMult=1\n"; - $config_text .= "DelayBus=no\n"; - $config_text .= "Size={$lcdproc_config['size']}\n"; - break; case "icp_a106": $config_text .= "[{$lcdproc_config['driver']}]\n"; $config_text .= "Device={$realport}\n"; diff --git a/config/lcdproc-dev/lcdproc.xml b/config/lcdproc-dev/lcdproc.xml index fcb16997..77c11584 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.6</title> + <title>Services: LCDproc 0.5.4 pkg v. 0.7</title> <name>lcdproc</name> - <version>0.5.4 pkg v. 0.6</version> + <version>0.5.4 pkg v. 0.7</version> <savetext>Save</savetext> <include_file>/usr/local/pkg/lcdproc.inc</include_file> <tabs> @@ -204,10 +204,6 @@ <name>hd44780</name> </option> <option> - <value>hd44780 fast</value> - <name>hd44780 fast</name> - </option> - <option> <value>icp_a106</value> <name>icp_a106</name> </option> @@ -546,6 +542,39 @@ </option> </options> <default_value>-1</default_value> + </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> + <type>select</type> + <options> + <option> + <value>default</value> + <name>Default</name> + </option> + <option> + <value>on</value> + <name>On</name> + </option> + <option> + <value>off</value> + <name>Off</name> + </option> + </options> + <default_value>default</default_value> + </field> + <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. <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 < 50, red > 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> </fields> <custom_php_command_before_form> diff --git a/config/lcdproc-dev/lcdproc_client.php b/config/lcdproc-dev/lcdproc_client.php index 52656fdc..aec8d8c3 100644 --- a/config/lcdproc-dev/lcdproc_client.php +++ b/config/lcdproc-dev/lcdproc_client.php @@ -455,6 +455,71 @@ } } + 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 + {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; + } + } + } 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; + $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; @@ -673,7 +738,7 @@ $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 = "";} @@ -682,6 +747,42 @@ /* 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, 0);} + else + {$led_output_value = $led_output_value + pow(2, 4);} + /* LED 2: CARP status */ + switch (outputled_carp()) + { + case -1:/* CARP disabled */ + case 0: /* CARP on Backup */ + {$led_output_value = $led_output_value + pow(2, 1);} + 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, 2);} + else + {$led_output_value = $led_output_value + pow(2, 6);} + /* LED 4: Gateway status */ + switch (outputled_gateway()) + { + case -1:/* Gateways not configured */ + case 0: /* Gateway down or with issues */ + {$led_output_value = $led_output_value + 2 ^ 3;} + case 1: /* All Gateways up */ + {$led_output_value = $led_output_value + 2 ^ 7;} + } + /* Sends the command to the panel */ + $lcd_cmds[] = "output {$led_output_value}"; + } /* process screens to display */ foreach((array) $lcdproc_screens_config as $name => $screen) { @@ -767,7 +868,6 @@ $lcd_cmds[] = "widget_set $name text_wdgt 1 2 \"{$out_data}\""; break; } - add_summary_values($lcd_cmds, $name, $lcd_summary_data, $lcdpanel_width); if ($name != "scr_traffic_interface") { $widget_counter++; add_summary_values($lcd_cmds, $name, $lcd_summary_data, $lcdpanel_width); diff --git a/config/lcdproc-dev/lcdproc_screens.xml b/config/lcdproc-dev/lcdproc_screens.xml index 0c967dff..9f98ea59 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.4 pkg v. 0.6</version> + <version>0.5.4 pkg v. 0.7</version> <savetext>Save</savetext> <include_file>/usr/local/pkg/lcdproc.inc</include_file> <tabs> |