From a2b3c8ca6bdbaadf032513d354c3c2658e49fa28 Mon Sep 17 00:00:00 2001 From: jim-p Date: Wed, 10 Aug 2011 16:32:07 -0400 Subject: Add gwled package that lets you use LED2/3 to show a gateway's status. --- config/gwled/gwled.inc | 70 +++++++++++++++++++++++++++++++++++++++++++++++ config/gwled/gwled.php | 18 ++++++++++++ config/gwled/gwled.xml | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 162 insertions(+) create mode 100644 config/gwled/gwled.inc create mode 100644 config/gwled/gwled.php create mode 100644 config/gwled/gwled.xml (limited to 'config') diff --git a/config/gwled/gwled.inc b/config/gwled/gwled.inc new file mode 100644 index 00000000..35038034 --- /dev/null +++ b/config/gwled/gwled.inc @@ -0,0 +1,70 @@ + 0); +} + +function sync_package_gwled() { + global $config; + $gwled_config = $config['installedpackages']['gwled']['config'][0]; + /* kill all instances of gwled */ + if(gwled_running()) { + gwled_stop(); + } + gwled_start(); +} + +function gwled_start() { + global $config; + $gwled_config = $config['installedpackages']['gwled']['config'][0]; + if (!($gwled_config['enable'])) + return; + + if (($gwled_config['enable_led2']) && ($gwled_config['gw_led2']) + || ($gwled_config['enable_led3']) && ($gwled_config['gw_led3'])) + mwexec("/usr/local/bin/minicron 30 /var/run/gwled.pid /usr/local/bin/gwled.php"); +} + +function gwled_stop() { + exec("/bin/pkill -9 -f gwled"); +} + +function validate_form_gwled($post, $input_errors) { + /* Make sure both aren't using the same interface */ + if (($post['gw_led2']) && ($post['gw_led3']) && + (($post['enable_led2']) && ($post['enable_led3'])) && + ($post['gw_led2'] == $post['gw_led3'])) + $input_errors[] = 'You cannot set two LEDs for a single gateway. Please choose seperate interfaces.'; +} + +function gwled_get_gateways() { + $gateways = return_gateways_array(); + + foreach ($gateways as $gateway) { + $tmp["name"] = "{$gateway['name']} (Monitor: {$gateway['monitor']})"; + $tmp["value"] = $gateway['name']; + $gws[] = $tmp; + } + return $gws; +} + +function gwled_set_status($gateway, $led) { + $a_gateways = return_gateways_array(); + $gateways_status = array(); + $gateways_status = return_gateways_status(true); + if ($gateways_status[$gateway]) { + $status = $gateways_status[$gateway]['status']; + if (stristr($status, "down")) + led_blink($led, "veryfast"); + elseif (stristr($status, "loss")) + led_blink($led, "fast"); + elseif (stristr($status, "delay")) + led_blink($led, "medium"); + elseif ($status == "none") + led_on($led); + } else + led_on($led); +} + +?> diff --git a/config/gwled/gwled.php b/config/gwled/gwled.php new file mode 100644 index 00000000..efcb73dd --- /dev/null +++ b/config/gwled/gwled.php @@ -0,0 +1,18 @@ +#!/usr/local/bin/php -q + diff --git a/config/gwled/gwled.xml b/config/gwled/gwled.xml new file mode 100644 index 00000000..7388230c --- /dev/null +++ b/config/gwled/gwled.xml @@ -0,0 +1,74 @@ + + + Interfaces: Gateway Status LEDs + gwled + 20110810 + Save + /usr/local/pkg/gwled.inc + + Gateway Status LEDs + Assign LEDs to indicate Gateway status. +
Interfaces
+ /pkg_edit.php?xml=gwled.xml&id=0 +
+ + http://www.pfsense.org/packages/config/gwled/gwled.inc + /usr/local/pkg/ + 0644 + + + /usr/local/bin/ + 0755 + http://www.pfsense.com/packages/config/gwled/gwled.php + + + gwled + gwled.sh + gwled + + + + Enable gwled + enable + checkbox + enable_led2,enable_led3,gw_led2,gw_led3 + if this is enabled, it will use LED #2 and #3 to + indicate network activity. Be aware, however, that this will + possibly consume some system resources in the process. + + + Enable LED #2 + enable_led2 + checkbox + + + Interface For LED #2 + gw_led2 + select_source + + name + value + Use LED #2 to indicate the status for this gateway. + + + Enable LED #3 + enable_led3 + checkbox + + + Interface For LED #3 + gw_led3 + select_source + + name + value + Use LED #3 to indicate the status for this gateway. + + + + validate_form_gwled($_POST, &$input_errors); + + + sync_package_gwled(); + +
-- cgit v1.2.3