MySQL Server alarm script, mysqlserver

Source: Internet
Author: User
Tags dname

MySQL Server alarm script, mysqlserver

Author: Skate
Time: 2014/12/30

 

MySQL Server email alert

: Http://download.csdn.net/detail/wyzxg/8314745

 

Implementation Method:

The system's load and session are used to determine whether the system's current load is too high. If the load is found to be too high, an email alert is triggered (of course, a short-term alert can also be triggered ), alert the current system status, slow SQL statements, and lock status in HTML mail,
You can also carry attachments.


Basic usage:

[Root @ skatedb66 tmp] #./dbmysqlalarm -- help
Usage: Alarm Mysql server performance v0.1, (C) Copyright Skate 2014
[-H] -- dhost DHOST -- duser DUSER -- dpasswd DPASSWD -- dport DPORT
-- Dname DNAME -- mail MAIL -- mhost MHOST -- muser MUSER -- mpasswd MPASSWD
-- Msubject MSUBJECT -- mconfig MCONFIG -- mkey MKEY -- mfield MFIELD
-- Attach ATTACH -- dload DLOAD -- dsession DSESSION

Optional arguments:
-H, -- help show this help message and exit
-- Dhost DHOST = Monitored database ip address
-- Duser DUSER = Monitored database user
-- Dpasswd DPASSWD = Monitored database password
-- Dport DPORT = Monitored database port
-- Dname DNAME = Monitored database name
-- Mail MAIL = Monitored database name
-- Mhost MHOST = Mail server host address
-- Muser MUSER = Mailbox username
-- Mpasswd MPASSWD = Mailbox password
-- Msubject MSUBJECT = Mail subject
-- Mconfig MCONFIG = Mail recipient configuration file
-- Mkey MKEY = The key that mail recipient configuration file
-- Mfield MFIELD = The field that mail recipient configuration file
-- Attach ATTACH = Email attachment
-- Dload DLOAD = Alarm threshold load
-- Dsession DSESSION = Alarm threshold session of database


Example:

#./Dbmysqlalarm \
-- Mconfig =/tmp/dist/list \
-- Muser = dba \
-- Mpasswd = pass \
-- Mhost = localhost \
-- Msubject = 'real-time Snapshot of database '\
-- Attach = '/tmp/dist/list '\
-- Dhost = 127.0.0.1 \
-- Dpasswd = passwd \
-- Dport = 3306 \
-- Dname = mysql \
-- Mkey = dba \
-- Mfield = email \
-- Mail = dba@skate.com \
-- Dload = 0 \
-- Dsession = 0

 

Parameter description

-- Mconfig =/tmp/dist/list // specifies the path of the configuration file, if there is a configuration center, you can do not need to configure the file, see: http://blog.csdn.net/wyzxg/article/details/41972683
-- Muser = dba // User Name of the mailbox
-- Mpasswd = passwd // password of the mailbox
-- Mhost = localhost // address of the email server. If you use the local machine to send an email, specify localhost
-- Msubject = 'real-time Snapshot of database' // mail title
-- Attach = '/tmp/dist/list' // path of the Attachment
-- Dhost = 127.0.0.1 // ip address of the database
-- Duser = root // User Name of the database
-- Dpasswd = passwd // Database Password
-- Dport = 3306 // database port number
-- Dname = mysql // name of the connected database. No operation is performed on the database. mysql is specified here. Of course, you can create a test database.
-- Mkey = dba // key of the configuration file
-- Mfield = email // The field of the configuration file
-- Mail = dba@skate.com // the email address of the specified sent mail
-- Dload = 0 // load threshold value that triggers the alarm
-- Dsession = 0 // number of database sessions that trigger an alarm


Note: first, use mysql-u-p-h-P to test whether the database can be connected.

 

Configuration File Format
# More list
[Command]
Mysqlmon =/tmp/dist/mysqlmon

[Phone]
Dba: 135 *******; 135 **********; 123 *********
Skate: 138 *******

[Email]
Dba: skate1@skate.com; skate2@skate.com; skate3@skate.com
Skate: skate@skate.com


Deployment Method

Directly decompress the downloaded file and update the absolute path of the extracted file mysqlmon to the configuration file.

# Tar-zxvf dbalarm.tar.gz

 

Supported versions: mysqlmon of "anysql" is referenced here. After my test, it is found that mysqlmon currently supports mysql 5.5.29 or above under centos6 (confirmed with anysql, because he compiled the 5.6 client to cause this problem ).. Anysql is a very useful tool.

 

Image of The alarm Email:

 

 

------ End -----

 

 

Related Article

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.