# Zabbix模板

#### userparameter\_mysql.conf

```
# 连接数
UserParameter=mysql.max_connections,echo "show variables where Variable_name='max_connections';" | mysql -N | awk '{print $2}'
UserParameter=mysql.current_connections,echo "show global status where Variable_name='Threads_connected';" |  mysql -N | awk '{print $2}'
# 缓冲池
UserParameter=mysql.buffer_pool_size,echo "show variables where Variable_name='innodb_buffer_pool_size';" | mysql -N |awk '{printf "%.2f",$2/1024/1024/1024}' 
UserParameter=mysql.buffer_pool_usage_percent,echo "show global status where Variable_name='Innodb_buffer_pool_pages_free' or Variable_name='Innodb_buffer_pool_pages_total';" | mysql -N | awk '{a[NR]=$2}END{printf "%.1f",100-((a[1]/a[2])*100)}'
# 增删改查
UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | mysql -N | awk '{print $$2}'
# 实例状态
UserParameter=mysql.ping,HOME=/usr/local/zabbix_agent mysqladmin ping | grep -c alive
UserParameter=mysql.version,mysql -V

```

{% file src="https://2134947750-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvILwbD2PrkBCkSitM3m4%2Fuploads%2Fd4gOCQ9DfoPChV1B6mla%2Fmysql_templates.xml?alt=media&token=0c7b24d2-2008-4ca1-a90b-a9772ff5a44c" %}

{% file src="https://2134947750-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvILwbD2PrkBCkSitM3m4%2Fuploads%2FU6yusKBr6HCCpjXoMYPj%2Fnginx_status_templates.xml?alt=media&token=ce867d32-7d03-420e-bf06-c66f7328eb69" %}

{% file src="https://2134947750-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvILwbD2PrkBCkSitM3m4%2Fuploads%2FL9oiAg55fJZitBBg32oF%2Ftcp_status_templates.xml?alt=media&token=7d95de89-b647-4ad5-8c88-6785bc8fce49" %}

{% file src="https://2134947750-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvILwbD2PrkBCkSitM3m4%2Fuploads%2FbP1EfK451TGY21Ddet46%2FZabbix.pdf?alt=media&token=814e1fd0-96f7-466c-8004-a4883e9d3532" %}
