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