SlideShare uma empresa Scribd logo
1 de 107
Baixar para ler offline
網路監控 
實作 
by netman<netman@study-area.org>
主題大綱 
● Tcpdump 
● Wireshark 
● Ntop 
● Mrtg 
● Cacti 
● Nagios 
● OpenNMS
tcpdump
tcpdump 
● http://www.tcpdump.org/ 
● CLI 模式的封包截取工具 
● 使用 libpcap 作為封包處理函式庫 
● 大多數 Unix-based 作業系統均內建
截取參數 
-D 
顯示所有可截取的網卡 
-i [interface] 
選擇網卡 
any 表示所有的網卡 
-p 
不將網卡切入 promiscuous mode 
-F [file] 
由指定的檔案讀取 Filter Expression 
-s 
限制封包長度 (預設為 68 bytes) 
0 表示不限制,錄下完整封包
儲存參數 
-c [封包數] 
錄下指令數量的封包後停止 
-C [檔案大小] 
限制記錄檔案之大小 (搭配 -w 指定檔名) 
達到上限時將開新檔繼續儲存 
單位為 1,000,000 bytes 
-W [檔案數] 
限制 -C 參數儲存之檔案數量
檔案參數 
-w [file] 
將截取封包寫入至檔案 
-U 
搭配 -w 寫入檔案時,不作緩存 
-r [file] 
由指定檔案取得封包
顯視參數 
-A 
以 ASCII 字元顯示封包內容 
-e 
顯示 Link Layer 資訊 (例如MAC-Address) 
-n 
不作名稱解析 (主機名稱、服務名稱… etc) 
-v 
顯示較詳細的封包資訊 
-v 、 -vv 、 -vvv 三種等級 
-x / -xx 
將封包內容以 hex 格式顯示 
-X / -XX 
將封包內容以 hex 及 ASCII 格式顯示
時間參數 
-t 
不顯示時間戳記 
-tt 
顯示 UNIX timestamp 格式 
-ttt 
顯示每個封包之間隔 (micro seconds) 
-tttt 
顯示標準格式 (yyyy-mm-dd hh:mm:ss.ms)
協定參數 
Layer 2 
arp 
rarp 
stp 
vlan 
Layer 3 
ip 
ip6 
Layer 4 
tcp 
udp 
icmp
目標參數 
src/dst 
ether 
host 
net 
port
封包參數 
broadcast 
multicast
數值運算 
= : equal 
< : less 
> : greater
羅輯運算 
! : not 
&& : and 
|| : or
範例 
● 觀察eth0網頁連線 
tcpdump -i eth0 tcp port 80 
● 觀察 eth1 arp 封包 
tcpdump -i eth1 arp 
● 觀察對 168.95.1.1 之 DNS 查詢 
tcpdump host 168.95.1.1 and udp port 53 
● 錄下 POP3封包 
tcpdump -w pop3.pcap tcp port 110 
● 觀察 TCP SYN 封包 
tcpdump ‘tcp[tcpflags] == 2’
練習1 
● 請問如下是什麼指令引起的封包? 
● 從哪個來源發起至哪個目的地?
練習2 
● 請從下載的封包檔中提取管理員(root)的密碼
wireshark
Wireshark 
● http://www.wireshark.org/ 
● 早期名稱為 ethereal 
● GUI 界面的封包截取工具 
● 可作為 sniffer 截取封包來分析 
● 亦可重組封包取出資料區
下載 
http://www.wireshark.org/download.html
安裝 
yum -y install wireshark wireshark-gnome
Sample Captures 
http://wiki.wireshark.org/SampleCaptures
執行
配置
截取選項
截取
分析 
● Follow Stream
IP來源分析 
● MaxMind GeoIP Database 
http://geolite.maxmind.com/download/geoip/da 
tabase/ 
● How To Use GeoIP With Wireshark 
http://wiki.wireshark.org/HowToUseGeoIP
IP來源分析 
● 起用 GeoIP
統計 
● 總覽
統計 
● 協定層級
統計 
● 對談
另存為...
參考資源 
● User’s Guide 
http://www.wireshark.org/docs/wsug_html_chunked/ 
● Display Filter Reference 
http://www.wireshark.org/docs/dfref/ 
● Wiki 
http://wiki.wireshark.org/ 
● Manual 
http://www.wireshark.org/docs/man-pages/ 
● FAQ 
http://www.wireshark.org/faq.html
ntop
ntop 
● http://www.ntop.org/ 
● 即時的流量分析/統計工具 
● 功能 
– Mirror Traffic 
– NetFlow/sFlow 
– In-Line Analysis
下載 
http://www.ntop.org/download.html
安裝 
wget http://pkgs.repoforge.org/rpmforge-release/ 
rpmforge-release-0.5.2-2.el5.rf.i386.rpm 
rpm -ivh rpmforge-release-0.5.2-2.el5.rf.i386.rpm 
yum install ntop
設定 
● 編輯 /etc/ntop.conf 
– --http-server=3000 
● 可變更 http server port 
– --interface=eth0 
● 可變更聆聽之網路界面 
– --local-subnets=xx.xx.xx.xx/yy 
● 定義本地端網段 
– 以及其他開放項目都要增加=
設定 
● 編輯 /etc/init.d/ntop (CentOS Only) 
– 把這行 
daemon $prog -d -L @/etc/ntop.conf 
– 修改為: 
daemon $prog @/etc/ntop.conf -d -L
啟動 
● ntop -A 
– 輸入登入密碼 
– Ctrl+C 停止 
● service ntop start 
● chkconfig ntop on
登入 
http://[IP]:3000/
參考資源 
● Ntop Blog 
http://www.ntop.org/blog/ 
● Ntop Overview 
http://www.ntop.org/ntop-overview.pdf 
● Ntop Presentation 
http://www.ntop.org/OpenSourceConf_Athens2 
008.pdf 
● Manpage 
http://www.ntop.org/ntop-man.html
mrtg
mrtg 
● http://www.mrtg.org/ 
● Multi Router Traffic Grapher 
● 利用SNMP、或客製指令抓取資料,並產生趨 
勢圖表 
● 可產生 日/週/月/年 下之平均數據 
● 常用來紀錄 
– 網路界面流量 
– 主機負載 (CPU/Memory/ … etc) 
– 磁碟使用率In-Line Analysis
安裝 
yum install mrtg net-snmp net-snmp-utils
設定 
● 修改 /etc/snmp/snmpd.conf 
● 在如下句子下修改: 
# YOU SHOULD CHANGE THE 
"COMMUNITY" TOKEN BELOW TO A NEW 
KEYWORD ONLY 
● 主要修改: 
com2sec local localhost netadmin 
com2sec mynetwork 10.10.10.0/24 netadmin
設定 
● 取消下行註解 
group MyRWGroup any local 
group MyROGroup any mynetwork 
view all included .1 80 
access MyROGroup "" any noauth 0 
all none none 
access MyRWGroup "" any noauth 0 
all all all
設定 
● 重新運行 snmpd 
service snmpd restart 
chkconfig snmpd on 
● 并以 snmpwalk 進行測試 
snmpwalk localhost -c netadmin -v 1
設定 
● 產生mrtg設定檔 
cd /etc/mrtg 
cfgmaker netadmin@[IP] >> mrtg.cfg 
● 執行 
LANG=C mrtg /etc/mrtg/mrtg.cfg 
● 執行三次 
● 產生mrtg首頁 
indexmaker --columns=1  
--output=/var/www/mrtg/index.html  
/etc/mrtg/mrtg.cfg
觀察結果 
● 起動 apache: 
service httpd restart 
chkconfig httpd on 
● 用瀏覽器察看: 
http://[ip]/mrtg 
● 或需修改: 
/etc/httpd/conf.d/mrtg.conf
cacti
cacti 
● http://www.cacti.net/ 
● 利用 php + mysql + rrdtool 畫出各種圖表的網 
管軟體 
● 常用來取代傳統的 mrtg 
● 可為各常用設備定義 template,套用方便
需求 
● php 
– 執行網頁界面 
● mysql 
– 存放網頁界面資料庫 
● rrdtool 
– 處理 rrd 資料 
● net-snmp 
– 抓取 snmp 資料
下載 
http://www.cacti.net/download_cacti.php
安裝 
yum -y install cacti mysql-server
資料庫處理 
● 啟動 MySQL 
– service mysqld start 
– chkconfig mysqld on 
● 建立 cacti 資料庫、帳號 
– mysql 
● mysql> create database cacti; 
● mysql> grant all on cacti.* to cacti@localhost 
identified by 'password'; 
● mysql> quit 
● 匯入資料庫 
– mysql cacti -u cacti -p < 
/var/www/cacti/cacti.sql
● 編輯設定檔 
– vim /var/www/cacti/include/config.php 
● $database_type = "mysql"; 
● $database_default = "cacti"; 
● $database_hostname = "localhost"; 
● $database_username = "cacti"; 
● $database_password = "password"; 
● $database_port = "3306"; 
● $url_path = “/cacti/”; 
● 重新起點 apache 
service apache restart
進入安裝界面 
http://[IP]/cacti/install/
選擇 New Install
選擇 Finish
登入 
● http://[IP]/cacti/ 
● 預設帳密為 admin/admin,登入後需改密碼
新增步驟 
● 新增主機 
– Devices → Add 
● 填入Description、Hostname 
● 選擇Host Template 
● 設定 SNMP Options(community) 
● Create
新增主機
新增步驟 
● 建立圖表 
– Devices → 點進該設備 → Create Graphs for 
this Host 
● 勾選欲建立之圖表後 
● Create
建立圖表 
建立圖表
新增步驟 
● 放置圖表 
– Devices → 勾選選擇該設備 (最右邊) 
● 下拉選單: 
– Place on a Tree 
● Go & Continue
放置圖表
● 管理圖表 
– Graph Trees → Add 
● 可建出各類設備之樹狀結構 
– Graph Management 
● 勾選欲置放之圖表 
● Choose an action: Place on a Tree 
– Destination Branch (如有子節點) 
– Yes
● 觀看圖表 
– 切換至 Graphs 標簽 
● 展開 Graph Tree 
● 選擇主機
觀看圖表
取得Host Template 
http://forums.cacti.net/forum-12.html
http://www.debianhelp.co.uk/cactitemplates.htm
匯入 Template
poller 
● cmd.php 
– 以 php 開發 
– cacti 預設的 poller script 
– 偵測主機多時效率不佳 
● spine (cactid) 
– 使用 C 語言開發 
– 以multi-process + multi-thread執行,效率較好
spine (cactid) 
http://www.cacti.net/spine_download.php
安裝spine 
● yum install cacti-spine
設定spine 
● 編輯設定檔 
– vim /etc/spine.conf 
● DB_Host localhost 
● DB_Database cacti 
● DB_User cacti 
● DB_Pass password 
● DB_Port 3306
使用 spine 
設定 spine 路徑(settings → Path: /usr/bin/spine)
更改 Poller Type
opennms
opennms 
● http://www.opennms.org/ 
● Open Source / Free 的監控工具 
● 網路狀態監控工具 
● 可發出即時 Alert 
● 常用於觀察 
● 主機服務 
● 網路節點狀態
安裝 
yum install opennms opennms-plugins 
opennms-plugins-nrpe 
* or 參考: 
http://eggchang.pixnet.net/blog/post/32659238
安裝與設定 PostgreSQL 
● 安裝 postgresql 
yum -y install postgresql postgresql-server 
postgresql-jdbc 
● 讓 postgresql 於開機時自動執行 
chkconfig --level 345 postgresql on 
● 第一次啟動 postgresql 
service postgresql start
● 修改 postgresql 啟動參數 
cd /var/lib/pgsql/data 
mv pg_hba.conf pg_hba.conf.bak 
sed 's/ident sameuser/trust/g' 
pg_hba.conf.bak > pg_hba.conf 
● 重新啟動 postgresql 
service postgresql restart
安裝與設定 JDK 
● 下載 jdk 
wget http://download.oracle.com/otn-pub/ 
java/jdk/6u22-b04/jdk-6u22-linux-i586- 
rpm.bin 
● 安裝 JDK 
bash jdk-6u22-linux-i586-rpm.bin
● 設定環境變數 
cat << EOF > /etc/profile.d/java.sh 
export JAVA_HOME=/usr/java/default 
export PATH=$JAVA_HOME/bin:$PATH 
EOF 
cat << EOF > /etc/profile.d/java.csh 
set JAVA_HOME=/usr/java/default 
set PATH=$JAVA_HOME/bin:$PATH 
EOF 
source /etc/profile.d/java.sh
下載與安裝 OpenNMS 
● 安裝 OpenNMS 的 yum repositories 
rpm -ivh 
http://yum.opennms.org/repofiles/open 
nms-repo-stable-rhel5.noarch.rpm 
● 建立與設定資料庫 
sudo -u postgres createdb -U postgres 
-E UNICODE opennms 
yum -y install iplike
● 安裝 OpenNMS 
yum -y install opennms mib2opennms 
opennms-* 
● 設定 OpenNMS 
/opt/opennms/bin/runjava -s 
/opt/opennms/bin/install -dis 
chkconfig opennms on 
● 啟動 OpenNMS 
service opennms start
http://[IP]:8980/opennms/
參考資源 
● OpenNMS Documentation 
– http://www.opennms.org/documentation 
● Official OpenNMS Documentation 
– http://support.opennms.com/knowledgebase/officialdocs 
● OpenNMS Wiki 
– http://wiki.opennms.org/index.php/Main_Page 
● Installation:Yum 
– http://www.opennms.org/wiki/Installation:Yum 
● OpenNMS Documentation Overview 
– http://www.opennms.org/wiki/Docu-overview 
● OpenNMS FAQ 
– http://www.opennms.org/wiki/FAQ
nagios
Nagios 
● http://www.nagios.org/ 
● Open Source / Free 的監控工具 
● 網路狀態監控工具 
● 可發出即時 Alert 
● 常用於觀察 
– 主機服務 
– 網路節點狀態
安裝 
● YUM 
yum install nagios*
系統設定 
● 建立httpd帳號 
htpasswd -c /etc/nagios/htpasswd.users 
nagiosadmin 
htpasswd /etc/nagios/htpasswd.users 
nagiosuser 
● 啟動服務 
service httpd restart 
service nagios start 
chkconfig httpd on 
chkconfig nagios on
測試連線 
● 檢查設定檔語法 
nagios -v /etc/nagios/nagios.cfg 
● http://127.0.0.1/nagios/ 
– 以 nagiosadmin 登入
設定 
● 修改管理員信箱 
vi /etc/nagios/objects/contacts.cfg 
define contact{ 
email user@domain ;
設定 
● 設定 nrpe 
echo 'nrpe 5666/tcp' >> /etc/services 
serivce nrpe start 
chkconfig nrpe on
設定 
● 測試 nrpe 
/usr/lib/nagios/plugins/check_nrpe -H 
localhost -c check_users 
/usr/lib/nagios/plugins/check_nrpe -H 
localhost -c check_load 
/usr/lib/nagios/plugins/check_nrpe -H 
localhost -c check_total_procs 
/usr/lib/nagios/plugins/check_nrpe -H 
localhost -c check_zombie_procs
設定 
● 測試硬碟空間 
vi /etc/nagios/nrpe.cfg 
allowed_hosts=127.0.0.1,ip.ip.ip.ip 
command[check_root_space]=/usr/l 
ib/nagios/plugins/check_disk -w 
20% -c 10% -p /dev/VG/root_LV 
serive nrpe restart 
/usr/lib/nagios/plugins/check_nrpe -H 
localhost -c check_root_space
設定 
● 建立主機組態 
cp /etc/nagios/objects/windows.cfg 
/etc/nagios/objects/linux.cfg 
vi /etc/nagios/objects/linux.cfg 
● use linux-server 
● host_name linuxserver 
● Address 10.10.2.1 
● hostgroup_name linux-servers
設定 
● vi /etc/nagios/objects/linux.cfg 
– 把全部 host_name 從 winserver 修改 
為 linuxserver (前面定義的) 
– 刪除多餘的 service { … } 
define service{ 
use generic-service 
host_name linuxserver 
service_description Online Users 
check_command check_nrpe!check_users 
}
設定 
● 定義 nrpe 命令 
vi /etc/nagios/objects/commands.cfg 
# 'check_nrpe' command definition 
define command{ 
command_name check_nrpe 
command_line $USER1$/check_nrpe -H 
$HOSTADDRESS$ -c $ARG1$ 
}
設定 
● 修改 /etc/nagios/nagios.cfg : 
cfg_file=/etc/nagios/objects/linux.cfg 
● 檢查組態 
nagios -v /etc/nagios/nagios.cfg 
● 重新執行服務 
service nagios restart
參考資源 
● OpenNagios 
– http://software.opensuse.org/ymp/openS 
USE:11.3/standard/nagios.ymp 
● Nagios Plugins 
– http://software.opensuse.org/ymp/openS 
USE:11.3/standard/nagios-plugins.ymp 
● Nagios Addons Extras 
– http://software.opensuse.org/ymp/openS 
USE:11.3/standard/nagios-plugins-extras. 
ymp
Q & A

Mais conteúdo relacionado

Mais procurados

再生龍於雲端環境之應用
再生龍於雲端環境之應用再生龍於雲端環境之應用
再生龍於雲端環境之應用Chenkai Sun
 
X64服务器 lamp服务器部署标准 new
X64服务器 lamp服务器部署标准 newX64服务器 lamp服务器部署标准 new
X64服务器 lamp服务器部署标准 newYiwei Ma
 
Apache trafficserver
Apache trafficserverApache trafficserver
Apache trafficserverDin Dindin
 
《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具
《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具
《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具Will Huang
 
Golang 高性能实战
Golang 高性能实战Golang 高性能实战
Golang 高性能实战rfyiamcool
 
使用Nginx轻松实现开源负载均衡
使用Nginx轻松实现开源负载均衡使用Nginx轻松实现开源负载均衡
使用Nginx轻松实现开源负载均衡guest2d0fe3
 
使用Nginx轻松实现开源负载均衡
使用Nginx轻松实现开源负载均衡使用Nginx轻松实现开源负载均衡
使用Nginx轻松实现开源负载均衡Cary Yang
 
高性能Web服务器Nginx及相关新技术的应用实践
高性能Web服务器Nginx及相关新技术的应用实践高性能Web服务器Nginx及相关新技术的应用实践
高性能Web服务器Nginx及相关新技术的应用实践rewinx
 
聊聊我接触的集群管理
聊聊我接触的集群管理聊聊我接触的集群管理
聊聊我接触的集群管理rfyiamcool
 
使用Nginx轻松实现开源负载均衡——对外版
使用Nginx轻松实现开源负载均衡——对外版使用Nginx轻松实现开源负载均衡——对外版
使用Nginx轻松实现开源负载均衡——对外版pigso
 
lua & ngx_lua 的介绍与应用
lua & ngx_lua 的介绍与应用lua & ngx_lua 的介绍与应用
lua & ngx_lua 的介绍与应用hugo
 
Mysql proxy+mysql-mmm
Mysql proxy+mysql-mmmMysql proxy+mysql-mmm
Mysql proxy+mysql-mmmYiwei Ma
 
PHP Optimization for Millions Visits Level
PHP Optimization for Millions Visits LevelPHP Optimization for Millions Visits Level
PHP Optimization for Millions Visits LevelHo Kim
 
2012 php conf slide PIXNET 如何使用 php
2012 php conf slide   PIXNET 如何使用 php2012 php conf slide   PIXNET 如何使用 php
2012 php conf slide PIXNET 如何使用 phpronnywang_tw
 
淘宝主备数据库自动切换
淘宝主备数据库自动切换淘宝主备数据库自动切换
淘宝主备数据库自动切换mysqlops
 
使用Rpm&yum进行基础软件管理
使用Rpm&yum进行基础软件管理使用Rpm&yum进行基础软件管理
使用Rpm&yum进行基础软件管理haiyuan ning
 
Apache+php+mysql在Linux下的安装与配置
Apache+php+mysql在Linux下的安装与配置Apache+php+mysql在Linux下的安装与配置
Apache+php+mysql在Linux下的安装与配置wensheng wei
 
Track2 -刘继伟--openstack in gamewave
Track2 -刘继伟--openstack in gamewaveTrack2 -刘继伟--openstack in gamewave
Track2 -刘继伟--openstack in gamewaveOpenCity Community
 
系统性能分析和优化.ppt
系统性能分析和优化.ppt系统性能分析和优化.ppt
系统性能分析和优化.pptFrank Cai
 
构建ActionScript游戏服务器,支持超过15000并发连接
构建ActionScript游戏服务器,支持超过15000并发连接 构建ActionScript游戏服务器,支持超过15000并发连接
构建ActionScript游戏服务器,支持超过15000并发连接 Renaun Erickson
 

Mais procurados (20)

再生龍於雲端環境之應用
再生龍於雲端環境之應用再生龍於雲端環境之應用
再生龍於雲端環境之應用
 
X64服务器 lamp服务器部署标准 new
X64服务器 lamp服务器部署标准 newX64服务器 lamp服务器部署标准 new
X64服务器 lamp服务器部署标准 new
 
Apache trafficserver
Apache trafficserverApache trafficserver
Apache trafficserver
 
《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具
《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具
《保哥線上講堂》打造一個具有 Linux 溫度的 Windows 命令提示字元工具
 
Golang 高性能实战
Golang 高性能实战Golang 高性能实战
Golang 高性能实战
 
使用Nginx轻松实现开源负载均衡
使用Nginx轻松实现开源负载均衡使用Nginx轻松实现开源负载均衡
使用Nginx轻松实现开源负载均衡
 
使用Nginx轻松实现开源负载均衡
使用Nginx轻松实现开源负载均衡使用Nginx轻松实现开源负载均衡
使用Nginx轻松实现开源负载均衡
 
高性能Web服务器Nginx及相关新技术的应用实践
高性能Web服务器Nginx及相关新技术的应用实践高性能Web服务器Nginx及相关新技术的应用实践
高性能Web服务器Nginx及相关新技术的应用实践
 
聊聊我接触的集群管理
聊聊我接触的集群管理聊聊我接触的集群管理
聊聊我接触的集群管理
 
使用Nginx轻松实现开源负载均衡——对外版
使用Nginx轻松实现开源负载均衡——对外版使用Nginx轻松实现开源负载均衡——对外版
使用Nginx轻松实现开源负载均衡——对外版
 
lua & ngx_lua 的介绍与应用
lua & ngx_lua 的介绍与应用lua & ngx_lua 的介绍与应用
lua & ngx_lua 的介绍与应用
 
Mysql proxy+mysql-mmm
Mysql proxy+mysql-mmmMysql proxy+mysql-mmm
Mysql proxy+mysql-mmm
 
PHP Optimization for Millions Visits Level
PHP Optimization for Millions Visits LevelPHP Optimization for Millions Visits Level
PHP Optimization for Millions Visits Level
 
2012 php conf slide PIXNET 如何使用 php
2012 php conf slide   PIXNET 如何使用 php2012 php conf slide   PIXNET 如何使用 php
2012 php conf slide PIXNET 如何使用 php
 
淘宝主备数据库自动切换
淘宝主备数据库自动切换淘宝主备数据库自动切换
淘宝主备数据库自动切换
 
使用Rpm&yum进行基础软件管理
使用Rpm&yum进行基础软件管理使用Rpm&yum进行基础软件管理
使用Rpm&yum进行基础软件管理
 
Apache+php+mysql在Linux下的安装与配置
Apache+php+mysql在Linux下的安装与配置Apache+php+mysql在Linux下的安装与配置
Apache+php+mysql在Linux下的安装与配置
 
Track2 -刘继伟--openstack in gamewave
Track2 -刘继伟--openstack in gamewaveTrack2 -刘继伟--openstack in gamewave
Track2 -刘继伟--openstack in gamewave
 
系统性能分析和优化.ppt
系统性能分析和优化.ppt系统性能分析和优化.ppt
系统性能分析和优化.ppt
 
构建ActionScript游戏服务器,支持超过15000并发连接
构建ActionScript游戏服务器,支持超过15000并发连接 构建ActionScript游戏服务器,支持超过15000并发连接
构建ActionScript游戏服务器,支持超过15000并发连接
 

Destaque

Linux fundamental - Chap 02 perm
Linux fundamental - Chap 02 permLinux fundamental - Chap 02 perm
Linux fundamental - Chap 02 permKenny (netman)
 
Docker on Windows
Docker on WindowsDocker on Windows
Docker on WindowsCarl Su
 
Using Selenium to Test Native Apps (Wait, you can do that?)
Using Selenium to Test Native Apps (Wait, you can do that?)Using Selenium to Test Native Apps (Wait, you can do that?)
Using Selenium to Test Native Apps (Wait, you can do that?)Sauce Labs
 
Linux fundamental - Chap 16 System Rescue
Linux fundamental - Chap 16 System RescueLinux fundamental - Chap 16 System Rescue
Linux fundamental - Chap 16 System RescueKenny (netman)
 
Ras pioverview
Ras pioverviewRas pioverview
Ras pioverviewAlec Clews
 
Linux pipe & redirection
Linux pipe & redirectionLinux pipe & redirection
Linux pipe & redirectionColin Su
 
Unix tutorial-08
Unix tutorial-08Unix tutorial-08
Unix tutorial-08Tushar Jain
 
Linux fundamentals
Linux fundamentalsLinux fundamentals
Linux fundamentalschakrikolla
 
Power point (asking permission)
Power point (asking permission)Power point (asking permission)
Power point (asking permission)ahmaddarda1505
 
Linux fundamental - Chap 13 account management
Linux fundamental - Chap 13 account managementLinux fundamental - Chap 13 account management
Linux fundamental - Chap 13 account managementKenny (netman)
 
Linux fundamental - Chap 05 filter
Linux fundamental - Chap 05 filterLinux fundamental - Chap 05 filter
Linux fundamental - Chap 05 filterKenny (netman)
 
Linux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkgLinux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkgKenny (netman)
 
Linux fundamental - Chap 14 shell script
Linux fundamental - Chap 14 shell scriptLinux fundamental - Chap 14 shell script
Linux fundamental - Chap 14 shell scriptKenny (netman)
 

Destaque (20)

Linux fundamental - Chap 02 perm
Linux fundamental - Chap 02 permLinux fundamental - Chap 02 perm
Linux fundamental - Chap 02 perm
 
Docker on Windows
Docker on WindowsDocker on Windows
Docker on Windows
 
Using Selenium to Test Native Apps (Wait, you can do that?)
Using Selenium to Test Native Apps (Wait, you can do that?)Using Selenium to Test Native Apps (Wait, you can do that?)
Using Selenium to Test Native Apps (Wait, you can do that?)
 
Linux fundamental - Chap 16 System Rescue
Linux fundamental - Chap 16 System RescueLinux fundamental - Chap 16 System Rescue
Linux fundamental - Chap 16 System Rescue
 
Chap 17 advfs
Chap 17 advfsChap 17 advfs
Chap 17 advfs
 
Chap 18 net
Chap 18 netChap 18 net
Chap 18 net
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
 
Ras pioverview
Ras pioverviewRas pioverview
Ras pioverview
 
Linux pipe & redirection
Linux pipe & redirectionLinux pipe & redirection
Linux pipe & redirection
 
Unix tutorial-08
Unix tutorial-08Unix tutorial-08
Unix tutorial-08
 
Linux fundamentals
Linux fundamentalsLinux fundamentals
Linux fundamentals
 
Basics of-linux
Basics of-linuxBasics of-linux
Basics of-linux
 
Your first linux programs
Your first linux programsYour first linux programs
Your first linux programs
 
Power point (asking permission)
Power point (asking permission)Power point (asking permission)
Power point (asking permission)
 
Unix - Filters/Editors
Unix - Filters/EditorsUnix - Filters/Editors
Unix - Filters/Editors
 
Chap 19 web
Chap 19 webChap 19 web
Chap 19 web
 
Linux fundamental - Chap 13 account management
Linux fundamental - Chap 13 account managementLinux fundamental - Chap 13 account management
Linux fundamental - Chap 13 account management
 
Linux fundamental - Chap 05 filter
Linux fundamental - Chap 05 filterLinux fundamental - Chap 05 filter
Linux fundamental - Chap 05 filter
 
Linux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkgLinux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkg
 
Linux fundamental - Chap 14 shell script
Linux fundamental - Chap 14 shell scriptLinux fundamental - Chap 14 shell script
Linux fundamental - Chap 14 shell script
 

Semelhante a Linux network monitoring hands-on pratice

Node.js從無到有 基本課程
Node.js從無到有 基本課程Node.js從無到有 基本課程
Node.js從無到有 基本課程Simon Su
 
Oraliux+mysql5单机多实例安装文档
Oraliux+mysql5单机多实例安装文档Oraliux+mysql5单机多实例安装文档
Oraliux+mysql5单机多实例安装文档xuebao_zx
 
Nagios的安装部署和与cacti的整合(linuxtone)
Nagios的安装部署和与cacti的整合(linuxtone)Nagios的安装部署和与cacti的整合(linuxtone)
Nagios的安装部署和与cacti的整合(linuxtone)Yiwei Ma
 
Bypat博客出品-利用cent os快速构建自己的发行版
Bypat博客出品-利用cent os快速构建自己的发行版Bypat博客出品-利用cent os快速构建自己的发行版
Bypat博客出品-利用cent os快速构建自己的发行版redhat9
 
Puppet安装总结
Puppet安装总结Puppet安装总结
Puppet安装总结Yiwei Ma
 
Open Street Map安裝指引 (Ubuntu 12.04)
Open Street Map安裝指引 (Ubuntu 12.04)Open Street Map安裝指引 (Ubuntu 12.04)
Open Street Map安裝指引 (Ubuntu 12.04)Marc Huang
 
Hadoop+spark實作
Hadoop+spark實作Hadoop+spark實作
Hadoop+spark實作FEG
 
StackOps step by-step guide
StackOps step by-step guideStackOps step by-step guide
StackOps step by-step guideslmagicbox
 
Mysql mmm演讲--冯浩
Mysql mmm演讲--冯浩Mysql mmm演讲--冯浩
Mysql mmm演讲--冯浩chinafenghao
 
Mysql mmm演讲-冯浩
Mysql mmm演讲-冯浩Mysql mmm演讲-冯浩
Mysql mmm演讲-冯浩chinafenghao
 
Mysql mmm演讲-冯浩
Mysql mmm演讲-冯浩Mysql mmm演讲-冯浩
Mysql mmm演讲-冯浩chinafenghao
 
Monitor is all for ops
Monitor is all for opsMonitor is all for ops
Monitor is all for ops琛琳 饶
 
南投替代役整理組數位典藏報告
南投替代役整理組數位典藏報告南投替代役整理組數位典藏報告
南投替代役整理組數位典藏報告Bo-Yi Wu
 
Elastic stack day-2
Elastic stack day-2Elastic stack day-2
Elastic stack day-2YI-CHING WU
 
用Raspberry PI學Linux驅動程式
用Raspberry PI學Linux驅動程式用Raspberry PI學Linux驅動程式
用Raspberry PI學Linux驅動程式Stanley Ho
 
Ruby on Rails 開發環境建置 for Ubuntu
Ruby on Rails 開發環境建置 for UbuntuRuby on Rails 開發環境建置 for Ubuntu
Ruby on Rails 開發環境建置 for UbuntuMarsZ Chen
 
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUGYingSiang Geng
 

Semelhante a Linux network monitoring hands-on pratice (20)

Node.js從無到有 基本課程
Node.js從無到有 基本課程Node.js從無到有 基本課程
Node.js從無到有 基本課程
 
Oraliux+mysql5单机多实例安装文档
Oraliux+mysql5单机多实例安装文档Oraliux+mysql5单机多实例安装文档
Oraliux+mysql5单机多实例安装文档
 
Nagios的安装部署和与cacti的整合(linuxtone)
Nagios的安装部署和与cacti的整合(linuxtone)Nagios的安装部署和与cacti的整合(linuxtone)
Nagios的安装部署和与cacti的整合(linuxtone)
 
Bypat博客出品-利用cent os快速构建自己的发行版
Bypat博客出品-利用cent os快速构建自己的发行版Bypat博客出品-利用cent os快速构建自己的发行版
Bypat博客出品-利用cent os快速构建自己的发行版
 
Puppet安装总结
Puppet安装总结Puppet安装总结
Puppet安装总结
 
Outside
OutsideOutside
Outside
 
Open Street Map安裝指引 (Ubuntu 12.04)
Open Street Map安裝指引 (Ubuntu 12.04)Open Street Map安裝指引 (Ubuntu 12.04)
Open Street Map安裝指引 (Ubuntu 12.04)
 
Hadoop+spark實作
Hadoop+spark實作Hadoop+spark實作
Hadoop+spark實作
 
StackOps step by-step guide
StackOps step by-step guideStackOps step by-step guide
StackOps step by-step guide
 
Mysql mmm演讲--冯浩
Mysql mmm演讲--冯浩Mysql mmm演讲--冯浩
Mysql mmm演讲--冯浩
 
Mysql mmm演讲-冯浩
Mysql mmm演讲-冯浩Mysql mmm演讲-冯浩
Mysql mmm演讲-冯浩
 
Mysql mmm演讲-冯浩
Mysql mmm演讲-冯浩Mysql mmm演讲-冯浩
Mysql mmm演讲-冯浩
 
Monitor is all for ops
Monitor is all for opsMonitor is all for ops
Monitor is all for ops
 
Linuxguide4f2e
Linuxguide4f2eLinuxguide4f2e
Linuxguide4f2e
 
LinuxGuide4F2E
LinuxGuide4F2ELinuxGuide4F2E
LinuxGuide4F2E
 
南投替代役整理組數位典藏報告
南投替代役整理組數位典藏報告南投替代役整理組數位典藏報告
南投替代役整理組數位典藏報告
 
Elastic stack day-2
Elastic stack day-2Elastic stack day-2
Elastic stack day-2
 
用Raspberry PI學Linux驅動程式
用Raspberry PI學Linux驅動程式用Raspberry PI學Linux驅動程式
用Raspberry PI學Linux驅動程式
 
Ruby on Rails 開發環境建置 for Ubuntu
Ruby on Rails 開發環境建置 for UbuntuRuby on Rails 開發環境建置 for Ubuntu
Ruby on Rails 開發環境建置 for Ubuntu
 
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
 

Mais de Kenny (netman)

rpi_audio configuration steps
rpi_audio configuration stepsrpi_audio configuration steps
rpi_audio configuration stepsKenny (netman)
 
Importance of linux system fundamental in technical documentation reading
Importance of linux system fundamental in technical documentation readingImportance of linux system fundamental in technical documentation reading
Importance of linux system fundamental in technical documentation readingKenny (netman)
 
Linux fundamental - Chap 15 Job Scheduling
Linux fundamental - Chap 15 Job SchedulingLinux fundamental - Chap 15 Job Scheduling
Linux fundamental - Chap 15 Job SchedulingKenny (netman)
 
Linux fundamental - Chap 12 Hardware Management
Linux fundamental - Chap 12 Hardware ManagementLinux fundamental - Chap 12 Hardware Management
Linux fundamental - Chap 12 Hardware ManagementKenny (netman)
 
Linux fundamental - Chap 11 boot
Linux fundamental - Chap 11 bootLinux fundamental - Chap 11 boot
Linux fundamental - Chap 11 bootKenny (netman)
 
Linux fundamental - Chap 10 fs
Linux fundamental - Chap 10 fsLinux fundamental - Chap 10 fs
Linux fundamental - Chap 10 fsKenny (netman)
 
Linux fundamental - Chap 08 proc
Linux fundamental - Chap 08 procLinux fundamental - Chap 08 proc
Linux fundamental - Chap 08 procKenny (netman)
 
Linux fundamental - Chap 07 vi
Linux fundamental - Chap 07 viLinux fundamental - Chap 07 vi
Linux fundamental - Chap 07 viKenny (netman)
 
Linux fundamental - Chap 06 regx
Linux fundamental - Chap 06 regxLinux fundamental - Chap 06 regx
Linux fundamental - Chap 06 regxKenny (netman)
 
Linux fundamental - Chap 04 archive
Linux fundamental - Chap 04 archiveLinux fundamental - Chap 04 archive
Linux fundamental - Chap 04 archiveKenny (netman)
 
Linux fundamental - Chap 03 file
Linux fundamental - Chap 03 fileLinux fundamental - Chap 03 file
Linux fundamental - Chap 03 fileKenny (netman)
 
Linux fundamental - Chap 01 io
Linux fundamental - Chap 01 ioLinux fundamental - Chap 01 io
Linux fundamental - Chap 01 ioKenny (netman)
 
Linux fundamental - Chap 00 shell
Linux fundamental - Chap 00 shellLinux fundamental - Chap 00 shell
Linux fundamental - Chap 00 shellKenny (netman)
 

Mais de Kenny (netman) (19)

rpi_audio configuration steps
rpi_audio configuration stepsrpi_audio configuration steps
rpi_audio configuration steps
 
Rpi audio
Rpi audioRpi audio
Rpi audio
 
Importance of linux system fundamental in technical documentation reading
Importance of linux system fundamental in technical documentation readingImportance of linux system fundamental in technical documentation reading
Importance of linux system fundamental in technical documentation reading
 
Ha opensuse
Ha opensuseHa opensuse
Ha opensuse
 
About the Course
About the CourseAbout the Course
About the Course
 
Linux fundamental - Chap 15 Job Scheduling
Linux fundamental - Chap 15 Job SchedulingLinux fundamental - Chap 15 Job Scheduling
Linux fundamental - Chap 15 Job Scheduling
 
Linux fundamental - Chap 12 Hardware Management
Linux fundamental - Chap 12 Hardware ManagementLinux fundamental - Chap 12 Hardware Management
Linux fundamental - Chap 12 Hardware Management
 
Linux fundamental - Chap 11 boot
Linux fundamental - Chap 11 bootLinux fundamental - Chap 11 boot
Linux fundamental - Chap 11 boot
 
Linux fundamental - Chap 10 fs
Linux fundamental - Chap 10 fsLinux fundamental - Chap 10 fs
Linux fundamental - Chap 10 fs
 
Linux fundamental - Chap 08 proc
Linux fundamental - Chap 08 procLinux fundamental - Chap 08 proc
Linux fundamental - Chap 08 proc
 
Linux fundamental - Chap 07 vi
Linux fundamental - Chap 07 viLinux fundamental - Chap 07 vi
Linux fundamental - Chap 07 vi
 
Linux fundamental - Chap 06 regx
Linux fundamental - Chap 06 regxLinux fundamental - Chap 06 regx
Linux fundamental - Chap 06 regx
 
Linux fundamental - Chap 04 archive
Linux fundamental - Chap 04 archiveLinux fundamental - Chap 04 archive
Linux fundamental - Chap 04 archive
 
Linux fundamental - Chap 03 file
Linux fundamental - Chap 03 fileLinux fundamental - Chap 03 file
Linux fundamental - Chap 03 file
 
Linux fundamental - Chap 01 io
Linux fundamental - Chap 01 ioLinux fundamental - Chap 01 io
Linux fundamental - Chap 01 io
 
Linux fundamental - Chap 00 shell
Linux fundamental - Chap 00 shellLinux fundamental - Chap 00 shell
Linux fundamental - Chap 00 shell
 
加密應用(GPG)
加密應用(GPG)加密應用(GPG)
加密應用(GPG)
 
金鑰管理 (PKI)
金鑰管理 (PKI)金鑰管理 (PKI)
金鑰管理 (PKI)
 
Linux firewall
Linux firewallLinux firewall
Linux firewall
 

Linux network monitoring hands-on pratice

  • 1. 網路監控 實作 by netman<netman@study-area.org>
  • 2. 主題大綱 ● Tcpdump ● Wireshark ● Ntop ● Mrtg ● Cacti ● Nagios ● OpenNMS
  • 4. tcpdump ● http://www.tcpdump.org/ ● CLI 模式的封包截取工具 ● 使用 libpcap 作為封包處理函式庫 ● 大多數 Unix-based 作業系統均內建
  • 5. 截取參數 -D 顯示所有可截取的網卡 -i [interface] 選擇網卡 any 表示所有的網卡 -p 不將網卡切入 promiscuous mode -F [file] 由指定的檔案讀取 Filter Expression -s 限制封包長度 (預設為 68 bytes) 0 表示不限制,錄下完整封包
  • 6. 儲存參數 -c [封包數] 錄下指令數量的封包後停止 -C [檔案大小] 限制記錄檔案之大小 (搭配 -w 指定檔名) 達到上限時將開新檔繼續儲存 單位為 1,000,000 bytes -W [檔案數] 限制 -C 參數儲存之檔案數量
  • 7. 檔案參數 -w [file] 將截取封包寫入至檔案 -U 搭配 -w 寫入檔案時,不作緩存 -r [file] 由指定檔案取得封包
  • 8. 顯視參數 -A 以 ASCII 字元顯示封包內容 -e 顯示 Link Layer 資訊 (例如MAC-Address) -n 不作名稱解析 (主機名稱、服務名稱… etc) -v 顯示較詳細的封包資訊 -v 、 -vv 、 -vvv 三種等級 -x / -xx 將封包內容以 hex 格式顯示 -X / -XX 將封包內容以 hex 及 ASCII 格式顯示
  • 9. 時間參數 -t 不顯示時間戳記 -tt 顯示 UNIX timestamp 格式 -ttt 顯示每個封包之間隔 (micro seconds) -tttt 顯示標準格式 (yyyy-mm-dd hh:mm:ss.ms)
  • 10. 協定參數 Layer 2 arp rarp stp vlan Layer 3 ip ip6 Layer 4 tcp udp icmp
  • 11. 目標參數 src/dst ether host net port
  • 13. 數值運算 = : equal < : less > : greater
  • 14. 羅輯運算 ! : not && : and || : or
  • 15. 範例 ● 觀察eth0網頁連線 tcpdump -i eth0 tcp port 80 ● 觀察 eth1 arp 封包 tcpdump -i eth1 arp ● 觀察對 168.95.1.1 之 DNS 查詢 tcpdump host 168.95.1.1 and udp port 53 ● 錄下 POP3封包 tcpdump -w pop3.pcap tcp port 110 ● 觀察 TCP SYN 封包 tcpdump ‘tcp[tcpflags] == 2’
  • 16. 練習1 ● 請問如下是什麼指令引起的封包? ● 從哪個來源發起至哪個目的地?
  • 19. Wireshark ● http://www.wireshark.org/ ● 早期名稱為 ethereal ● GUI 界面的封包截取工具 ● 可作為 sniffer 截取封包來分析 ● 亦可重組封包取出資料區
  • 21. 安裝 yum -y install wireshark wireshark-gnome
  • 28. IP來源分析 ● MaxMind GeoIP Database http://geolite.maxmind.com/download/geoip/da tabase/ ● How To Use GeoIP With Wireshark http://wiki.wireshark.org/HowToUseGeoIP
  • 30.
  • 35. 參考資源 ● User’s Guide http://www.wireshark.org/docs/wsug_html_chunked/ ● Display Filter Reference http://www.wireshark.org/docs/dfref/ ● Wiki http://wiki.wireshark.org/ ● Manual http://www.wireshark.org/docs/man-pages/ ● FAQ http://www.wireshark.org/faq.html
  • 36. ntop
  • 37. ntop ● http://www.ntop.org/ ● 即時的流量分析/統計工具 ● 功能 – Mirror Traffic – NetFlow/sFlow – In-Line Analysis
  • 39. 安裝 wget http://pkgs.repoforge.org/rpmforge-release/ rpmforge-release-0.5.2-2.el5.rf.i386.rpm rpm -ivh rpmforge-release-0.5.2-2.el5.rf.i386.rpm yum install ntop
  • 40. 設定 ● 編輯 /etc/ntop.conf – --http-server=3000 ● 可變更 http server port – --interface=eth0 ● 可變更聆聽之網路界面 – --local-subnets=xx.xx.xx.xx/yy ● 定義本地端網段 – 以及其他開放項目都要增加=
  • 41. 設定 ● 編輯 /etc/init.d/ntop (CentOS Only) – 把這行 daemon $prog -d -L @/etc/ntop.conf – 修改為: daemon $prog @/etc/ntop.conf -d -L
  • 42. 啟動 ● ntop -A – 輸入登入密碼 – Ctrl+C 停止 ● service ntop start ● chkconfig ntop on
  • 44. 參考資源 ● Ntop Blog http://www.ntop.org/blog/ ● Ntop Overview http://www.ntop.org/ntop-overview.pdf ● Ntop Presentation http://www.ntop.org/OpenSourceConf_Athens2 008.pdf ● Manpage http://www.ntop.org/ntop-man.html
  • 45. mrtg
  • 46. mrtg ● http://www.mrtg.org/ ● Multi Router Traffic Grapher ● 利用SNMP、或客製指令抓取資料,並產生趨 勢圖表 ● 可產生 日/週/月/年 下之平均數據 ● 常用來紀錄 – 網路界面流量 – 主機負載 (CPU/Memory/ … etc) – 磁碟使用率In-Line Analysis
  • 47. 安裝 yum install mrtg net-snmp net-snmp-utils
  • 48. 設定 ● 修改 /etc/snmp/snmpd.conf ● 在如下句子下修改: # YOU SHOULD CHANGE THE "COMMUNITY" TOKEN BELOW TO A NEW KEYWORD ONLY ● 主要修改: com2sec local localhost netadmin com2sec mynetwork 10.10.10.0/24 netadmin
  • 49. 設定 ● 取消下行註解 group MyRWGroup any local group MyROGroup any mynetwork view all included .1 80 access MyROGroup "" any noauth 0 all none none access MyRWGroup "" any noauth 0 all all all
  • 50. 設定 ● 重新運行 snmpd service snmpd restart chkconfig snmpd on ● 并以 snmpwalk 進行測試 snmpwalk localhost -c netadmin -v 1
  • 51. 設定 ● 產生mrtg設定檔 cd /etc/mrtg cfgmaker netadmin@[IP] >> mrtg.cfg ● 執行 LANG=C mrtg /etc/mrtg/mrtg.cfg ● 執行三次 ● 產生mrtg首頁 indexmaker --columns=1 --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg
  • 52. 觀察結果 ● 起動 apache: service httpd restart chkconfig httpd on ● 用瀏覽器察看: http://[ip]/mrtg ● 或需修改: /etc/httpd/conf.d/mrtg.conf
  • 53. cacti
  • 54. cacti ● http://www.cacti.net/ ● 利用 php + mysql + rrdtool 畫出各種圖表的網 管軟體 ● 常用來取代傳統的 mrtg ● 可為各常用設備定義 template,套用方便
  • 55. 需求 ● php – 執行網頁界面 ● mysql – 存放網頁界面資料庫 ● rrdtool – 處理 rrd 資料 ● net-snmp – 抓取 snmp 資料
  • 57. 安裝 yum -y install cacti mysql-server
  • 58. 資料庫處理 ● 啟動 MySQL – service mysqld start – chkconfig mysqld on ● 建立 cacti 資料庫、帳號 – mysql ● mysql> create database cacti; ● mysql> grant all on cacti.* to cacti@localhost identified by 'password'; ● mysql> quit ● 匯入資料庫 – mysql cacti -u cacti -p < /var/www/cacti/cacti.sql
  • 59. ● 編輯設定檔 – vim /var/www/cacti/include/config.php ● $database_type = "mysql"; ● $database_default = "cacti"; ● $database_hostname = "localhost"; ● $database_username = "cacti"; ● $database_password = "password"; ● $database_port = "3306"; ● $url_path = “/cacti/”; ● 重新起點 apache service apache restart
  • 63. 登入 ● http://[IP]/cacti/ ● 預設帳密為 admin/admin,登入後需改密碼
  • 64. 新增步驟 ● 新增主機 – Devices → Add ● 填入Description、Hostname ● 選擇Host Template ● 設定 SNMP Options(community) ● Create
  • 66. 新增步驟 ● 建立圖表 – Devices → 點進該設備 → Create Graphs for this Host ● 勾選欲建立之圖表後 ● Create
  • 68. 新增步驟 ● 放置圖表 – Devices → 勾選選擇該設備 (最右邊) ● 下拉選單: – Place on a Tree ● Go & Continue
  • 70. ● 管理圖表 – Graph Trees → Add ● 可建出各類設備之樹狀結構 – Graph Management ● 勾選欲置放之圖表 ● Choose an action: Place on a Tree – Destination Branch (如有子節點) – Yes
  • 71. ● 觀看圖表 – 切換至 Graphs 標簽 ● 展開 Graph Tree ● 選擇主機
  • 76. poller ● cmd.php – 以 php 開發 – cacti 預設的 poller script – 偵測主機多時效率不佳 ● spine (cactid) – 使用 C 語言開發 – 以multi-process + multi-thread執行,效率較好
  • 78. 安裝spine ● yum install cacti-spine
  • 79. 設定spine ● 編輯設定檔 – vim /etc/spine.conf ● DB_Host localhost ● DB_Database cacti ● DB_User cacti ● DB_Pass password ● DB_Port 3306
  • 80. 使用 spine 設定 spine 路徑(settings → Path: /usr/bin/spine)
  • 83. opennms ● http://www.opennms.org/ ● Open Source / Free 的監控工具 ● 網路狀態監控工具 ● 可發出即時 Alert ● 常用於觀察 ● 主機服務 ● 網路節點狀態
  • 84. 安裝 yum install opennms opennms-plugins opennms-plugins-nrpe * or 參考: http://eggchang.pixnet.net/blog/post/32659238
  • 85. 安裝與設定 PostgreSQL ● 安裝 postgresql yum -y install postgresql postgresql-server postgresql-jdbc ● 讓 postgresql 於開機時自動執行 chkconfig --level 345 postgresql on ● 第一次啟動 postgresql service postgresql start
  • 86. ● 修改 postgresql 啟動參數 cd /var/lib/pgsql/data mv pg_hba.conf pg_hba.conf.bak sed 's/ident sameuser/trust/g' pg_hba.conf.bak > pg_hba.conf ● 重新啟動 postgresql service postgresql restart
  • 87. 安裝與設定 JDK ● 下載 jdk wget http://download.oracle.com/otn-pub/ java/jdk/6u22-b04/jdk-6u22-linux-i586- rpm.bin ● 安裝 JDK bash jdk-6u22-linux-i586-rpm.bin
  • 88. ● 設定環境變數 cat << EOF > /etc/profile.d/java.sh export JAVA_HOME=/usr/java/default export PATH=$JAVA_HOME/bin:$PATH EOF cat << EOF > /etc/profile.d/java.csh set JAVA_HOME=/usr/java/default set PATH=$JAVA_HOME/bin:$PATH EOF source /etc/profile.d/java.sh
  • 89. 下載與安裝 OpenNMS ● 安裝 OpenNMS 的 yum repositories rpm -ivh http://yum.opennms.org/repofiles/open nms-repo-stable-rhel5.noarch.rpm ● 建立與設定資料庫 sudo -u postgres createdb -U postgres -E UNICODE opennms yum -y install iplike
  • 90. ● 安裝 OpenNMS yum -y install opennms mib2opennms opennms-* ● 設定 OpenNMS /opt/opennms/bin/runjava -s /opt/opennms/bin/install -dis chkconfig opennms on ● 啟動 OpenNMS service opennms start
  • 92. 參考資源 ● OpenNMS Documentation – http://www.opennms.org/documentation ● Official OpenNMS Documentation – http://support.opennms.com/knowledgebase/officialdocs ● OpenNMS Wiki – http://wiki.opennms.org/index.php/Main_Page ● Installation:Yum – http://www.opennms.org/wiki/Installation:Yum ● OpenNMS Documentation Overview – http://www.opennms.org/wiki/Docu-overview ● OpenNMS FAQ – http://www.opennms.org/wiki/FAQ
  • 94. Nagios ● http://www.nagios.org/ ● Open Source / Free 的監控工具 ● 網路狀態監控工具 ● 可發出即時 Alert ● 常用於觀察 – 主機服務 – 網路節點狀態
  • 95. 安裝 ● YUM yum install nagios*
  • 96. 系統設定 ● 建立httpd帳號 htpasswd -c /etc/nagios/htpasswd.users nagiosadmin htpasswd /etc/nagios/htpasswd.users nagiosuser ● 啟動服務 service httpd restart service nagios start chkconfig httpd on chkconfig nagios on
  • 97. 測試連線 ● 檢查設定檔語法 nagios -v /etc/nagios/nagios.cfg ● http://127.0.0.1/nagios/ – 以 nagiosadmin 登入
  • 98. 設定 ● 修改管理員信箱 vi /etc/nagios/objects/contacts.cfg define contact{ email user@domain ;
  • 99. 設定 ● 設定 nrpe echo 'nrpe 5666/tcp' >> /etc/services serivce nrpe start chkconfig nrpe on
  • 100. 設定 ● 測試 nrpe /usr/lib/nagios/plugins/check_nrpe -H localhost -c check_users /usr/lib/nagios/plugins/check_nrpe -H localhost -c check_load /usr/lib/nagios/plugins/check_nrpe -H localhost -c check_total_procs /usr/lib/nagios/plugins/check_nrpe -H localhost -c check_zombie_procs
  • 101. 設定 ● 測試硬碟空間 vi /etc/nagios/nrpe.cfg allowed_hosts=127.0.0.1,ip.ip.ip.ip command[check_root_space]=/usr/l ib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/VG/root_LV serive nrpe restart /usr/lib/nagios/plugins/check_nrpe -H localhost -c check_root_space
  • 102. 設定 ● 建立主機組態 cp /etc/nagios/objects/windows.cfg /etc/nagios/objects/linux.cfg vi /etc/nagios/objects/linux.cfg ● use linux-server ● host_name linuxserver ● Address 10.10.2.1 ● hostgroup_name linux-servers
  • 103. 設定 ● vi /etc/nagios/objects/linux.cfg – 把全部 host_name 從 winserver 修改 為 linuxserver (前面定義的) – 刪除多餘的 service { … } define service{ use generic-service host_name linuxserver service_description Online Users check_command check_nrpe!check_users }
  • 104. 設定 ● 定義 nrpe 命令 vi /etc/nagios/objects/commands.cfg # 'check_nrpe' command definition define command{ command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ }
  • 105. 設定 ● 修改 /etc/nagios/nagios.cfg : cfg_file=/etc/nagios/objects/linux.cfg ● 檢查組態 nagios -v /etc/nagios/nagios.cfg ● 重新執行服務 service nagios restart
  • 106. 參考資源 ● OpenNagios – http://software.opensuse.org/ymp/openS USE:11.3/standard/nagios.ymp ● Nagios Plugins – http://software.opensuse.org/ymp/openS USE:11.3/standard/nagios-plugins.ymp ● Nagios Addons Extras – http://software.opensuse.org/ymp/openS USE:11.3/standard/nagios-plugins-extras. ymp
  • 107. Q & A