shell 监控

#!/bin/sh
source /etc/profile
serverName=$1
dingDingName=$2

#获取内存情况
memory=(`free | awk 'NR==2{print $2,$3}'`)
memoryAll=${memory[0]}
memoryUsed=${memory[1]}

#cpu负载
cpuLoad=(`cat /proc/loadavg | awk '{print $1,$2,$3,$4}'`)
cpuLoad1=${cpuLoad[0]}
cpuLoad5=${cpuLoad[1]}
cpuLoad15=${cpuLoad[2]}
cpuLoadProcess=${cpuLoad[3]}

#cpu使用率
cpuUsed=`/usr/bin/top -b -n 1 | awk 'NR==3 {print $2}'`

#磁盘使用率
disk=(`df | grep /dev/ | awk '{print $2,$3}'`)
diskAll=${disk[0]}
diskUsed=${disk[1]}

#查看总的逻辑核数
coreNum=`cat /proc/cpuinfo | grep 'model name'  | wc -l`

上一篇:awk,seq,xarg实例使用


下一篇:VESTA NM52W1S-PR电磁阀