http://www.ntop.org/products/ntop/ //原廠說明
沒有apt-get 套件安裝法,當然就要靠編譯了,所以寫了一個腳本方便安裝。
圖片取自原廠 |
apt-get install //安裝相依性元件
libpcap-dev
libglib2.0-dev
libgeoip-dev
redis-server
wget
libxml2-dev
build-essential
libsqlite3-dev
cd /usr/local/src //切換資料夾
wget "http://downloads.sourceforge.net/project/ntop/ntopng/ntopng-data-1.1_6932.tgz" -O ntopng-data-1.1_6932.tgz
// -O 是英文大寫O
wget "http://downloads.sourceforge.net/project/ntop/ntopng/ntopng-1.1_6932.tgz" -O ntopng-1.1_6932.tgz
要先裝ntopng-data
cd /usr/local/src //切換目錄
tar -xf ntopng-data-1.1_6932.tar.gz //解壓縮
cd ntopng-data-1.1_6932
cp -r ./usr/* /usr //複製ntopng-data-1.1_6932裡面usr資料夾裡面的全部,到系統usr資料夾
再安裝ntopng
cd /usr/local/src //切換目錄
tar -xf ntopng-1.1_6932.tar.gz //解壓縮
cd ntopng-1.1_6932 //進入主程式目錄進行編譯
make clean
|-----cd third-party/json-c //編譯副件
|-----make clean
|-----cd .. //切換回原路徑
|----------
|-----cd third-party/LuaJIT-2.0.2 //編譯副件
|-----make clean
|-----cd .. //切換回原路徑
|----------
|-----cd third-party/rrdtool-1.4.7 //編譯副件
|-----make clean
|-----cd .. //切換回原路徑
|----------
|-----cd third-party/zeromq-3.2.3 //編譯副件
|-----make clean
|-----cd .. //切換回原路徑
|----------
|-----cd third-party/credis-0.2.3 //編譯副件
|-----make clean
|-----cd .. //切換回原路徑
|----------
make
make install //編譯並安裝
mkdir -p /etc/ntopng //建立啟動檔與設定檔
touch /etc/ntopng/ntopng.start
touch /etc/ntopng/ntopng.conf
vi ntopng.conf //編輯設定檔
-G= /var/tmp/ntopng .gid
vi ntopng.start //編輯啟動檔
--interface 1 //請先執行ntopng -h 觀看全部設定值,在依需求寫入值
/etc/init.d/redis-server restart //重新啟動redis-server
ntopng /etc/ntopng/ntopng.conf //啟動ntopng 後面載入設定檔路徑
//系統啟動檔腳本
vi /etc/init/ntopng.conf
# ntopng network flow analyzer
# by https://raymii.org
description "ntopng network flow analyzer"
start on virtual-filesystems
stop on runlevel [06]
respawn
respawn limit 5 30
limit nofile 65550 65550
setuid root
setgid root
console log
script
exec /usr/local/bin/ntopng /etc/ntopng/ntopng.conf
end script
//安裝腳本,請自行複製至文件檔並跟改副檔名為.sh
執行安裝完後,啟動檔與設定檔內都沒寫值
必須寫值進去才會動
****************************************************
#!/bin/bash
#ntopng script for Ubuntu 12.04
logfile=/var/log/ntopng_install.log
mkfifo ${logfile}.pipe
tee < ${logfile}.pipe $logfile &
exec &> ${logfile}.pipe
rm ${logfile}.pipe
########################################
function print_status ()
{
echo -e "\x1B[01;34m[*]\x1B[0m $1"
}
function print_good ()
{
echo -e "\x1B[01;32m[*]\x1B[0m $1"
}
function print_error ()
{
echo -e "\x1B[01;31m[*]\x1B[0m $1"
}
function print_notification ()
{
echo -e "\x1B[01;33m[*]\x1B[0m $1"
}
########################################
#Package installation function.
function install_packages()
{
apt-get update &>> $logfile && apt-get install -y ${@} &>> $logfile
if [ $? -eq 0 ]; then
print_good "Packages successfully installed."
else
print_error "Packages failed to install!"
exit 1
fi
}
########################################
print_status "Wget check."
/usr/bin/which wget 2>&1 >> /dev/null
if [ $? -ne 0 ]; then
print_error "Wget not found."
print_notification "Installing wget."
install_packages wget
else
print_good "Found wget."
fi
########################################
print_status "Grabbing packages for ntopng."
apt-get install -y libpcap-dev libglib2.0-dev libgeoip-dev redis-server libxml2-dev build-essential libsqlite3-dev make &>> $logfile
if [ $? != 0 ];then
print_error "Failed to acquire required packages for ntopng. See $logfile for details."
exit 1
else
print_good "Successfully acquired packages."
fi
########################################
print_status "making the ntopng directory"
mkdir -p /usr/local/src
cd /usr/local/src
########################################
print_status "Grabbing ntopng-data."
wget http://downloads.sourceforge.net/project/ntop/ntopng/ntopng-data-1.1_6932.tgz -O ntopng-data-1.1_6932.tgz &>> $logfile
if [ $? != 0 ];then
print_error "Attempt to pull down ntopng-data console failed. See $logfile for details."
exit 1
else
print_good "Successfully downloaded ntopng-data."
fi
print_status "Installing ntopng-data."
tar -xf ntopng-data-1.1_6932.tgz &>> $logfile
if [ $? != 0 ];then
print_error "Attempt to unpack ntopng-data failed. See $logfile for details."
exit 1
else
print_good "Successfully installed ntopng-data."
fi
cd ntopng-data-1.1_6932
cp -r ./usr/* /usr
cd ..
########################################
print_status "Grabbing ntopng."
wget http://downloads.sourceforge.net/project/ntop/ntopng/ntopng-1.1_6932.tgz -O ntopng-1.1_6932.tgz &>> $logfile
if [ $? != 0 ];then
print_error "Attempt to pull down ntopng console failed. See $logfile for details."
exit 1
else
print_good "Successfully downloaded ntopng."
fi
print_status "Installing ntopng."
tar -xf ntopng-1.1_6932.tgz &>> $logfile
if [ $? != 0 ];then
print_error "Attempt to unpack ntopng failed. See $logfile for details."
exit 1
else
print_good "Successfully installed ntopng."
fi
########################################
cd ntopng-1.1_6932
print_status "compiling and linking ntopng-1.1_6932. This will take a moment or two."
./configure &>> $logfile
if [ $? -ne 0 ]; then
print_error "Failed to configure. Please check $logfile for details."
exit 1
fi
make clean &>> $logfile
if [ $? -ne 0 ]; then
print_error "Failed to make clean. Please check $logfile for details."
exit 1
fi
print_good "ntopng-1.1_6932 installed."
#########################################
cd third-party/json*
make clean &>> $logfile
if [ $? -ne 0 ]; then
print_error "Failed to make clean. Please check $logfile for details."
exit 1
fi
print_good "json-c installed."
cd ..
#########################################
cd LuaJIT*
make clean &>> $logfile
if [ $? -ne 0 ]; then
print_error "Failed to make clean. Please check $logfile for details."
exit 1
fi
print_good "LuaJIT-2.0.2 installed."
cd ..
#########################################
cd rrdtool*
make clean &>> $logfile
if [ $? -ne 0 ]; then
print_error "Failed to make clean. Please check $logfile for details."
exit 1
fi
print_good "rrdtool-1.4.7 installed."
cd ..
#########################################
cd zeromq*
make clean &>> $logfile
if [ $? -ne 0 ]; then
print_error "Failed to make clean. Please check $logfile for details."
exit 1
fi
print_good "zeromq-3.2.3 installed."
cd ..
#########################################
cd credis*
make clean &>> $logfile
if [ $? -ne 0 ]; then
print_error "Failed to make clean. Please check $logfile for details."
exit 1
fi
print_good "credis-0.2.3 installed."
cd ..
cd ..
#########################################
make &>> $logfile
if [ $? -ne 0 ]; then
print_error "Failed to make. Please check $logfile for details."
exit 1
fi
make install &>> $logfile
if [ $? -ne 0 ]; then
print_error "Failed to make install. Please check $logfile for details."
exit 1
fi
print_good "ntopng-1.1_6932 installed."
#########################################
mkdir -p /etc/ntopng
touch /etc/ntopng/ntopng.start && touch /etc/ntopng/ntopng.conf
exit 0
**************************************************
參考資料
沒有留言:
張貼留言