本文介绍几款比较实用的Linux运维工具,希望对Linux运维人员有所帮助。本文来自《学无捷径,学无捷径!blog1.查看进程占用的带宽——NethogsNethogs是一款终端下的网络流量监控工具,可以直观的显示各个进程占用的带宽。下载:http://sourceforge.net/projec...[root@localhost~]#yum-yinstalllibpcap-develncurses-devel[root@localhost~]#tarzxvfnethogs-0.8.0.tar.gz[root@localhost~]#cdnethogs[root@localhostnethogs]#make&&makeinstall[root@localhostnethogs]#nethogseth02。硬盘读取性能测试——IOZoneIOZone是一款Linux文件系统性能测试工具,可以测试不同操作系统中文件系统的读写性能。下载地址:http://www.iozone.org/src/cur...[root@localhostcurrent]#tarxvfiozone3_420.tar[root@localhost~]#cdiozone3_420/src/current/[root@localhostcurrent]#makelinux[root@localhostcurrent]#./iozone-a-n512m-g16g-i0-i1-i5-f/mnt/iozone-Rb./iozone.xls-a使用全自动模式-n为自动模式设置最小文件大小(千字节)。-g设置自动模式可以使用的最大文件大小Kbytes。-i用于指定要运行的测试。-f指定测试文件名,自动删除-R生成Excel到标准输出-b指定输出到指定文件3.实时监控磁盘IO-IOTopIOTop命令是显示的专用命令硬盘IO,界面风格类似top命令。[root@localhost~]#yum-y安装iotop4。网络流量监控——IPtrafIPtraf是一款运行在Linux下的简单网络状态分析工具。[root@localhost~]#yum-y安装iptraf5。网络流量监控——IFTopiftop是一款类似于linux下top的实时流量监控工具。比iptraf更直观。下载地址:http://www.ex-parrot.com/~pdw...[root@localhost~]#tarzxvfiftop-0.17.tar.gz[root@localhost~]#cdiftop-0.17[root@localhostiftop-0.17]#./configure[root@localhostiftop-0.17]#make&&makeinstall[root@localhostiftop-0.17]#iftop[root@localhostiftop-0.17]#iftop-ieth0#指定监控网卡接口`TX:发送流量RX:接收流量TOTAL:总流量Cumm:运行iftop到当前时间的总流量peak:流量峰值率:分别表示过去2s、10s、40s的平均流量6.实时处理monitoring-HTopHTop是Linux下的一个交互进程浏览器,可以用来代替Linux下的top命令。rpm-ivhhttp://pkgs.repoforge.org/rpm..._64.rpm(安装第三方YUM源)[root@localhost~]#yum-yinstallhtop7.系统资源监控——NMONNMON是一款广泛应用于各种Linux操作系统的监控分析下载工具:http://sourceforge.jp/project...[root@localhost~]#chmod+xnmon_x86_64_rhel6[root@localhost~]#mvnmon_x86_64_rhel6/usr/sbin/nmon[root@localhost~]#nmon8.监控多条日志-MultiTailMultiTail是一款在控制台打开多个窗口同时监控多个日志文件的软件,类似于tail命令.rpm-ivhhttp://pkgs.repoforge.org/rpm...(安装第三方YUM源)[root@localhost~]#yum-yinstallmultitail[root@localhost~]#multitail-e"fail"/var/log/secure#监控的屏幕关键字[root@localhost~]#multitail-l"pingbaidu.com"#监控以下命令-l要执行的命令[root@localhost~]#multitail-i/var/log/messages-i/var/log/secure#-i指定文件名9.SSH暴力破解保护-Fail2banFail2ban可以监控你的系统日志,将日志的错误信息与正则表达式匹配来执行一般情况下相应的屏蔽动作是调用防火墙来阻止下载:http://www.fail2ban.org/wiki/...[root@localhost~]#cdfail2ban-0.8.11[root@localhostfail2ban-0.8.11]#pythonsetup.pyinstall[root@localhostfail2ban-0.8.11]#cdfiles/[root@localhostfiles]#cp./redhat-initd/etc/init.d/fail2ban[root@localhostfiles]#servicefail2banstart[root@localhostfiles]#chkconfig--addfail2ban[root@localhostfiles]#chkconfigfail2banon注意:需要配置iptables才能实用。如果重启iptables,还必须重启fail2ban,因为fail2ban的原理是实时调用iptables来阻断外部攻击。[root@localhost~]#grep-v"^#"/etc/fail2ban/jail.conf|grep-v"^$"[DEFAULT]ignoreip=127.0.0.1/8#ignorelocalIPbantime=600#满足规则后的阻塞时间findtime=600#根据规则执行块多长时间,比如600秒to3次,然后执行maxretry=3#最大尝试次数backend=auto#日志修改检测日志gamin,polling和auto三种使用ns=warn[ssh-iptables]enabled=true#默认是禁用falsefilter=sshdaction=iptables[name=SSH,port=ssh,protocol=tcp]#sendmail-whois[name=SSH,dest=收件人邮箱,sender=发件人邮箱,sendername="Fail2Ban"]logpath=/var/log/sshd.log#The响应的错误日志一般在/var/log/securemaxretry=5#尝试次数和错误次数覆盖全局的maxretry注意:默认所有应用程序保护都是关闭的,我们需要手动开启。fail2ban.conf文件是日志信息,jail.conf文件是受保护的具体服务和动作配置信息。[root@localhost~]#touch/var/log/sshd.log[root@localhost~]#servicefail2banrestart[root@localhost~]#fail2ban-clientstatus#查看监控是否开启Status|-jail数量:1-Jaillist:ssh-iptables[root@localhost~]#iptables-L#iptablesfiltertablehasafail2banrule`fail2ban-SSHtcp--anywhereanywhereexcellenttcpdpt:ssh10.连接会话终端持久性-TmuxTmuxisa像GNUScreen这样的终端多路复用软件比Screen更全面、更灵活、更高效。为了保证SSH连接断开不影响任务运行。rpm-ivhhttp://pkgs.repoforge.org/rpm..._64.rpm(安装第三方YUM源)11.页面显示磁盘空间使用情况-Agedu下载:http://www.chiark.greenend。或者...[root@localhost~]#tarzxvfagedu-r9723.tar.gz[root@localhost~]#cdageu-r9723[root@localhost~]#./configure[root@localhost~]#make&&makeinstall[root@localhost~]#agedu-s/#-sscan[root@localhost~]#agedu-w--address192.168.0.10:80#-w输入一个网页链接[root@localhost~]#agedu-w--address192.168.0.108080--authnone#--auth关闭认证如果不添加端口号,将生成随机浏览器访问12.安全扫描工具-NMapNMap是Linux下的网络连接扫描嗅探工具包它用于扫描Internet上计算机的开放网络连接。下载:http://nmap.org/download.html[root@localhost~]#tarjxvfnmap-6.40.tar.bz2[root@localhostnmap-6.40]#./configure[root@localhostnmap-6.40]#make&&makeinstall[root@localhost~]#nmap192.168.0.10#获取基本信息[root@localhost~]#nmap-O192.168.0.10#获取系统版本信息[root@localhost~]#nmap-A192.168.0.10#获取系统综合信息[root@localhost~]#nmap192.168.0.0/24#获取某网段工作设备的基本信息-sSTCP扫描-sV系统版本检测13.Web压力测试-HttperfHttperf比ab更强大可以测试出一个web服务所能承载的最大服务量和发现的潜在问题;例如:内存使用、稳定性。最大优势:可以指定压测规则,模拟真实环境。下载:http://code.google.com/p/http...[root@localhost~]#tarzxvfhttperf-0.9.0.tar.gz[root@localhost~]#cdhttperf-0.9.0[root@localhosthttperf-0.9.0]#./configure[root@localhosthttperf-0.9.0]#make&&makeinstall[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个session连接,第二个10表示每个session连接发出10次请求,0.1表示会话连接请求之间的每个Intervaltime/s
