Before is cacti monitoring MySQL, many parameters monitoring is not particularly clear, think about looking for Zabbix monitoring.
Write a configuration file that monitors MySQL
Userparameter=mysql. Ping,mysqladmin -uroot -p123456 ping|grep alive|wc -luserparameter=mysql. Threads,mysqladmin -uroot -p123456 status|cut -f3 -d ":" |cut -f1 -d "Q" Userparameter=mysql. Questions,mysqladmin -uroot -p123456 status|cut -f4 -d ":" |cut -f1 -d " S "Userparameter=mysql. Slowqueries,mysqladmin -uroot -p123456 status|cut -f5 -d ":" |cut -f1 - D "O" Userparameter=mysql. Qps,mysqladmin -uroot -p123456 status|cut -f9 -d ":" UserParameter=mysql. slave_io_state,if [ "$ (mysql -uroot -p123456 -e " show slave Status\g "| grep slave_io_running|awk ' {print $2} ')" == "Yes" ];then Echo 1; else echo 0;fiuserparameter=mysql. slave_sql_state,if [ "$ (mysql -uroot -p123456 -e " show slave&Nbsp;status\g "| grep slave_sql_running|awk ' {print $2} ')" == "Yes" ];then echo 1; else echo 0;fiuserparameter=mysql. key_buffer_size,mysql -uroot -p123456 -e "show variables like ' Key_ Buffer_size '; ' | grep -v Value |awk ' {print $2/1024^2} ' userparameter=mysql. key_reads,mysql -uroot -p123456 -e "show global status like " key _reads '; ' | grep -v Value |awk ' {print $2} ' userparameter=mysql. key_read_requests,mysql -uroot -p123456 -e "Show global status like ' key_read_requests '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. key_cache_miss_rate,echo $ (mysql -uroot -p123456 -e "show global status like ' key_reads '; "| grep -v Value |awk ' {print $2} ') $ (mysql -uroot -p123456 -e "show global status like ' key_read_requests '; "| grep -v Value |awk ' {print $2} ') | awk ' {printf ("%1.4f\n", $1/$2*100)} ' Userparameter=mysql. key_blocks_used,mysql -uroot -p123456 -e "Show global status like ' key_blocks_used '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. key_blocks_unused,mysql -uroot -p123456 -e "Show global status like ' key_blocks_unused '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. key_blocks_used_rate,echo $ (mysql -uroot -p123456 -e "show global status like ' key_blocks_used '; "| grep -v Value |awk ' {print $2} ') $ (mysql -uroot -p123456 -e "Show global status like ' key_blocks_unused '; "| grep -v Value |awk ' {print $2} ') | awk ' {printf ("%1.4f\n", $1/($1+$2) * )} ' Userparameter=mysql. innodb_buffer_pool_size,mysql -uroot -p123456 -e "Show variables like ' innodb_buffer_pool_size '; "| grep -v Value |awk ' {print $2/1024^2} ' userparameter=mysql. innodb_log_file_size,mysql -uroot -p123456 -e "show variables like " Innodb_log_file_size '; ' | grep -v Value |awk ' {print $2/1024^2} ' userparameter=mysql. innodb_log_buffer_size,mysql -uroot -p123456 -e "show variables like ' Innodb_log_buffer_size '; "| grep -v Value |awk ' {print $2/1024^2} ' userparameter=mysql. table_open_cache,mysql -uroot -p123456 -e "show variables like ' table _open_cache '; ' | grep -v value |awk ' {print $2} ' userparameter=mysql. open_tables,mysql -uroot -p123456 -e "show global status like " Open_tables '; ' | grep -v Value |awk ' {print $2} ' userparameter=mysql. opened_tables,mysql -uroot -p123456 -e "show global status like ' Opened_tables '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. open_tables_rate,echo $ (mysql -uroot -p123456 -e "Show global status like ' open_tables '; "| grep -v Value |awk ' {print $2} ') $ (mysql -uroot -p123456 -e "show global status like ' opened_tables ';" | grep -v Value |awk ' {print $2} ') | awk ' {printf ("%1.4f\n", $1/($1+$2) * )} ' Userparameter=mysql. table_open_cache_used_rate,echo $ (MYSQL -UROOT -P123456 -e "show global status like ' open_tables ';" | grep -v Value |awk ' {print $2} ') $ (mysql -uroot -p123456 -e "show variables like ' Table_open_cache ';" | grep -v Value |awk ' {print $2} ') | awk ' {printf ("%1.4f\n", $1/($1+$2) * )} ' Userparameter=mysql. thread_cache_size,mysql -uroot -p123456 -e "show variables like " Thread_cache_size '; ' | grep -v Value |awk ' {print $2} ' userparameter=mysql. threads_cached,mysql -uroot -p123456 -e "Show global status like ' threads_cached '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. threads_connected,mysql -uroot -p123456 -e "Show global status like ' threads_connected '; "| grep -v value |awk ‘ {print $2} ' userparameter=mysql. threads_created,mysql -uroot -p123456 -e "Show global status like ' threads_created '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. threads_running,mysql -uroot -p123456 -e "Show global status like ' threads_running '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. qcache_free_blocks,mysql -uroot -p123456 -e "Show global status like ' qcache_free_blocks '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. qcache_free_memory,mysql -uroot -p123456 -e "Show global status like ' qcache_free_memory '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. qcache_hits,mysql -uroot -p123456 -e "SHOW GLOBAL STATUS&Nbsp;like ' qcache_hits '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. qcache_inserts,mysql -uroot -p123456 -e "Show global status like ' qcache_inserts '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. qcache_lowmem_prunes,mysql -uroot -p123456 -e "show global status like ' qcache_lowmem_prunes '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. qcache_not_cached,mysql -uroot -p123456 -e "Show global status like ' qcache_not_cached '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. qcache_queries_in_cache,mysql -uroot -p123456 -e "show global status like ' Qcache_queries_in_cache '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. Qcache_total_blocks,mysql -uroot -p123456 -e "Show global status like ' qcache_total_blocks '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. qcache_fragment_rate,echo $ (mysql -uroot -p123456 -e "show global status like ' qcache_free_blocks '; "| grep -v Value |awk ' {print $2} ') $ (mysql -uroot -p123456 -e "show global status like ' qcache_total_blocks ';" | grep -v Value |awk ' {print $2} ') | awk ' {printf ("%1.4f\n", $1/$2*100)} ' Userparameter=mysql. qcache_used_rate,echo $ (mysql -uroot -p123456 -e "Show variables like ' query_cache_size '; "| grep -v Value |awk ' {print $2} ') $ (mysql -uroot -p123456 -e "show global status like ' QCACHe_free_memory '; ' | grep -v Value |awk ' {print $2} ') | awk ' {printf ("%1.4f\n", ($1-$2)/$1* )} ' Userparameter=mysql. qcache_hits_rate,echo $ (mysql -uroot -p123456 -e "Show global status like ' qcache_hits '; "| grep -v Value |awk ' {print $2} ') $ (mysql -uroot -p123456 -e "show global status like ' qcache_inserts ';" | grep -v Value |awk ' {print $2} ') | awk ' {printf ("%1.4f\n", ($2-$1)/$2* )} ' Userparameter=mysql. query_cache_limit,mysql -uroot -p123456 -e "show variables like " Query_cache_limit '; ' | grep -v Value |awk ' {print $2} ' userparameter=mysql. query_cache_min_res_unit,mysql -uroot -p123456 -e "Show variables like ' Query_cache_min_res_unit '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. query_cache_size,mysql -uroot -p123456 -e "show variables like ' query _cache_size '; ' | grep -v Value |awk ' {print $2} ' userparameter=mysql. sort_merge_passes,mysql -uroot -p123456 -e "Show global status like ' sort_merge_passes '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. sort_range,mysql -uroot -p123456 -e "show global status like " Sort_range '; ' | grep -v Value |awk ' {print $2} ' userparameter=mysql. sort_rows,mysql -uroot -p123456 -e "show global status like " Sort_rows '; ' | grep -v Value |awk ' {print $2} ' userparameter=mysql. sort_scan,mysql -uroot -p123456 -e "show global status like " Sort_scan '; ' | grep -v value |awk ' {print $2} ' userparameter=mysql. handler_read_first,mysql -uroot -p123456 -e "Show global status like ' Handler_read_first '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. handler_read_key,mysql -uroot -p123456 -e "Show global status like ' Handler_read_key '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. handler_read_next,mysql -uroot -p123456 -e "Show global status like ' Handler_read_next '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. handler_read_prev,mysql -uroot -p123456 -e "Show global status like ' Handler_read_prev '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. handler_read_rnd,mysql -uroot -p123456 -e "show global status like ' handler_read_rnd ';" | grep -v Value |awk ' {print $2} ' userparameter=mysql. handler_read_rnd_next,mysql -uroot -p123456 -e "show global status like ' Handler_read_rnd_next '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. com_select,mysql -uroot -p123456 -e "show global status like " Com_select '; ' | grep -v Value |awk ' {print $2} ' userparameter=mysql. com_insert,mysql -uroot -p123456 -e "show global status like " Com_insert '; ' | grep -v Value |awk ' {print $2} ' userparameter=mysql. com_insert_select,mysql -uroot -p123456 -e "Show global status like ' Com_insert_select '; "| grep -v Value |awk ' {print $2} 'Userparameter=mysql. com_update,mysql -uroot -p123456 -e "show global status like " Com_update '; ' | grep -v Value |awk ' {print $2} ' userparameter=mysql. com_replace,mysql -uroot -p123456 -e "show global status like " Com_replace '; ' | grep -v Value |awk ' {print $2} ' userparameter=mysql. com_replace_select,mysql -uroot -p123456 -e "Show global status like ' Com_replace_select '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. table_scan_rate,echo $ (mysql -uroot -p123456 -e "Show global status like ' Handler_read_rnd_next '; "| grep -v Value |awk ' {print $2} ') $ (mysql -uroot -p123456 -e "show global status like ' com_select ';" | grep -v Value |awk ' {print $2} ') | awk ' {printf ("%1.4f\n", $1/$2*100)} ' userparameter= Mysql. open_files,mysql -uroot -p123456 -e "show global status like " Open_files '; ' | grep -v Value |awk ' {print $2} ' userparameter=mysql. open_files_limit,mysql -uroot -p123456 -e "show variables like ' Open_ Files_limit '; ' | grep -v Value |awk ' {print $2} ' userparameter=mysql. open_files_rate,echo $ (mysql -uroot -p123456 -e "Show global status like ' open_files '; "| grep -v Value |awk ' {print $2} ') $ (mysql -uroot -p123456 -e "show variables like ' open_files_limit ';" | grep -v Value |awk ' {print $2} ') | awk ' {printf ("%1.4f\n", $1/$2*100)} ' Userparameter=mysql. Created_tmp_disk_tables,mysql -uroot -p123456 -e "show global status like ' Created_tmp_disk_ Tables '; ' | grep -v Value |awk ' {print $2} ' userparameter=mysql. created_tmp_tables,mysql -uroot -p123456 -e "Show global status like ' created_tmp_tables '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. created_tmp_disk_tables_rate,echo $ (mysql -uroot -p123456 -e "Show global status like ' created_tmp_disk_tables '; "| grep -v Value |awk ' {print $2} ') $ (mysql -uroot -p123456 -e "show global status like ' created_tmp_tables ';" | grep -v Value |awk ' {print $2} ') | awk ' {printf ("%1.4f\n", $1/$2*100)} ' Userparameter=mysql. max_connections,mysql -uroot -p123456 -e "Show variables like ' max_connections '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. max_used_connections,mysql -uroot -p123456 -e "show global status like ' max_used_connections '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. max_connections_used_rate,echo $ (mysql -uroot -p123456 -e "Show global status like ' max_used_connections '; "| grep -v Value |awk ' {print $2} ') $ (mysql -uroot -p123456 -e "show variables like ' max_connections ';" | grep -v Value |awk ' {print $2} ') | awk ' {printf ("%1.4f\n", $1/$2*100)} ' Userparameter=mysql. table_locks_immediate,mysql -uroot -p123456 -e "show global status like ' table_locks_immediate '; "| grep -v Value |awk ' {PRINT&Nbsp;$2} ' Userparameter=mysql. table_locks_waited,mysql -uroot -p123456 -e "Show global status like ' table_locks_waited '; "| grep -v Value |awk ' {print $2} ' userparameter=mysql. engine_select,echo $ (mysql -uroot -p123456 -e "Show global status like ' table_locks_immediate '; "| grep -v Value |awk ' {print $2} ') $ (mysql -uroot -p123456 -e "show global status like ' table_locks_waited ';" | grep -v Value |awk ' {print $2} ') |awk ' {if ($2==0) {printf ("%1.4f\n", 0)}else{ printf ("%5.4f\n", $1/$2)}} '
A closer look will make it easier to see what is being monitored.
Zabbix seems to have a bug in the agent program can not grep and then grep will not get data.
Monitor template file I put it in the attachment.
The following is 650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/73/81/wKioL1X_z-OxxCWvAAeG2dov5fA071.jpg "title=" QQ picture 20150921172655.png "alt=" Wkiol1x_z-oxxcwvaaeg2dov5fa071.jpg "/>
This article is from the "tireless learning ..." Blog, reprint please contact the author!
Zabbix monitoring MySQL Status