From 296008c99ff8efc3de1d68c177d889004a095575 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sun, 13 Sep 2015 23:58:24 +0200 Subject: ntopng - reworked package - Moved all PHP code to separate ntopng.inc - Add a button to wipe ntopng data - Add enable checkbox - Add checkbox to either keep or delete settings and data on uninstall/reinstall. - Some description cosmetics --- config/ntopng/ntopng.xml | 286 +++++++++++------------------------------------ 1 file changed, 66 insertions(+), 220 deletions(-) diff --git a/config/ntopng/ntopng.xml b/config/ntopng/ntopng.xml index 6c01515c..9416a693 100644 --- a/config/ntopng/ntopng.xml +++ b/config/ntopng/ntopng.xml @@ -9,7 +9,7 @@ /* ntopng.xml part of pfSense (https://www.pfSense.org/) - Copyright (C) 2014 ESF, LLC + Copyright (C) 2014-2015 ESF, LLC All rights reserved. */ /* ========================================================================== */ @@ -39,15 +39,19 @@ ]]> ntopng - 0.7.2 + 0.8.0 Diagnostics: ntopng Settings - Change + /usr/local/pkg/ntopng.inc + + /usr/local/pkg/ + https://packages.pfsense.org/packages/config/ntopng/ntopng.inc + pkg_edit.php?xml=ntopng.xml ntopng Settings Set ntopng settings such as password and port.
Diagnostics
- /pkg_edit.php?xml=ntopng.xml&id=0 + /pkg_edit.php?xml=ntopng.xml
ntopng @@ -60,12 +64,12 @@ ntopng ntopng.sh ntopng - ntopng bandwidth monitoring/graphing + ntopng Network Traffic Monitor ntopng Settings - /pkg_edit.php?xml=ntopng.xml&id=0 + /pkg_edit.php?xml=ntopng.xml @@ -74,33 +78,58 @@ + + Enable ntopng + enable + Check this to enable ntopng. + checkbox + + + Keep Data/Settings + keepdata + + + Note: If 'Keep Data' is disabled, all settings and data will be wiped on package uninstall/reinstall/upgrade! + ]]> + + checkbox + on + ntopng Admin Password - password - Enter the password for the ntopng GUI. Minimum 5 characters, defaults to admin. + redis_password + Enter the password for the ntopng GUI. Minimum 5 characters. password + true + 20 Confirm ntopng Admin Password - passwordagain + redis_passwordagain password + true + 20 Interface interface_array interfaces_selection 3 - lan + lan true + loopback DNS Mode dns_mode - Configures how name resolution is handled<br/><br/> - Additionally, GeoIP Data can provide location information about IP addresses.<br/> - This product includes GeoLite data created by MaxMind, available from <a href="http://www.maxmind.com">http://www.maxmind.com</a>.<br/> - <input type="submit" name="Submit" value="Update GeoIP Data"> +
+ Additionally, GeoIP Data can provide location information about IP addresses.
+ This product includes GeoLite data created by MaxMind, available from http://www.maxmind.com

+ + ]]>
select 0 @@ -114,7 +143,12 @@ Local Networks local_networks - Configures how Local Networks are defined + + + (Default: Consider all RFC1918 networks local) + ]]> + select rfc1918 @@ -126,226 +160,38 @@ Historical Data Storage dump_flows - Enable historical data storage + + + WARNING: This feature consumes HUGE amount of disk space. + Also, browsing the historical data is VERY slow.
+ The historical interface is considered abandoned by upstream, + pending more usable replacement.

+ + WARNING: This will delete all ntopng graphs, traffic data and historical dump flows! + ]]> +
checkbox
Disable Alerts disable_alerts - Disables all alerts generated by ntopng, such as flooding notifications + Disables all alerts generated by ntopng, such as flooding notifications. checkbox
- - = 0) && ($ntopng_config['dns_mode'] <= 3)) { - $dns_mode = "--dns-mode " . escapeshellarg($ntopng_config['dns_mode']); - } - - // Local Networks > - switch ($ntopng_config['local_networks']) { - case "selected": - $nets = array(); - foreach ($ntopng_config['interface_array'] as $iface) { - if (is_ipaddr(get_interface_ip($iface))) { - $nets[] = gen_subnet(get_interface_ip($iface),get_interface_subnet($iface)) . '/' . get_interface_subnet($iface); - } - } - if (!empty($nets)) - $local_networks = "--local-networks " . escapeshellarg(implode(",", $nets)); - break; - case "lanonly": - if (is_ipaddr(get_interface_ip('lan'))) { - $local_networks = "--local-networks " . escapeshellarg(gen_subnet(get_interface_ip('lan'),get_interface_subnet('lan')) . '/' . get_interface_subnet('lan')); - } - break; - case "rfc1918": - default: - $local_networks = "--local-networks '192.168.0.0/16,172.16.0.0/12,10.0.0.0/8'"; - break; - } - - // Historical Data Storage, Dump expired flows - if ($ntopng_config['dump_flows'] >= on) { - $dump_flows = "-F"; - } - - // Disable alerts - if ($ntopng_config['disable_alerts'] >= on) { - $disable_alerts = "-H"; - } - - if ($pf_version == "2.2") { - $redis_path = "/usr/pbi/ntopng-" . php_uname("m") . "/local/bin"; - } else if ($pf_version == "2.1") { - $redis_path = "/usr/pbi/ntopng-" . php_uname("m") . "/bin"; - } else { - $redis_path = "/usr/local/bin"; - } - - $start = ""; - if ($pf_version == "2.1" || $pf_version == "2.2") { - $start .= "ldconfig -m /usr/pbi/ntopng-" . php_uname("m") . "/lib\n"; - } - $start .= "\t{$redis_path}/redis-server --dir /var/db/ntopng/ --dbfilename ntopng.rdb &\n"; - // TODO: - // Add support for --data-dir /somewhere, --httpdocs-dir /somewhereelse, - // --dump-timeline (on/off) --http-port, --https-port - - $start .= "\t/usr/local/bin/ntopng -d /var/db/ntopng -G /var/run/ntopng.pid -s -e {$disable_alerts} {$dump_flows} {$ifaces} {$dns_mode} {$aggregations} {$local_networks} &"; - write_rcfile(array( - "file" => "ntopng.sh", - "start" => $start, - "stop" => "/usr/bin/killall ntopng redis-cli redis-server" - ) - ); - if (is_service_running("ntopng")) { - stop_service("ntopng"); - // Wait for ntopng to shut down cleanly. - sleep(20); - } - ntopng_fixup_geoip(); - start_service("ntopng"); - sleep(2); - - if (empty($ntopng_config['password'])) - $ntopng_config['password'] = "admin"; - $password = md5($ntopng_config['password']); - mwexec_bg("{$redis_path}/redis-cli SET user.admin.password " . escapeshellarg($password)); - mwexec_bg("{$redis_path}/redis-cli save"); - conf_mount_ro(); - } - function ntopng_update_geoip() { - $fetchcmd = "/usr/bin/fetch"; - $geolite_city = "https://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz"; - $geolite_city_v6 = "https://geolite.maxmind.com/download/geoip/database/GeoLiteCityv6-beta/GeoLiteCityv6.dat.gz"; - $geoip_asnum = "https://download.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz"; - $geoip_asnum_v6 = "https://download.maxmind.com/download/geoip/database/asnum/GeoIPASNumv6.dat.gz"; - $pf_version=substr(trim(file_get_contents("/etc/version")),0,3); - if ($pf_version == "2.1" || $pf_version == "2.2") { - $output_dir = "/usr/pbi/ntopng-" . php_uname("m") . "/share/ntopng"; - } else { - $output_dir = "/usr/local/share/ntopng"; - } - - mwexec("{$fetchcmd} -o {$output_dir} -T 5 {$geolite_city}"); - mwexec("{$fetchcmd} -o {$output_dir} -T 5 {$geolite_city_v6}"); - mwexec("{$fetchcmd} -o {$output_dir} -T 5 {$geoip_asnum}"); - mwexec("{$fetchcmd} -o {$output_dir} -T 5 {$geoip_asnum_v6}"); - - ntopng_fixup_geoip(); - restart_service("ntopng"); - } - function ntopng_fixup_geoip() { - $pf_version=substr(trim(file_get_contents("/etc/version")),0,3); - if ($pf_version == "2.1" || $pf_version == "2.2") { - $target_dir = "/usr/pbi/ntopng-" . php_uname("m") . "/local/share/ntopng/httpdocs/geoip"; - $source_dir = "/usr/pbi/ntopng-" . php_uname("m") . "/share/ntopng"; - } else { - $target_dir = "/usr/local/share/ntopng/httpdocs/geoip"; - $source_dir = "/usr/local/share/ntopng"; - } - - safe_mkdir($target_dir, 0755); - - foreach(glob("{$source_dir}/Geo*.dat*") as $geofile) { - /* Decompress if needed. */ - if (substr($geofile, -3, 3) == ".gz") { - // keep -f here, otherwise the files will not get updated - mwexec("/usr/bin/gzip -d -f " . escapeshellarg($geofile)); - } - } - - /* Use a separate glob since the filenames could have changed since the last run */ - foreach(glob("{$source_dir}/Geo*.dat*") as $geofile) { - $target_file = $target_dir . '/' . basename($geofile); - if (!file_exists($target_file)) { - symlink($geofile, $target_file); - } - } - } - ]]> - - - sync_package_ntopng(); - - sync_package_ntopng(); + ntopng_sync_package(); - + ntopng_sync_package(); - exec("rm /usr/local/etc/rc.d/ntopng*"); - $pf_version=substr(trim(file_get_contents("/etc/version")),0,3); - if ($pf_version == "2.1" || $pf_version == "2.2") { - if (is_dir("/usr/local/share/ntopng/")) { - exec("rm -rf /usr/local/share/ntopng/"); - } - } + ntopng_php_deinstall_command(); - + ntopng_validate_input($_POST, $input_errors); -- cgit v1.2.3