aboutsummaryrefslogtreecommitdiffstats
path: root/config/softflowd
diff options
context:
space:
mode:
Diffstat (limited to 'config/softflowd')
-rw-r--r--config/softflowd/softflowd.xml136
1 files changed, 136 insertions, 0 deletions
diff --git a/config/softflowd/softflowd.xml b/config/softflowd/softflowd.xml
new file mode 100644
index 00000000..1b45f8bb
--- /dev/null
+++ b/config/softflowd/softflowd.xml
@@ -0,0 +1,136 @@
+<packagegui>
+ <name>softflowd</name>
+ <version>0.9.8</version>
+ <title>softflowd: Settings</title>
+ <aftersaveredirect>pkg_edit.php?xml=softflowd.xml&amp;id=0</aftersaveredirect>
+ <menu>
+ <name>softflowd</name>
+ <tooltiptext>Modify softflowd settings.</tooltiptext>
+ <section>Services</section>
+ <configfile>softflowd.xml</configfile>
+ <url>/pkg_edit.php?xml=softflowd.xml&amp;id=0</url>
+ </menu>
+ <service>
+ <name>softflowd</name>
+ <rcfile>softflowd.sh</rcfile>
+ <executable>softflowd</executable>
+ </service>
+ <configpath>installedpackages->package->$packagename->configuration->settings</configpath>
+ <fields>
+ <field>
+ <fielddescr>Interface</fielddescr>
+ <fieldname>interface</fieldname>
+ <type>interfaces_selection</type>
+ <description>Pick an interface from which to collect netflow data. A separate instance of softflowd will be launched for each interface.</description>
+ <multiple/>
+ </field>
+ <field>
+ <fielddescr>Host</fielddescr>
+ <fieldname>host</fieldname>
+ <description>Specify the host to which datagrams will be sent.</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Port</fielddescr>
+ <fieldname>port</fieldname>
+ <description>Enter the port to which datagrams will be sent.</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Max Flows</fielddescr>
+ <fieldname>maxflows</fieldname>
+ <description>Specify the maximum number of flows to concurrently track before older flows are expired. Default: 8192.</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Netflow version</fielddescr>
+ <fieldname>version</fieldname>
+ <description>Select the desired version of the NetFlow protocol.</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>9</name>
+ <value>9</value>
+ </option>
+ <option>
+ <name>5</name>
+ <value>5</value>
+ </option>
+ <option>
+ <name>1</name>
+ <value>1</value>
+ </option>
+ </options>
+ </field>
+ </fields>
+ <custom_php_global_functions>
+ <![CDATA[
+ function sync_package_softflowd() {
+ conf_mount_rw();
+ config_lock();
+ global $config;
+ $cf = $config['installedpackages']['softflowd']['config'][0];
+ $interface_list = explode(",", $cf['interface']);
+ if (!empty($cf['host']) && !empty($interface_list)) {
+ $cf['host'] = is_ipaddrv6($cf['host']) ? "[{$cf['host']}]" : $cf['host'];
+ $start = "/usr/bin/killall -9 softflowd";
+ foreach ($interface_list as $interface_friendly) {
+ if (empty($interface_friendly))
+ continue;
+ $interface = get_real_interface($interface_friendly);
+ if (empty($interface))
+ continue;
+ $start .= "\n\t/usr/local/sbin/softflowd ";
+ $start .= " -i {$interface}";
+ $start .= " -n {$cf['host']}:{$cf['port']}";
+ if (is_numeric($cf['maxflows']))
+ $start .= " -m {$cf['maxflows']}";
+ if ($cf['version'] != "")
+ $start .= " -v {$cf['version']}";
+ $start .= " -p /var/run/softflowd.{$interface}.pid";
+ $start .= " -c /var/run/softflowd.{$interface}.ctl";
+ }
+ write_rcfile(array(
+ "file" => "softflowd.sh",
+ "start" => $start,
+ "stop" => "/usr/bin/killall -9 softflowd"
+ )
+ );
+ restart_service("softflowd");
+ }
+ conf_mount_ro();
+ config_unlock();
+ }
+
+ function validate_form_softflowd($post, $input_errors) {
+ if (($post['host'] == "") || !is_ipaddr($post['host']))
+ $input_errors[] = 'You must specify a valid ip address in the \'Host\' field';
+ if (($post['port'] == "") || !is_port($post['port']))
+ $input_errors[] = 'You must specify a valid port number in the \'Port\' field';
+ }
+
+ function cleanup_config_softflowd() {
+ global $a_pkg;
+ $pffconf = array();
+ if (is_array($a_pkg)) {
+ foreach($a_pkg as $cf) {
+ if ($cf['host'] != "") {
+ $pffconf = $cf;
+ }
+ }
+ }
+ $a_pkg = array();
+ $a_pkg[0] = $pffconf;
+ }
+ ]]>
+ </custom_php_global_functions>
+ <custom_php_resync_config_command>
+ sync_package_softflowd();
+ </custom_php_resync_config_command>
+ <custom_php_validation_command>
+ validate_form_softflowd($_POST, &amp;$input_errors);
+ </custom_php_validation_command>
+ <custom_php_command_before_form>
+ cleanup_config_softflowd();
+ </custom_php_command_before_form>
+</packagegui>