Monitoring MySQL queries is a favorite pastime of MySQL administrators especially for performance reasons. رصد الاستفسارات الخلية هو المفضل لتسلية من الخلية ولا سيما المسؤولين الاداريين لأسباب الأداء. Here is a simple bash script to monitor long running MySQL queries in realtime using the ubiquitous ’show processlist’. هنا بسيطة باش سكريبت لرصد طويل تشغيل الخلية الاستفسارات في الوقت الحقيقي باستخدام كل مكان 'اظهار processlist'. The best part about this script is that you can use it to log your queries over time for later evaluation. الجزء الافضل عن هذا السيناريو هو انه يمكنك استخدامه لتسجيل الدخول استفساراتك على مر الزمن في وقت لاحق من التقييم.

 #!/bin/bash while [ 1 ] do         mysql -N -u root -p password -e 'show processlist' |grep -v 'show processlist'         sleep 2 done #! / بن / بينما اللكمه [1] هل الخلية - ن - ش - ف الجذر كلمة السر - ه 'اظهار processlist' | grep - الخامس 'اظهار processlist' النوم 2 عمله 

Note: Replace password with your actual password. ملاحظه : يستعاض عن كلمة السر الخاصة بك مع كلمة السر الفعليه.
Note: -N removes column headers. ملاحظه : - ان يزيل رأسيات الاعمده.

This script excludes the show processlist thread itself. ويستبعد هذا السيناريو processlist تبين الخيط نفسه. You may also exclude the Sleeping threads with the following modification: يمكنك ايضا استبعاد خيوط النوم مع اجراء التعديل التالي :
mysql -N -u root -p password -e ’show processlist’ | egrep -v ‘Sleep|show processlist’ الخلية - ن - ش - ف الجذر كلمة السر - ه 'اظهار processlist' | egrep - الخامس 'نوم واحدة | اظهار processlist'

Note: This is not the only or best solution in market. ملاحظه : هذه ليست الوحيدة أو أفضل حل في السوق. There is mtop script with more functionality but written in perl. وهناك مزيد من النصي mtop ولكن وظيفة كتابية في بيرل. I am alergic to perl and also couldn’t get it working in my only attempt. انا alergic لبيرل وايضا لا يمكن ان يحصل عليها العامل في بلادي فقط من محاولة اغتيال. So here is a simple solution in bash. حتى هنا هو الحل البسيط في باش. Personally I don’t like hacking perl scripts. شخصيا لا أحب تقطيع مخطوطات برل.

Note: You can use slow query log too but in my experience a running top like display is better at finding bottlenecks. ملاحظه : يمكنك استخدام سجل استفسار بطيءه جدا ولكن في تجربتي جارية مثل أعلى هو افضل عرض في ايجاد الاختناقات. Slow query log doesn’t indicate why a query took long time. سجل بطيءه استفسار لماذا لا يشير الى استفسار اتخذ منذ وقت طويل. It could be because it was waiting on another query to complete. ويمكن لانها كانت تنتظر على استفسار آخر لاستكمال.