本文介绍了几个更实用的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]#nethogseth02、硬盘读取性能测试——IOZoneIOZone是一款Linux文件系统性能测试工具你可以测试文件系统在不同操作系统下的读写性能。下载地址:http://www.iozone.org/src/current/[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为自动模式设置最小文件大小(KB)。-g设置可在自动模式下使用的最大文件大小Kbytes。-i用于指定要运行的测试。-f指定测试文件名,完成后自动删除-R生成Excel到标准输出-b指定输出到指定文件3.实时监控磁盘IO-IOTopIOTop命令是显示的专用命令硬盘IO,界面风格类似top命令。[root@localhost~]#yum-yinstalliotop4、网络流量监控-IPtrafIPtraf是一款运行在Linux下的简单网络状态分析工具。[root@localhost~]#yum-yinstalliptraf5、网络流量监控——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:分别代表过去2s、10s、40s的平均流量6.进程实时监控-HTopHTop是Linux下的交互式进程浏览器,可以用于替换top命令。rpm-ivhhttp://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm(安装第三方YUM源)[root@localhost~]#yum-yinstallhtop7,系统资源监控——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~]#nmon8,监控多个日志-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#监控的屏幕关键字[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/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=#最大尝试次数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#响应的错误日志一般在/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-Liptables过滤表有fail2banfail2ban-SSHtcp--anywhereanywhereetcpdpt:ssh10,connectionsession终端持久化-TmuxTmux是一款优秀的类似GNUScreen的终端多路复用软件,功能更全面比屏幕,灵活高效。为了保证SSH连接断开不影响任务运行。rpm-ivhhttp://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm(安装第三方YUM源)11.页面显示磁盘空间使用情况-阿杜下载: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关闭认证如果不加端口号,会生成随机浏览器访问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#获取系统综合Information[root@localhost~]#nmap192.168.0.0/24#获取某网段工作设备的基本信息-sSTCP扫描-sV系统版本检测13.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
