五个常用的Linux监控脚本代码 Linux
1、查看主机网卡流量
#!/bin/bash#network#Mike.Xuwhile : ; do time='date +%m"-"%d" "%k":"%M' day='date +%m"-"%d' rx_before='ifconfig eth0|sed -n "8"p|awk '{print $2}'|cut -c7-'
标签: linux
shell实现数字打印从100到200的数 Linux
#!/bin/bash#name: print number from 100 to 200for i in $(seq 100 200)doecho $idone
标签: linux
统计 cpu 内存 使用率的shell脚本代码 Linux
#!/bin/shclearwhile ((1>0))do NET=$(netstat -anp | grep 1000 | grep EST | wc -l) PRC=$(ps aux | grep thread1 | grep -v grep | grep -v SCREEN | awk '{ print " CPU: " $3 "%, MEM: " $4 "%, RSS: " $6/
标签: linux
一个用了统计CPU 内存 硬盘 使用率的shell脚本 Linux
#!/bin/bash#This script is use for describle CPU Hard Memery Utilizationtotal=0idle=0system=0user=0nice=0mem=0vmexec=/usr/bin/vmstatwhich sar > /dev/null 2>&1if [ $? -ne 0 ]then ver=`vmstat -V
标签: linux
shell 进度条实现代码 Linux
#!/bin/bashCOUNTER=0_R=0_C=`tput cols`_PROCEC=`tput cols`tput cup $_C $_Rprintf "["while [ $COUNTER -lt 100 ]do COUNTER=`expr $COUNTER + 1` sleep 0.1 printf "=>" _R=`expr $_R + 1` _C
标签: linux
awk统计文件中某关键词出现次数的命令 Linux
awk -F "" '{for(i=1;i<=NF;++i) if($i=="a") ++sum}END{print sum}' test.c[root@xiaobb 5906]# awk '{for(i=1;i<=NF;++i) if($i=="test") ++sum}END{print sum}' test.c6[root@xiaobb 5906]# cat test.ctest
标签: linux
shell查找当前目录下大于1M的文件的三种方法分享 Linux
1、使用find的参数实现
[root@xiaobb mnt]# find . -maxdepth 1 -size +1000000c./sys.tar.gz./install.tar.bz2./CTeX_2.9.0.152_Full.exe./php-5.3.6.tar.gz[root@xiaobb mnt]# ls -lhtotal 1.3G-rw-r--r--
标签: linux
expect自动检测并重启另外一台服务器上的程序代码 Linux
[s005 you] # cat haproxy_expect
#!/usr/bin/expectset ssh_user "fivetrees"set password "123456"spawn ssh -i /root/.ssh/$ssh_user Server004.xd.comexpect_before "no)?" {send "yesr" }sleep 0.5expect "Ente
标签: linux
查看某时间段到现在的系统日志的sed命令 Linux
sed查看某时间段到现在的系统日志: sed -n '/May 20 17/,$p' /var/log/messages | less
标签: linux
except自动登录的几段代码分享 Linux
#!/usr/bin/expect -fset timeout 30set host "192.168.1.198"spawn ssh $hostexpect_before "no)?" {send "yesr" }sleep 1expect "password:"send "123456r"expect "*#"send "echo my name is fivetrees > /roo
标签: linux