13款高逼格且實用的Linux運維必備工具

本文介紹幾款 Linux 運維比較實用的工具
1. 查看進程佔用帶寬情況 - Nethogs

Nethogs 是一個終端下的網絡流量監控工具可以直觀的顯示每個進程佔用的帶寬。

下載:
http://sourceforge.net/projects/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 512 -g 16 -i 0 -i1 -i5 -f /mnt/iozon R ./iozone.xl
-a -n							  m	    g			e-			bs

在這裏插入圖片描述
-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/iftop/

[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 iftop0.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/rpmforge-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/rpmforge-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/rpmforge-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.108 --auth no
--address								68		080	ne  
#--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/httperf/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 192.168.0.2 --uri=/index.html --num100 --wses1,1,0.
--server=						68		02	 -conns=				00 s= 0 0 1

在這裏插入圖片描述
參數說明:
–hog:讓 httperf 儘可能多產生連接,httperf 會根據硬件配置,有規律的產生訪問連接
–num-conns:連接數量,總髮起 10000 請求
–wsess: 用戶打開網頁時間規律模擬,第一個 10 表示產生 10 個會話連接,第二個 10 表示每個會話連接進行 10 次請求,0.1 表示每個會話連接請求之間的間隔時間 / s

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章