Linux 運維必備的13款實用工具,趕緊收藏!
本文介紹幾款Linux運維比較實用的工具,希望對Linux管理員有所幫助。
1、檢視程序佔用頻寬情況-Nethogs
Nethogs 是一個終端下的網路流量監控工具可以直觀的顯示每個程序佔用的頻寬。下載:
http://
sourceforge。net/project
s/nethogs/files/nethogs/0。8/nethogs-0。8。0。tar。gz/download
[root@localhost ~]#yum -y install libpcap-devel ncurses-devel
[root@localhost ~]# tar zxvf nethogs-0。8。0。tar。gz
[root@localhost ~]# cd nethogs
[root@localhost nethogs]# make && make install
[root@localhost nethogs]# nethogs eth0
2、硬碟讀取效能測試-IOZone
IOZone是一款Linux檔案系統性能測試工具 可以測試不同的作業系統中檔案系統的讀寫效能。下載:
http://www。
iozone。org/src/current/
[root@localhost current]# tar xvf iozone3_420。tar
[root@localhost ~]# cd iozone3_420/src/current/
[root@localhost current]# make linux
[root@localhost current]# 。/iozone -a -n 512m -g 16g -i 0 -i 1 -i 5 -f /mnt/iozone -Rb 。/iozone。xls
-a使用全自動模式
-n為自動模式設定最小檔案大小(Kbytes)。
-g設定自動模式可使用的最大檔案大小Kbytes。
-i用來指定執行哪個測試。
-f指定測試檔案的名字完成後自動刪除
-R產生Excel到標準輸出
-b指定輸出到指定檔案上
3、實時監控磁碟IO-IOTop
IOTop命令是專門顯示硬碟IO的命令,介面風格類似top命令。
[root@localhost ~]# yum -y install iotop
4、網路流量監控-IPtraf
IPtraf是一個執行在Linux下的簡單的網路狀況分析工具。
[root@localhost ~]# yum -y install iptraf
5、網路流量監控-IFTop
iftop是類似於linux下面top的實時流量監控工具。比iptraf直觀些。下載:
http://www。
ex-parrot。com/~pdw/ifto
p/
[root@localhost ~]# tar zxvf iftop-0。17。tar。gz
[root@localhost ~]# cd iftop-0。17 [root@localhost iftop-0。17]# 。/configure
[root@localhost iftop-0。17]# make && make install
[root@localhost iftop-0。17]# iftop [root@localhost iftop-0。17]# iftop -i eth0 #指定監控網絡卡介面
TX:傳送流量
RX:接收流量
TOTAL:總流量
Cumm:執行iftop到目前時間的總流量
peak:流量峰值
rates:分別表示過去 2s 10s 40s 的平均流量
6、程序實時監控-HTop
HTop是一個 Linux 下的互動式的程序瀏覽器可以用來替換Linux下的top命令。rpm -ivh
http://
pkgs。repoforge。org/rpmf
orge-release/rpmforge-release-0。5。2-2。el6。rf。x86_64。rpm
(安裝第三方YUM源)
[root@localhost ~]# yum -y install htop
7、系統資源監控-NMON
NMON是一種在AIX與各種Linux作業系統上廣泛使用的監控與分析工具下載:
http://
sourceforge。jp/projects
/sfnet_nmon/releases/
[root@localhost ~]# chmod +x nmon_x86_64_rhel6
[root@localhost ~]# mv nmon_x86_64_rhel6 /usr/sbin/nmon
[root@localhost ~]# nmon
8、監控多個日誌-MultiTail
MultiTail是在控制檯開啟多個視窗用來實現同時監控多個日誌文件、類似tail命令的功能的軟體。rpm -ivh
http://
pkgs。repoforge。org/rpmf
orge-release/rpmforge-release-0。5。2-2。el6。rf。x86_64。rpm
(安裝第三方YUM源)
[root@localhost ~]# yum -y install multitail
[root@localhost ~]# multitail -e “fail” /var/log/secure #篩選關鍵字進行監控
[root@localhost ~]# multitail -l “ping baidu。com” #監控後面的命令-l將要執行的命令
[root@localhost ~]# multitail -i /var/log/messages -i /var/log/secure #-i指定一個檔名
9、SSH暴力破解防護-Fail2ban
Fail2ban可以監視你的系統日誌然後匹配日誌的錯誤資訊正則式匹配執行相應的遮蔽動作一般情況下是呼叫防火牆遮蔽下載:
http://www。
fail2ban。org/wiki/index
。php/Downloads
[root@localhost ~]# cd fail2ban-0。8。11
[root@localhost fail2ban-0。8。11]# python setup。py install
[root@localhost fail2ban-0。8。11]# cd files/
[root@localhost files]# cp 。/redhat-initd /etc/init。d/fail2ban
[root@localhost files]# service fail2ban start
[root@localhost files]# chkconfig ——add fail2ban
[root@localhost files]# chkconfig fail2ban on
注:需要配置iptables實用,如果重啟iptables了也要重啟fail2ban,因為fail2ban的原理是呼叫iptables實時阻擋外界的攻擊。
[root@localhost ~]# grep -v “^#” /etc/fail2ban/jail。conf | grep -v “^$” [DEFAULT]
ignoreip = 127。0。0。1/8#忽略本機IP
bantime = 600 #符合規則後封鎖時間
findtime = 600 #在多長時間內符合規則執行封鎖如600秒達到3次則執行
maxretry = 3 #最大嘗試次數
backend = auto #日誌修改檢測日誌gamin、polling和auto這三種
usedns = warn [ssh-iptables]
enabled = true#預設是禁用
false filter = sshd action = iptables[name=SSH, port=ssh, protocol=tcp] # sendmail-whois[name=SSH,dest=收件人郵箱, sender=發件人郵箱, sendername=“Fail2Ban”] logpath = /var/log/sshd。log #響應的錯誤日誌一般在/var/log/secure maxretry = 5 #嘗試錯誤次數覆蓋全域性中的maxretry
注:預設所有的應用防護都是關閉的,需要我們手動開啟。fail2ban。conf檔案是日誌資訊,jail。conf檔案是保護的具體服務和動作配置資訊。
[root@localhost ~]# touch /var/log/sshd。log
[root@localhost ~]# service fail2ban restart
[root@localhost ~]# fail2ban-client status #檢視監控已經開啟 Status |- Number of jail: 1 `- Jail list: ssh-iptables
[root@localhost ~]# iptables -L #iptables過濾表有fail2ban一條規則 fail2ban-SSH tcp —— anywhere anywhere tcp dpt:ssh
10、連線會話終端持續化-Tmux
Tmux是一個優秀的終端複用軟體類似GNU Screen比Screen更加方面、靈活和高效。為了確保連線SSH時掉線不影響任務執行。rpm -ivh
http://
pkgs。repoforge。org/rpmf
orge-release/rpmforge-release-0。5。2-2。el6。rf。x86_64。rpm
(安裝第三方YUM源)
11、頁面顯示磁碟空間使用情況-Agedu
下載:
http://www。
chiark。greenend。org。uk/
~sgtatham/agedu/
[root@localhost ~]# tar zxvf agedu-r9723。tar。gz
[root@localhost ~]# cd agedu-r9723
[root@localhost ~]# 。/configure
[root@localhost ~]# make && make install
[root@localhost ~]# agedu -s / #-s掃描
[root@localhost ~]# agedu -w ——address 192。168。0。10:80 #-w輸入一個網頁連結
[root@localhost ~]# agedu -w ——address 192。168。0。108080 ——auth none #——auth關閉認證如果不加埠號會生成一個隨機的用瀏覽器訪問
12、安全掃描工具-NMap
NMap是Linux下的網路連線掃描和嗅探工具包用來掃描網上電腦開放的網路連線端。下載:
http://
nmap。org/download。html
[root@localhost ~]# tar jxvf nmap-6。40。tar。bz2
[root@localhost nmap-6。40]# 。/configure
[root@localhost nmap-6。40]# make && make install
[root@localhost ~]# nmap 192。168。0。10 #獲取基本資訊
[root@localhost ~]# nmap -O 192。168。0。10 #獲取系統版本資訊
[root@localhost ~]# nmap -A 192。168。0。10 #獲取系統綜合資訊
[root@localhost ~]# nmap 192。168。0。0/24 #獲取一個網段工作裝置基本資訊
-sSTCP掃描
-sV系統版本檢測
13、Web壓力測試-Httperf
Httperf比ab更強大,能測試出web服務能承載的最大服務量及發現潛在問題;比如:記憶體使用、穩定性。最大優勢:可以指定規律進行壓力測試,模擬真實環境。下載:
http://
code。google。com/p/httpe
rf/downloads/list
[root@localhost ~]# tar zxvf httperf-0。9。0。tar。gz
[root@localhost ~]# cd httperf-0。9。0
[root@localhost httperf-0。9。0]# 。/configure
[root@localhost httperf-0。9。0]# make && make install
[root@localhost ~]# httperf ——hog ——server=192。168。0。202 ——uri=/index。html ——num-conns=10000 ——wsess=10,10,0。1
引數說明:
—hog:讓httperf儘可能多產生連線,httperf會根據硬體配置,有規律的產生訪問連線;
—num-conns:連線數量,總髮起10000請求;
—wsess: 使用者開啟網頁時間規律模擬,第一個10表示產生10個會話連線,第二個10表示每個會話連線進行10次請求,0。1表示每個會話連線請求之間的間隔時間/s。
文章轉載自網路(侵刪)
感謝閱讀,我是 @運維光頭強 ;
關注我,一起學習更多運維知識!