本文介绍几款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 -a -n 512m -g 16g -i 0 -i 1 -i 5 -f /mnt/iozone -rb ./iozone.xls
-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 iftop-0.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#忽略本机ipbantime = 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、连接会话终端持续化-tmuxtmux是一个优秀的终端复用软件类似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.108080 --auth none #--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 --server=192.168.0.202 --uri=/index.html --num-conns=10000 --wsess=10,10,0.1
华为云耀云服务器 L 实例:小程序时代的得力伙伴
盘点苹果这些年冷门到爆炸的产品,果粉们见过嘛?
目前诺基亚手机在中国市场的份额接近50%
国际共识:AI产业化从航母式发展到精准打击
从原理出发,交流异步/永磁同步电动机如何产生动力?
Linux运维必备的13款实用工具
小米申请“电子设备和隐蔽摄像头”新专利
电路设计如何控制远程负载的电压
简单电力场效应管驱动器是孤立的和DC耦合-Simple Po
MAXIMD/A转换器MAX547的工作原理、性能特点和应用分析
如何通过机器人与先进机器视觉结合来应对复杂的自动化挑战
卡萨帝的“朋友圈”遍布全球,这次是法国堡主
屏蔽线只能一端接地的原因是什么
IBM 陈科典:数字经济时代,在华跨国企业应深挖数据潜能同时超前部署应对数据安全挑战
讲解三相异步电动机振动原因的查找方式
双向可控硅的几大基本要素解析
如何保证数据中心建设预算和时间计划
介绍下自动焊接设备的种类
氮化镓你了解多少
英飞凌CoolSiC肖特基二极管650V G6的性能分析和应用