diff --git a/httpdocs/misc/ntopng-utils-manage-config.in b/httpdocs/misc/ntopng-utils-manage-config.in index f7ee25c33b..5f91fc11ec 100755 --- a/httpdocs/misc/ntopng-utils-manage-config.in +++ b/httpdocs/misc/ntopng-utils-manage-config.in @@ -22,6 +22,8 @@ SAVED_SUFFIX=".ntopngsaved" ACTION="" QUIET=false +INTERFACE="" + NEDGE="@NEDGE@" function print_usage() { @@ -31,6 +33,7 @@ function print_usage() { echo "`basename $0` -a restore [-d datadir] [-c archive.tar.gz]" echo "`basename $0` -a backup [-d datadir] [-c archive.tar.gz]" echo "`basename $0` -a check-restore [-d datadir] [-c archive.tar.gz]" + echo "`basename $0` -a install-n2disk-conf [-d datadir] -i interface" echo "" echo "[-d datadir]" echo " The path to the ntopng data directory." @@ -57,6 +60,11 @@ function print_usage() { echo "`basename $0` -a check-restore [-c archive.tar.gz] [-d datadir]" echo " Check restore scans the data directory and looks for a valid compressed archive there." echo " Returns true when the archive is found and false otherwise." + echo "" + echo "-a install-n2disk-conf" + echo "`basename $0` -a install-n2disk-conf [-d datadir] -i interface" + echo "Installs a n2disk configuration file generated by ntopng to /etc/n2disk/ creating a symlink" + echo "" } POSITIONAL=() @@ -82,6 +90,11 @@ case $key in shift shift ;; + -i|--interface) + INTERFACE="$2" + shift + shift + ;; *) POSITIONAL+=("$1") shift @@ -106,7 +119,7 @@ function cleanup() { trap cleanup EXIT -if [[ ( $ACTION != "backup" && $ACTION != "restore" && $ACTION != "check-restore") ]]; then +if [[ ( $ACTION != "backup" && $ACTION != "restore" && $ACTION != "check-restore" && $ACTION != "install-n2disk-conf" ) ]]; then print_usage exit 1 fi @@ -383,6 +396,24 @@ function post_restore_actions() { fi } +function install_n2disk_conf() { + if [ "${INTERFACE}" == "" ]; then + return + fi + + local SOURCE_FILE="${DATADIR}/n2disk/n2disk-${INTERFACE}.conf" + + if [ ! -f "${SOURCE_FILE}" ]; then + return + fi + + local DEST_PATH="/etc/n2disk" + + mkdir -p "${DEST_PATH}" + + ln -s "${SOURCE_FILE}" "${DEST_PATH}" +} + prepare_cur_data_dir_path prepare_tar_file_path @@ -408,9 +439,17 @@ elif [ $ACTION == "restore" ]; then sanitize_staging_dir restore_files post_restore_actions + elif [ $ACTION == "check-restore" ]; then + check_tar_file check_tar_contents + +elif [ $ACTION == "install-n2disk-conf" ]; then + echo "Installing n2disk configuration for ${INTERFACE} ..." + + install_n2disk_conf + else # never reached echo "Unknown action $ACTION" diff --git a/scripts/lua/modules/recording_utils.lua b/scripts/lua/modules/recording_utils.lua index f4c639771f..26e5f768f5 100644 --- a/scripts/lua/modules/recording_utils.lua +++ b/scripts/lua/modules/recording_utils.lua @@ -39,7 +39,7 @@ local function nextFreeCore(num_cores, busy_cores, start) end function recording_utils.createConfig(ifname, params) - local filename = "/etc/n2disk/n2disk-"..ifname..".conf" -- TODO write in a folder with write permissions + local filename = dirs.workingdir.."/n2disk/n2disk-"..ifname..".conf" local defaults = { path = "/storage", -- Storage path @@ -60,7 +60,7 @@ function recording_utils.createConfig(ifname, params) if ifspeed > 10000 then -- 40/100G defaults.max_file_size = 4*1024 - else if ifspeed > 1000 then -- 10G + elseif ifspeed > 1000 then -- 10G defaults.max_file_size = 1*1024 end defaults.buffer_size = 4*defaults.max_file_size