diff options
Diffstat (limited to 'config/bandwidthd')
-rw-r--r-- | config/bandwidthd/bandwidthd.inc | 49 | ||||
-rw-r--r-- | config/bandwidthd/bandwidthd.xml | 24 |
2 files changed, 45 insertions, 28 deletions
diff --git a/config/bandwidthd/bandwidthd.inc b/config/bandwidthd/bandwidthd.inc index 3aa53694..34532c18 100644 --- a/config/bandwidthd/bandwidthd.inc +++ b/config/bandwidthd/bandwidthd.inc @@ -28,12 +28,24 @@ POSSIBILITY OF SUCH DAMAGE. */ +// Check pfSense version +$pfs_version = substr(trim(file_get_contents("/etc/version")),0,3); +switch ($pfs_version) { + case "1.2": + case "2.0": + define('PKG_BANDWIDTHD_BASE', '/usr/local/bandwidthd'); + break; + default: + define('PKG_BANDWIDTHD_BASE', '/usr/pbi/bandwidthd-' . php_uname("m") . '/bandwidthd'); + } +// End: Check pfSense version + function bandwidthd_install_deinstall() { conf_mount_rw(); config_lock(); - exec("rm /usr/local/etc/rc.d/bandwidthd*"); - exec("rm -rf /usr/local/bandwidthd*"); - exec("rm /usr/local/www/bandwidthd"); + exec("rm -f /usr/local/etc/rc.d/bandwidthd*"); + exec("rm -rf " . PKG_BANDWIDTHD_BASE . "/htdocs"); + exec("rm -f /usr/local/www/bandwidthd"); conf_mount_ro(); config_unlock(); } @@ -41,16 +53,22 @@ function bandwidthd_install_deinstall() { function bandwidthd_install_config() { global $config, $g; + /* bandwidthd doesn't have a way to pass a custom config path, unfortunately */ + $bandwidthd_config_dir = PKG_BANDWIDTHD_BASE . "/etc"; + conf_mount_rw(); config_lock(); /* user defined values */ - $meta_refresh = $config['installedpackages']['bandwidthd']['config'][0]['metarefresh']; + $meta_refresh = $config['installedpackages']['bandwidthd']['config'][0]['meta_refresh']; if($meta_refresh) $meta_refresh = "meta_refresh $meta_refresh\n"; - $graph = $config['installedpackages']['bandwidthd']['config'][0]['graph']; + $graph = $config['installedpackages']['bandwidthd']['config'][0]['drawgraphs']; if($graph) $graph = "graph true\n"; + else + $graph = "graph false\n"; + $filter_text = $config['installedpackages']['bandwidthd']['config'][0]['filter']; if($filter_text) $filter_text = "filter $filter_text\n"; @@ -63,6 +81,9 @@ function bandwidthd_install_config() { $promiscuous = $config['installedpackages']['bandwidthd']['config'][0]['promiscuous']; if($promiscuous) $promiscuous = "promiscuous true\n"; + else + $promiscuous = "promiscuous false\n"; + $graph_cutoff = $config['installedpackages']['bandwidthd']['config'][0]['graphcutoff']; if($graph_cutoff) $graph_cutoff = "graph_cutoff $graph_cutoff\n"; @@ -73,10 +94,10 @@ function bandwidthd_install_config() { if($config['installedpackages']['bandwidthd']['config'][0]['active_interface']){ $ifdescrs = array($config['installedpackages']['bandwidthd']['config'][0]['active_interface']); } else { - log_error("You should specify a interface for bandwidthd to listen on. exiting."); + log_error("You should specify an interface for bandwidthd to listen on. Exiting."); } - $subnets_custom = split(';',str_replace(' ','',$config['installedpackages']['bandwidthd']['config'][0]['subnets_custom'])); + $subnets_custom = explode(';',str_replace(' ','',$config['installedpackages']['bandwidthd']['config'][0]['subnets_custom'])); /* initialize to "" */ $subnets = ""; @@ -146,7 +167,7 @@ $dev # An interval is 2.5 minutes, this is how many # intervals to skip before doing a graphing run -$skip_inervals +$skip_intervals # Graph cutoff is how many k must be transfered by an # ip before we bother to graph it @@ -177,9 +198,9 @@ $meta_refresh EOF; - $fd = fopen("/usr/local/bandwidthd/etc/bandwidthd.conf","w"); + $fd = fopen("{$bandwidthd_config_dir}/bandwidthd.conf","w"); if(!$fd) { - log_error("could not open /usr/local/bandwidthd/etc/bandwidthd.conf for writing"); + log_error("could not open {$bandwidthd_config_dir}/bandwidthd.conf for writing"); exit; } fwrite($fd, $config_file); @@ -188,15 +209,15 @@ EOF; /* write out rc.d start/stop file */ write_rcfile(array( "file" => "bandwidthd.sh", - "start" => "/usr/local/bandwidthd/bandwidthd /usr/local/bandwidthd/etc/bandwidthd.conf", + "start" => "/usr/local/bandwidthd/bandwidthd {$bandwidthd_config_dir}/bandwidthd.conf", "stop" => "/usr/bin/killall bandwidthd" ) ); exec("rm /usr/local/www/bandwidthd"); - exec("/bin/ln -s /usr/local/bandwidthd/htdocs /usr/local/www/bandwidthd"); + exec("/bin/ln -s " . PKG_BANDWIDTHD_BASE . "/htdocs /usr/local/www/bandwidthd"); - exec("echo \"Please start bandwidthd to populate this directory.\" > /usr/local/bandwidthd/htdocs/index.html"); + exec("echo \"Please start bandwidthd to populate this directory.\" > " . PKG_BANDWIDTHD_BASE . "/htdocs/index.html"); conf_mount_ro(); config_unlock(); @@ -206,4 +227,4 @@ EOF; } -?> +?>
\ No newline at end of file diff --git a/config/bandwidthd/bandwidthd.xml b/config/bandwidthd/bandwidthd.xml index 6a3dab35..258772a7 100644 --- a/config/bandwidthd/bandwidthd.xml +++ b/config/bandwidthd/bandwidthd.xml @@ -80,7 +80,7 @@ </additional_files_needed> <fields> <field> - <fielddescr>interface</fielddescr> + <fielddescr>Interface</fielddescr> <fieldname>active_interface</fieldname> <description>The interface that bandwidthd will bind to.</description> <type>interfaces_selection</type> @@ -88,27 +88,25 @@ <default_value>lan</default_value> </field> <field> - <fielddescr>Subnet</fielddescr> - <fieldname>subnets_custom</fieldname> - <description>The subnet(s) on which bandwidthd will report. (separate with ';' for multiple subnets, e.g. 192.168.1.0/24;10.0.0.0/24)</description> - <type>input</type> + <fielddescr>Subnet</fielddescr> + <fieldname>subnets_custom</fieldname> + <description>The subnet(s) on which bandwidthd will report. (separate with ';' for multiple subnets, e.g. 192.168.1.0/24;10.0.0.0/24) The ordinary subnet for the selected interface/s is automatically put in the config, do not specify it here.</description> + <type>input</type> </field> <field> <fielddescr>Skip intervals</fielddescr> <fieldname>skipintervals</fieldname> - <description></description> + <description>Number of intervals (2.5 minute) to skip between graphing. Default 0.</description> <type>input</type> - <value>1024</value> </field> <field> <fielddescr>Graph cutoff</fielddescr> <fieldname>graphcutoff</fieldname> - <description>Graph cutoff is how many KB must be transferred by an IP before it is graphed</description> + <description>Graph cutoff is how many KB must be transferred by an IP before it is graphed. Default 1024.</description> <type>input</type> - <value>1024</value> </field> <field> - <fielddescr>promiscuous</fielddescr> + <fielddescr>Promiscuous</fielddescr> <fieldname>promiscuous</fieldname> <description>Put interface in promiscuous mode to score to traffic that may not be routing through the host machine.</description> <type>checkbox</type> @@ -126,25 +124,23 @@ <type>checkbox</type> </field> <field> - <fielddescr>filter</fielddescr> + <fielddescr>Filter</fielddescr> <fieldname>filter</fieldname> <description>Libpcap format filter string used to control what bandwidthd sees. Please always include "ip" in the string to avoid strange problems.</description> <type>input</type> - <value>ip</value> </field> <field> <fielddescr>Draw Graphs</fielddescr> <fieldname>drawgraphs</fieldname> <description>This defaults to true to graph the traffic bandwidthd is recording. Set this to false if you only want cdf output or you are using the database output option. Bandwidthd will use very little RAM and CPU if this is set to false.</description> <type>checkbox</type> - <value>checked</value> + <default_value>on</default_value> </field> <field> <fielddescr>Meta Refresh</fielddescr> <fieldname>meta_refresh</fieldname> <description>Set META REFRESH seconds (default 150, use 0 to disable).</description> <type>input</type> - <value>150</value> </field> </fields> <custom_php_resync_config_command> |