mysql cpu和内存监控

 

 

mysqlMem 监控:
#!/bin/bash
Pid=`/bin/ps -ef|grep mysqld|grep -Ev "grep|safe"|awk '{print $2}'`
vMem=`/usr/bin/top -b -n 1 -p $Pid |grep mysql |awk '{print $5}'|awk -F"g" '{print $1}'`
rMem=`/usr/bin/top -b -n 1 -p $Pid |grep mysql |awk '{print $6}'|awk -F"g" '{print $1}'`
if [ $1 == "vMem" ];then
  echo $vMem
elif [ $1 == "rMem" ];then
  echo $rMem
fi

mysqlCpu监控:
#!/bin/bash
Pid=`/bin/ps -ef|grep mysqld|grep -Ev "grep|safe"|awk '{print $2}'`
#vMem=`/usr/bin/top -b -n 1 -p $Pid |grep mysql |awk '{print $5}'|awk -F"g" '{print $1}'`
Cpu=`/usr/bin/top -b -n 1 -p $Pid |grep mysql |awk '{print $9}'|awk -F"g" '{print $1}'`
if [ $1 == "Cpu" ];then
  echo $Cpu
elif [ $1 == "rMem" ];then
  echo $rMem
fi

 

转载于:https://www.cnblogs.com/fanxuanhui-linux/p/6242979.html

你可能感兴趣的:(数据库,awk)