1、查看进程占用带宽情况-nethogs
nethogs 是一个终端下的网络流量监控工具可以直观的显示每个进程占用的带宽。
下载:http://sourceforge.net/projects/nethogs/files/nethogs/0.8/nethogs-0.8.0.tar.gz/download
1
2
3
4
5
<code>[root@localhost ~]</code><code>#yum -y install libpcap-devel ncurses-devel</code>
<code>[root@localhost ~]</code><code># tar zxvf nethogs-0.8.0.tar.gz</code>
<code>[root@localhost ~]</code><code># cd nethogs</code>
<code>[root@localhost nethogs]</code><code># make && make install</code>
<code>[root@localhost nethogs]</code><code># nethogs eth0</code>
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIyZuBnLxATM2AjM1UTMvwlMxMTMwIzLcRnbl1GajFGd0F2Lc12bj5yb0NWM14SMn1Wavw1LcpDc0RHaiojIsJye.png)
2、硬盘读取性能测试-iozone
iozone是一款linux文件系统性能测试工具,可以测试不同的操作系统中文件系统的读写性能。
下载:http://www.iozone.org/src/current/
<code>[root@localhost current]</code><code># tar xvf iozone3_420.tar</code>
<code>[root@localhost ~]</code><code># cd iozone3_420/src/current/</code>
<code>[root@localhost current]</code><code># make linux</code>
<code>[root@localhost current]</code><code># ./iozone -a -n 512m -g 16g -i 0 -i 1 -i 5 -f /mnt/iozone -rb ./iozone.xls</code>
-a使用全自动模式
-n为自动模式设置最小文件大小(kbytes)。
-g设置自动模式可使用的最大文件大小kbytes。
-i用来指定运行哪个测试。
-f指定测试文件的名字完成后自动删除
-r产生excel到标准输出
-b指定输出到指定文件上
3、实时监控磁盘io-iotop
iotop命令是专门显示硬盘io的命令,界面风格类似top命令。
[root@localhost ~]# yum -y install iotop
[root@localhost ~]# iotop
4、网络流量监控-iptraf
iptraf是一个运行在linux下的简单的网络状况分析工具。
[root@localhost ~]# yum -y install iptraf
5、网络流量监控-iftop
iftop是类似于linux下面top的实时流量监控工具。比iptraf直观些。
<a href="http://img1.51cto.com/attachment/201312/165956137.jpg" target="_blank"></a>
6
<code>[root@localhost ~]</code><code># tar zxvf iftop-0.17.tar.gz</code>
<code>[root@localhost ~]</code><code># cd iftop-0.17</code>
<code>[root@localhost iftop-0.17]</code><code># ./configure</code>
<code>[root@localhost iftop-0.17]</code><code># make && make install</code>
<code>[root@localhost iftop-0.17]</code><code># iftop</code>
<code>[root@localhost iftop-0.17]</code><code># iftop -i eth0 #指定监控网卡接口</code>
tx:发送流量
rx:接收流量
total:总流量
cumm:运行iftop到目前时间的总流量
peak:流量峰值
rates:分别表示过去 2s 10s 40s 的平均流量
6、进程实时监控-htop
htop是一个 linux 下的交互式的进程浏览器可以用来替换linux下的top命令。
[root@localhost ~]# yum -y install htop
7、系统资源监控-nmon
下载:http://sourceforge.jp/projects/sfnet_nmon/releases/
<code>[root@localhost ~]</code><code># chmod +x nmon_x86_64_rhel6</code>
<code>[root@localhost ~]</code><code># mv nmon_x86_64_rhel6 /usr/sbin/nmon</code>
<code>[root@localhost ~]</code><code># nmon</code>
8、监控多个日志-multitail
multitail是在控制台打开多个窗口用来实现同时监控多个日志文档、类似tail命令的功能的软件。
<code>[root@localhost ~]</code><code># yum -y install multitail</code>
<code>[root@localhost ~]</code><code># multitail -e "fail" /var/log/secure #筛选关键字进行监控</code>
<code>[root@localhost ~]</code><code># multitail -l "ping baidu.com" #监控后面的命令-l将要执行的命令</code>
<code>[root@localhost ~]</code><code># multitail -i /var/log/messages -i /var/log/secure #-i指定一个文件名</code>
9、ssh暴力破解防护-fail2ban
下载:http://www.fail2ban.org/wiki/index.php/downloads
7
<code>[root@localhost ~]</code><code># cd fail2ban-0.8.11</code>
<code>[root@localhost fail2ban-0.8.11]</code><code># python setup.py install</code>
<code>[root@localhost fail2ban-0.8.11]</code><code># cd files/</code>
<code>[root@localhost files]</code><code># cp ./redhat-initd /etc/init.d/fail2ban</code>
<code>[root@localhost files]</code><code># service fail2ban start</code>
<code>[root@localhost files]</code><code># chkconfig --add fail2ban</code>
<code>[root@localhost files]</code><code># chkconfig fail2ban on</code>
注需要配置iptables实用如果重启iptables了也要重启fail2ban因为 fail2ban 的原理是调用iptables 实时阻挡外界的攻击
8
9
10
11
12
13
14
15
<code>[root@localhost ~]</code><code># grep -v "^#" /etc/fail2ban/jail.conf | grep -v "^$"</code>
<code>[default]</code>
<code>ignoreip = 127.0.0.1</code><code>/8</code><code>#忽略本机ip</code>
<code>bantime = 600 </code><code>#符合规则后封锁时间</code>
<code>findtime = 600 </code><code>#在多长时间内符合规则执行封锁如600秒达到3次则执行</code>
<code>maxretry = 3 </code><code>#最大尝试次数</code>
<code>backend = auto </code><code>#日志修改检测日志gamin、polling和auto这三种</code>
<code>usedns = warn</code>
<code>[</code><code>ssh</code><code>-iptables]</code>
<code>enabled = </code><code>true</code><code>#默认是禁用false</code>
<code>filter = sshd</code>
<code>action = iptables[name=ssh, port=</code><code>ssh</code><code>, protocol=tcp]</code>
<code># sendmail-whois[name=ssh,dest=收件人邮箱, sender=发件人邮箱, sendername="fail2ban"]</code>
<code>logpath = </code><code>/var/log/sshd</code><code>.log </code><code>#响应的错误日志一般在/var/log/secure</code>
<code>maxretry = 5 </code><code>#尝试错误次数覆盖全局中的maxretry</code>
注默认所有的应用防护都是关闭的需要我们手动开启fail2ban.conf文件是日志信息jail.conf文件是保护的具体服务和动作配置信息。
<code>[root@localhost ~]</code><code># touch /var/log/sshd.log</code>
<code>[root@localhost ~]</code><code># service fail2ban restart</code>
<code>[root@localhost ~]</code><code># fail2ban-client status #查看监控已经开启</code>
<code>status</code>
<code>|- number of jail: 1</code>
<code>`- jail list: </code><code>ssh</code><code>-iptables</code>
<code>[root@localhost ~]</code><code># iptables -l #iptables过滤表有fail2ban一条规则</code>
<code>fail2ban-ssh tcp -- anywhere anywhere tcp dpt:</code><code>ssh</code>
10、连接会话终端持续化-tmux
<a href="http://img1.51cto.com/attachment/201312/160605880.png" target="_blank"></a>
<code>[root@localhost ~]</code><code># yum -y install tmux</code>
<code>[root@localhost ~]</code><code># tmux #打开tmux会话终端</code>
<code>离开当前会话先ctrl+b后再按d</code>
<code>[root@localhost ~]</code><code># tmux ls #列出会话</code>
<code>[root@localhost ~]</code><code># tmux a -t 编号/name #回到指定会话,exit关闭当前会话</code>
<code>[root@localhost ~]</code><code># tmux new -s lamp #创建一个lamp会话名</code>
<code>[root@localhost ~]</code><code># tmux kill-server #关闭所有终端</code>
11、页面显示磁盘空间使用情况-agedu
下载:http://www.chiark.greenend.org.uk/~sgtatham/agedu/
<code>[root@localhost ~]</code><code># tar zxvf agedu-r9723.tar.gz</code>
<code>[root@localhost ~]</code><code># cd agedu-r9723</code>
<code>[root@localhost ~]</code><code># ./configure</code>
<code>[root@localhost ~]</code><code># make && make install</code>
<code>[root@localhost ~]</code><code># agedu -s / #-s扫描</code>
<code>[root@localhost ~]</code><code># agedu -w --address 192.168.0.10:80 #-w输入一个网页链接</code>
<code>[root@localhost ~]</code><code># agedu -w --address 192.168.0.108080 --auth none #--auth关闭认证如果不加端口号会生成一个随机的用浏览器访问</code>
12、安全扫描工具-nmap
下载:http://nmap.org/download.html
<code>[root@localhost ~]</code><code># tar jxvf nmap-6.40.tar.bz2</code>
<code>[root@localhost nmap-6.40]</code><code># ./configure</code>
<code>[root@localhost nmap-6.40]</code><code># make && make install</code>
<code>[root@localhost ~]</code><code># nmap 192.168.0.10 #获取基本信息</code>
<code>[root@localhost ~]</code><code># nmap -o 192.168.0.10 #获取系统版本信息</code>
<code>[root@localhost ~]</code><code># nmap -a 192.168.0.10 #获取系统综合信息</code>
<code>[root@localhost ~]</code><code># nmap 192.168.0.0/24 #获取一个网段工作设备基本信息</code>
-sstcp扫描
-sv系统版本检测
13、web压力测试-httperf
httperf比ab更强大,能测试出web服务能承载的最大服务量及发现潜在问题;比如:内存使用、稳定性。最大优势:可以指定规律进行压力测试,模拟真实环境。
<code>[root@localhost ~]</code><code># tar zxvf httperf-0.9.0.tar.gz</code>
<code>[root@localhost ~]</code><code># cd httperf-0.9.0</code>
<code>[root@localhost httperf-0.9.0]</code><code># ./configure</code>
<code>[root@localhost httperf-0.9.0]</code><code># make && make install</code>
<code>[root@localhost ~]</code><code># httperf --hog --server=192.168.0.202 --uri=/index.html --num-conns=10000 --wsess=10,10,0.1</code>
参数说明:
--hog:让httperf尽可能多产生连接,httperf会根据硬件配置,有规律的产生访问连接
--num-conns:连接数量,总发起10000请求
--wsess: 用户打开网页时间规律模拟,第一个10表示产生10个会话连接,第二个10表示每个会话连接进行10次请求,0.1表示每个会话连接请求之间的间隔时间/s