Zabbix self-template monitoring MySQL

Source: Internet
Author: User


Scripting on client-side monitoring

http://www.ttlsa.com/zabbix/zabbix-monitor-mysql/


vim/usr/local/zabbix-2.2.2/scripts/chk_mysql.sh


#!/bin/bash

# -------------------------------------------------------------------------------

# FileName:check_mysql.sh

# revision:1.0

# date:2015/06/09

# Author:dengyun

# email: [Email protected]

# Website:www.ttlsa.com

# Description:

# Notes: ~

# -------------------------------------------------------------------------------

# copyright:2015 (c) Dengyun

# LICENSE:GPL


# User Name

Mysql_user= ' Root '


# password

Mysql_pwd= ' 123.com '


# Host address/IP

Mysql_host= ' 127.0.0.1 '


# port

Mysql_port= ' 3306 '


# Data connection

Mysql_conn= "/usr/bin/mysqladmin-u${mysql_user}-p${mysql_pwd}-h${mysql_host}-p${mysql_port}"


# parameters are correct

If [$#-ne "1"];then

echo "Arg error!"

Fi


# Get Data

Case $ in

Uptime)

result= ' ${mysql_conn} status|cut-f2-d ":" |cut-f1-d "T" '

Echo $result

;;

Com_update)

result= ' ${mysql_conn} extended-status |grep-w "Com_update" |cut-d "|"-f3 '

Echo $result

;;

Slow_queries)

result= ' ${mysql_conn} status |cut-f5-d ":" |cut-f1-d "O"

Echo $result

;;

Com_rollback)

result= ' ${mysql_conn} extended-status |grep-w "Com_rollback" |cut-d "|"-f3 '

Echo $result

;;

Questions)

result= ' ${mysql_conn} status|cut-f4-d ":" |cut-f1-d "S" '

Echo $result

;;

Com_insert)

result= ' ${mysql_conn} extended-status |grep-w "Com_insert" |cut-d "|"-f3 '

Echo $result

;;

Com_delete)

result= ' ${mysql_conn} extended-status |grep-w "Com_delete" |cut-d "|"-f3 '

Echo $result

;;

Com_commit)

result= ' ${mysql_conn} extended-status |grep-w "Com_commit" |cut-d "|"-f3 '

Echo $result

;;

Bytes_sent)

result= ' ${mysql_conn} extended-status |grep-w "bytes_sent" |cut-d "|"-f3 '

Echo $result

;;

bytes_received)

result= ' ${mysql_conn} extended-status |grep-w "bytes_received" |cut-d "|"-f3 '

Echo $result

;;

Com_begin)

result= ' ${mysql_conn} extended-status |grep-w "Com_begin" |cut-d "|"-f3 '

Echo $result

;;


*)

echo "Usage:$0 (uptime| com_update| slow_queries| Com_select| com_rollback| questions| Com_insert| com_delete| Com_commit| Bytes_sent| bytes_received| Com_begin) "

;;

Esac


Script to have Execute permission



Modifying a configuration file


Vim/usr/local/zabbix-2.2.2/etc/zabbix_agentd.conf

At the end, add

Userparameter=mysql.version,mysql-v

Userparameter=mysql.status[*],/usr/local/zabbix/scripts/chk_mysql.sh $

userparameter=mysql.ping,mysqladmin-uroot-p123.com-p3306-h127.0.0.1 Ping | Grep-c Alive


Authorized

Grant all privileges on * * to [e-mail protected] identified by ' 123.com ';


Restart

Killall Zabbix-agentd

/usr/local/zabbix-2.4.4/bin/zabbix_agentd


Connection templates


650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/81/FA/wKioL1dGrAzBYyjZAABlc4e4TM8214.png "title=" 1.PNG " alt= "Wkiol1dgrazbyyjzaablc4e4tm8214.png"/>


Ok


This article from "No Trace" blog, declined reproduced!

Zabbix self-template monitoring MySQL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.