Envoyé par unreal
Ce tout petit script permet de voir l'activité d'un serveur MySQL local assez simplement. Il génère les stats en forme CSV ce qui permet de tracer les résultats :
crontab
mysqlstat.sh
crontab
*/1 * * * * /usr/local/bin/mysqlstat.sh >> mysqlstat.csv
mysqlstat.sh
#!/bin/bash
SAMPLE=10
USER=root
PW=myrootpassword
NOWDATE=`date +"%D %H:%M"`
MYSQLADMIN=/usr/local/mysql/bin/mysqladmin
T1=`$MYSQLADMIN -u $USER -p$PW status | sed 's/.*Questions: //' | sed 's/ Slow queries:.*//'`
sleep $SAMPLE
T2=`$MYSQLADMIN -u $USER -p$PW status | sed 's/.*Questions: //' | sed 's/ Slow queries:.*//'`
T=`expr $T2 - $T1`
TT=`expr $T / $SAMPLE`
echo "$NOWDATE ; Requests: $T ($TT per sec.)"
SAMPLE=10
USER=root
PW=myrootpassword
NOWDATE=`date +"%D %H:%M"`
MYSQLADMIN=/usr/local/mysql/bin/mysqladmin
T1=`$MYSQLADMIN -u $USER -p$PW status | sed 's/.*Questions: //' | sed 's/ Slow queries:.*//'`
sleep $SAMPLE
T2=`$MYSQLADMIN -u $USER -p$PW status | sed 's/.*Questions: //' | sed 's/ Slow queries:.*//'`
T=`expr $T2 - $T1`
TT=`expr $T / $SAMPLE`
echo "$NOWDATE ; Requests: $T ($TT per sec.)"
Posté le 24/04/09 à 15:22