#!/bin/sh
select_num=`/usr/local/mysql/bin/mysqladmin -uroot -p123456 extended-status| egrep -w "Com_select" |awk -F "|" '{print $3}'`
update_num=`/usr/local/mysql/bin/mysqladmin -uroot -p123456 extended-status| egrep -w "Com_update" |awk -F "|" '{print $3}'`
delete_num=`/usr/local/mysql/bin/mysqladmin -uroot -p123456 extended-status| egrep -w "Com_delete" |awk -F "|" '{print $3}'`
replace_num=`/usr/local/mysql/bin/mysqladmin -uroot -p123456 extended-status| egrep -w "Com_replace" |awk -F "|" '{print $3}'`
connected_num=`/usr/local/mysql/bin/mysqladmin -uroot -p123456 extended-status| egrep -w "Threads_connected" |awk -F "|" '{print $3}'`
dml_num=`expr $delete_num + $update_num + $replace_num`
cd /data/system_worksh
old_dml_num=0
old_sel_num=0
if [ -f "mysql_count.cache" ];
then
old_dml_num=`cat mysql_count.cache|awk -F',' '{print $1}'`;
old_sel_num=`cat mysql_count.cache|awk -F',' '{print $2}'`;
fi
echo $dml_num"," $select_num > mysql_count.cache
dml_num=`expr $dml_num - $old_dml_num`
sel_num=`expr $select_num - $old_sel_num`
datestr=`date +"%Y-%m-%d %H:%M:%S"`
echo "[$datestr]"$dml_num","$sel_num","$connected_num