no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | monitors:xymon-mysqlperf [2012/12/13 19:06] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Xymon-MySQLPerf ====== | ||
+ | ^ Author | [[ contato@blackballti.com | LXTI ]] | | ||
+ | ^ Compatibility | Xymon 4.3.10 | | ||
+ | ^ Requirements | MySQL, Linux, etc | | ||
+ | ^ Download | None | | ||
+ | ^ Last Update | 2013-12-13 | | ||
+ | |||
+ | ===== Description ===== | ||
+ | |||
+ | This xymon plugin monitors some of the most important perform variables of MySQL for the Xymon environment. Enjoy! | ||
+ | |||
+ | ===== Installation ===== | ||
+ | |||
+ | === Client side === | ||
+ | |||
+ | 1. Copy xymon-mysqlperf.sh file to xymon extensions directory, usually “$XYMONCLIENTHOME/ | ||
+ | |||
+ | 2. Configure xymon client to make the test, add this content to clientlaunch.cfg: | ||
+ | |||
+ | [mysqlperf] | ||
+ | ENVFILE $XYMONCLIENTHOME/ | ||
+ | CMD $XYMONCLIENTHOME/ | ||
+ | LOGFILE $XYMONCLIENTLOGS/ | ||
+ | INTERVAL 5m | ||
+ | | ||
+ | <note important> | ||
+ | | ||
+ | === Server side === | ||
+ | |||
+ | Nothing to do here, yet. | ||
+ | |||
+ | ===== Source ===== | ||
+ | ==== xymon-mysqlperf.sh ==== | ||
+ | |||
+ | <hidden onHidden=" | ||
+ | < | ||
+ | #!/bin/bash | ||
+ | # | ||
+ | # | ||
+ | #USE IT AS YOU WANT. BY LXTI -- contato@blackballti.com - 23/11/2012. | ||
+ | # | ||
+ | # | ||
+ | ##################### | ||
+ | #### EXPLANATION #### | ||
+ | ##################### | ||
+ | # | ||
+ | #For explanation about the monitored mysql variables, please see http:// | ||
+ | # | ||
+ | #ADDING NEW VARIABLE | ||
+ | # | ||
+ | #To add new monitorable value from mysql performance table, you just need to put the name of it on MONITORADOS. | ||
+ | #Create new measurement variables into the " | ||
+ | #Still in the function " | ||
+ | #Voalá. | ||
+ | # | ||
+ | # | ||
+ | #Especial thanks to " | ||
+ | # | ||
+ | # | ||
+ | ################################ | ||
+ | #### VARIABLES DECLARATION ##### | ||
+ | ################################ | ||
+ | |||
+ | # User used to connect to MYSQL. It is not necessary have any privileges. Use " | ||
+ | MYSQLUSER=xymon | ||
+ | # Password used for the user connection. | ||
+ | MYSQLPASS=123 | ||
+ | |||
+ | # Variables pool monitored by the script. If you want to monitor others variables, this is the right place. Put them after all these. | ||
+ | MONITORADOS=( | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | #PUT IT HERE A NEW VARIABLE | ||
+ | ) | ||
+ | |||
+ | # Logs files | ||
+ | # Change them as you want, however set the correct permission for Xymon user. | ||
+ | |||
+ | LOG1=/ | ||
+ | LOG2=/ | ||
+ | STATUS=/ | ||
+ | |||
+ | # | ||
+ | |||
+ | echo "" | ||
+ | echo "" | ||
+ | echo "" | ||
+ | |||
+ | ######################################################################### | ||
+ | |||
+ | ################### | ||
+ | #### FUNCTIONS #### | ||
+ | ################### | ||
+ | |||
+ | |||
+ | # For Xymon getting the general status | ||
+ | |||
+ | function general_status { | ||
+ | if [ " | ||
+ | echo " | ||
+ | |||
+ | elif [ "`cat $STATUS`" | ||
+ | echo " | ||
+ | fi | ||
+ | } | ||
+ | |||
+ | |||
+ | # Get the values of the Variables. | ||
+ | |||
+ | function obtem_valores { | ||
+ | #date > $LOG1 | ||
+ | for (( i = 0 ; i < ${# | ||
+ | do | ||
+ | mysql -u $MYSQLUSER -p$MYSQLPASS -e "SHOW GLOBAL STATUS WHERE Variable_name LIKE ' | ||
+ | check $(mysql -u $MYSQLUSER -p$MYSQLPASS -e "SHOW GLOBAL STATUS WHERE Variable_name LIKE ' | ||
+ | done | ||
+ | } | ||
+ | |||
+ | # Verify all Variables and set the threshold for Xymon. | ||
+ | |||
+ | function check { | ||
+ | ### SETTING MEASURES ### | ||
+ | # | ||
+ | ## HOW TO USE ## | ||
+ | # | ||
+ | #By default the color yellow or red start when the definitions values get over of the values setted. | ||
+ | #I don't know how to know the best status value for your enviroment, so try them by yourself. | ||
+ | # | ||
+ | #################### | ||
+ | ## LET'S STARTING ## | ||
+ | #################### | ||
+ | # | ||
+ | # | ||
+ | TC_STARTING_YELLOW=100 | ||
+ | TC_STARTING_RED=300 | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | CT_STARTING_YELLOW=6000 | ||
+ | CT_STARTING_RED=10000 | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | HF_STARTING_YELLOW=200000 | ||
+ | HF_STARTING_RED=500000 | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | IF_STARTING_YELLOW=10 | ||
+ | IF_STARTING_RED=30 | ||
+ | # | ||
+ | #Key_reads | ||
+ | # | ||
+ | KR_STARTING_YELLOW=5000 | ||
+ | KR_STARTING_RED=10000 | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | MC_STARTING_YELLOW=100 | ||
+ | MC_STARTING_RED=400 | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | OT_STARTING_YELLOW=100 | ||
+ | OT_STARTING_RED=500 | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | SJ_STARTING_YELLOW=150 | ||
+ | SJ_STARTING_RED=500 | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | SQ_STARTING_YELLOW=100 | ||
+ | SQ_STARTING_RED=500 | ||
+ | # | ||
+ | #Uptime. (PS. IN THIS CASE WE WANT TO KNOW WHEN THE MYSQL WAS RESTARTED AS SOON POSSIBLE, THEN WE NEED TO MONITORING SINCE WHEN IT IS UP. IN HOURS FEWER THAT YOU WHANT TO BE GREEN) | ||
+ | # | ||
+ | UP_STARTING_RED=1 | ||
+ | # | ||
+ | |||
+ | case " | ||
+ | 0) | ||
+ | # | ||
+ | if [[ $1 -ge $TC_STARTING_YELLOW ]]; then | ||
+ | if [[ $1 -le $TC_STARTING_RED ]]; then | ||
+ | # Vai pro yellow | ||
+ | echo "& | ||
+ | general_status yellow | ||
+ | else | ||
+ | # Vai pro red | ||
+ | echo "& | ||
+ | general_status red | ||
+ | fi | ||
+ | else | ||
+ | #Vai pro green | ||
+ | echo "& | ||
+ | general_status green | ||
+ | fi | ||
+ | ;; | ||
+ | 1) | ||
+ | # | ||
+ | if [[ $1 -ge $CT_STARTING_YELLOW ]]; then | ||
+ | if [[ $1 -le $CT_STARTING_RED ]]; then | ||
+ | # Vai pro yellow | ||
+ | echo "& | ||
+ | general_status yellow | ||
+ | else | ||
+ | # Vai pro red | ||
+ | echo "& | ||
+ | general_status red | ||
+ | fi | ||
+ | else | ||
+ | #Vai pro green | ||
+ | echo "& | ||
+ | general_status green | ||
+ | fi | ||
+ | ;; | ||
+ | 2) | ||
+ | # | ||
+ | if [[ $1 -ge $HF_STARTING_YELLOW ]]; then | ||
+ | if [[ $1 -le $HF_STARTING_RED ]]; then | ||
+ | # Vai pro yellow | ||
+ | echo "& | ||
+ | general_status yellow | ||
+ | else | ||
+ | # Vai pro red | ||
+ | echo "& | ||
+ | general_status red | ||
+ | fi | ||
+ | else | ||
+ | #Vai pro green | ||
+ | echo "& | ||
+ | general_status green | ||
+ | fi | ||
+ | ;; | ||
+ | 3) | ||
+ | # | ||
+ | if [[ $1 -ge $IF_STARTING_YELLOW ]]; then | ||
+ | if [[ $1 -le $IF_STARTING_RED ]]; then | ||
+ | # Vai pro yellow | ||
+ | echo "& | ||
+ | general_status yellow | ||
+ | else | ||
+ | # Vai pro red | ||
+ | echo "& | ||
+ | general_status red | ||
+ | fi | ||
+ | else | ||
+ | #Vai pro green | ||
+ | echo "& | ||
+ | general_status green | ||
+ | fi | ||
+ | ;; | ||
+ | 4) | ||
+ | # | ||
+ | if [[ $1 -ge $KR_STARTING_YELLOW ]]; then | ||
+ | if [[ $1 -le $KR_STARTING_RED ]]; then | ||
+ | # Vai pro yellow | ||
+ | echo "& | ||
+ | general_status yellow | ||
+ | else | ||
+ | # Vai pro red | ||
+ | echo "& | ||
+ | general_status red | ||
+ | fi | ||
+ | else | ||
+ | #Vai pro green | ||
+ | echo "& | ||
+ | general_status green | ||
+ | fi | ||
+ | ;; | ||
+ | 5) | ||
+ | # | ||
+ | if [[ $1 -ge $MC_STARTING_YELLOW ]]; then | ||
+ | if [[ $1 -le $MC_STARTING_RED ]]; then | ||
+ | # Vai pro yellow | ||
+ | echo "& | ||
+ | general_status yellow | ||
+ | else | ||
+ | # Vai pro red | ||
+ | echo "& | ||
+ | general_status red | ||
+ | fi | ||
+ | else | ||
+ | #Vai pro green | ||
+ | echo "& | ||
+ | general_status green | ||
+ | fi | ||
+ | ;; | ||
+ | 6) | ||
+ | # | ||
+ | if [[ $1 -ge $OT_STARTING_YELLOW ]]; then | ||
+ | if [[ $1 -le $OT_STARTING_RED ]]; then | ||
+ | # Vai pro yellow | ||
+ | echo "& | ||
+ | general_status yellow | ||
+ | else | ||
+ | # Vai pro red | ||
+ | echo "& | ||
+ | general_status red | ||
+ | fi | ||
+ | else | ||
+ | #Vai pro green | ||
+ | echo "& | ||
+ | general_status green | ||
+ | fi | ||
+ | ;; | ||
+ | 7) | ||
+ | # | ||
+ | if [[ $1 -ge $SJ_STARTING_YELLOW ]]; then | ||
+ | if [[ $1 -le $SJ_STARTING_RED ]]; then | ||
+ | # Vai pro yellow | ||
+ | echo "& | ||
+ | general_status yellow | ||
+ | else | ||
+ | # Vai pro red | ||
+ | echo "& | ||
+ | general_status red | ||
+ | fi | ||
+ | else | ||
+ | #Vai pro green | ||
+ | echo "& | ||
+ | general_status green | ||
+ | fi | ||
+ | ;; | ||
+ | 8) | ||
+ | # | ||
+ | if [[ $1 -ge $SQ_STARTING_YELLOW ]]; then | ||
+ | if [[ $1 -le $SQ_STARTING_RED ]]; then | ||
+ | # Go to yellow | ||
+ | echo "& | ||
+ | general_status yellow | ||
+ | else | ||
+ | # Go to red | ||
+ | echo "& | ||
+ | general_status red | ||
+ | fi | ||
+ | else | ||
+ | #Go to green | ||
+ | echo "& | ||
+ | general_status green | ||
+ | fi | ||
+ | ;; | ||
+ | 9) | ||
+ | #Uptime | ||
+ | if [[ $(($1/ | ||
+ | # Vai pro red | ||
+ | echo "& | ||
+ | general_status red | ||
+ | else | ||
+ | #Vai pro green | ||
+ | echo "& | ||
+ | general_status green | ||
+ | fi | ||
+ | ;; | ||
+ | esac | ||
+ | } | ||
+ | |||
+ | ####################### | ||
+ | #### KICKING UP IT #### | ||
+ | ####################### | ||
+ | |||
+ | echo " | ||
+ | |||
+ | obtem_valores | ||
+ | |||
+ | ################ | ||
+ | #### XYMON #### | ||
+ | ################ | ||
+ | |||
+ | $BB $BBDISP " | ||
+ | |||
+ | `cat $LOG2`" | ||
+ | |||
+ | exit 0 | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== Known Bugs and Issues ===== | ||
+ | |||
+ | ===== To Do ===== | ||
+ | |||
+ | Graphic all variables. | ||
+ | |||
+ | ===== Credits ===== | ||
+ | |||
+ | Melonfire - For MySQL explanation. | ||
+ | |||
+ | ===== Changelog ===== | ||
+ | |||
+ | * **2012-11-23** | ||
+ | * Initial release |