本文介绍了12个比较实用的Linux运维工具,希望对Linux运维人员有所帮助。1、查看进程占用带宽——NethogsNethogs是一款终端下的网络流量监控工具,可以直观的显示各个进程占用的带宽。下载:http://sourceforge.net/projects/nethogs/files/nethogs/0.8/nethogs-0.8.0.tar.gz/download[root@localhost~]#yum-yinstalllibpcap-develncurses-devel[root@localhost~]#tarzxvfnethogs-0.8.0.tar.gz[root@localhost~]#cdnethogs[root@localhostnethogs]#make&&makeinstall[root@localhostnethogs]#nethogseth0Ubuntu安装linuxmi@linuxmi:~/www.linuxmi.com$sudoaptinstallnethogs2.硬盘读取性能测试——IOZoneIOZone是一款Linux文件系统性能测试工具,可以测试文件系统在不同操作系统下的读写性能。下载地址:http://www.iozone.org/src/current/[root@localhostcurrent]#tarxvfiozone3_420.tar[root@localhost~]#cdiozone3_420/src/current/[root@localhostcurrent]#makelinuxUbuntulinuxmi@linuxmi:~/www.linuxmi.com$sudoapt-getinstalliozone3-a使用全自动模式-n为自动模式设置最小文件大小(KB)。-g设置自动模式可以使用的最大文件大小Kbytes。-i用于指定要运行的测试。-f指定测试文件名,自动删除-R生成Excel到标准输出-b指定输出到指定文件3.实时监控磁盘IO-IOTopIOTop命令是显示的专用命令硬盘IO,界面风格类似top命令。[root@localhost~]#yum-yinstalliotop或linuxmi@linuxmi:~/www.linuxmi.com$sudoaptinstalliotop4。网络流量监控——IFTopiftop是Linux下类似top的实时流量监控工具。比iptraf更直观。下载:http://www.ex-parrot.com/~pdw/iftop/[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:总计trafficcumm:从运行iftop到当前时间的总流量peak:峰值流量rates:top命令分别过去2s、10s、40s的平均流量。rpm-ivhhttp://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm(安装第三方YUM源)[root@localhost~]#yum-yinstallhtop或linuxmi@linuxmi:~/www.linuxmi.com$sudoaptinstallhtop6,系统资源监控-NMONNMON是AIX和各种Linux操作系统上广泛使用的监控分析工具下载地址:http://sourceforge.jp/projects/sfnet_nmon/releases/[root@localhost~]#chmod+xnmon_x86_64_rhel6[root@localhost~]#mvnmon_x86_64_rhel6/usr/sbin/nmon[root@localhost~]#nmon7,监控多条日志-MultiTailMultiTail在控制台打开多窗口使用同时监控多个日志文件,软件类似tail命令的功能。rpm-ivhhttp://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm(安装第三方YUM源)[root@localhost~]#yum-yinstallmultitail[root@localhost~]#multitail-e"fail"/var/log/secure#filter关键字用于监控[root@localhost~]#multitail-l"pingbaidu.com"#monitor下面的命令-l会执行命令[root@localhost~]#multitail-i/var/log/messages-i/var/log/secure#-i指定一个文件名ubuntulinuxmi@linuxmi:~/www.linuxmi.com$sudoaptinstallmultitail8.SSH暴力破解保护-Fail2banFail2ban可以监控您的系统日志,然后将日志的错误信息与正则表达式匹配,执行相应的拦截动作。一般是调用防火墙阻止下载:http://www.fail2ban.org/wiki/index.php/Downloads[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#忽略本地IPbantime=600#遵守therules出块后时间findtime=600#按照规则执行出块需要多长时间?如果600秒达到3次,则执行maxretry=3#最大尝试次数backend=auto#日志修改检测loggamin、polling和autousedns=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#响应的错误日志一般在/var/log/securemaxretry=5#尝试和错误的次数覆盖全局的maxretry注意:所有的应用保护默认都是关闭的,需要手动开启。fail2ban.conf文件是日志信息,jail.conf文件是受保护的具体服务和动作配置信息。[root@localhost~]#touch/var/log/sshd.log[root@localhost~]#servicefail2banrestart[root@localhost~]#fail2ban-clientstatus#查看监控已开启状态|-Numberofjail:1`-Jaillist:ssh-iptables[root@localhost~]#iptables-L#iptables过滤表有一条规则fail2banfail2ban-SSHtcp--anywhereanywhereetcpdpt:ssh9。Connectionsession终端持久化-TmuxTmux是一款优秀的类似GNUScreen的终端多路复用软件,比ScreenAspects更强大,灵活高效。为了保证SSH连接断开不影响任务运行。rpm-ivhhttp://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm(安装第三方YUM源)Ubuntulinuxmi@linuxmi:~/www.linuxmi.com$sudoapt安装tmux10。该页面显示磁盘空间使用情况-Agedu下载:http://www.chiark.greenend.org.uk/~sgtatham/agedu/[root@localhost~]#tarzxvfagedu-r9723.tar。gz[root@localhost~]#cdagedu-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如果没有端口则关闭认证添加的数字会生成一个随机的浏览器访问--addressUbuntulinuxmi@linuxmi:~/www.linuxmi.com$sudoapt-getinstallagedu11,安全扫描工具-NMapNMap是Linux下的一个网络连接扫描嗅探工具包,用于Scansforopennetwork来自网络上计算机的连接。下载: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#获取系统综合Information[root@localhost~]#nmap192.168.0.0/24#获取某个网段工作设备的基本信息ubuntulinuxmi@linuxmi:~/www.linuxmi.com$sudoaptinstallnmap-sSTCPscan-sV系统版本检测12、Web压力测试——HttperfHttperf比ab更强大,可以测试web服务所能承载的最大服务量,发现潜在问题;例如:内存使用、稳定性。最大优势:可以指定压测规则,模拟真实环境。下载:http://code.google.com/p/httperf/downloads/list[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或Ubuntulinuxmi@linuxmi:~/www.linuxmi.com$sudoaptinstallhttperf
