linux的常用监控命令
查看linux的中cup使用率前10的进程
ps aux|head -1;ps aux|grep -v PID|sort -rn -k +3|head
打印CPU日志信息
# 创建checkcpu.sh
#!/usr/bin/env bash
logFile=/var/log/Bigdata/checkCpuUsage.log
delayTime=30 # seconds between each excute, default value is 30 seconds
while( true )
do
echo `date` >> $logFile
echo "USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND " >> $logFile
ps aux|head -1;ps aux|grep -v PID|sort -rn -k +3|head >> $logFile
sleep $delayTime
echo " " >> $logFile
done
在节点在后台执行如下shell文件:
chmd 700 /opt/checkcpu.sh
nohup /opt/checkcpu.sh > /dev/null 2 > /dev/null &
日志分析
# 查看压缩文件中字符出现的次数
zgrep -a -C 100 "HBase get error" error.log.2019-01-10.gz|wc -l