ntopng
1.2 v0.5
Diagnostics: ntopng Settings
Change
pkg_edit.php?xml=ntopng.xml
ntopng
ntopng.sh
ntopng
ntopng bandwidth monitoring/graphing
ntopng Settings
/pkg_edit.php?xml=ntopng.xml&id=0
Access ntopng
http://$myurl:3000
ntopng Admin Password
password
Enter the password for the ntopng GUI. Minimum 5 characters, defaults to admin.
password
Confirm ntopng Admin Password
passwordagain
password
Interface
interface_array
interfaces_selection
3
lan
true
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">
select
0
Local Networks
local_networks
Configures how Local Networks are defined
select
rfc1918
Historical Data Storage
dump_flows
Enable historical data storage
checkbox
Disable Alerts
disable_alerts
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";
}
$pf_version=substr(trim(file_get_contents("/etc/version")),0,3);
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();
config_unlock();
}
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();
exec("rm /usr/local/etc/rc.d/ntopng*");