Author:skate
Time:2014/12/23
Database Availability Monitoring Tool
[Email protected] tmp]#/db_availability--help
usage:used to view server Availability v0.1, (C) Copyright Skate 2014
[-h]--host host--user user--passwd passwd [--port Port]
[--dbname dbname]--rhost rhost--ruser ruser--rpasswd rpasswd
[--rport Rport] [--rdbname Rdbname] [--type Type] [--interval interval]
Optional arguments:
-H,--help show this help message and exit
--host host = Data Configuration Center IP address
--user user = Data Configuration Center Database user
--PASSWD passwd = Data Configuration Center Database Password
--port port = Data Configuration Center Database port
--dbname dbname = Data Configure Center database name
--rhost rhost = Monitored IP address
--ruser ruser = Monitored database user
--rpasswd rpasswd = Monitored database password
--rport rport = Monitored database port
--rdbname rdbname = Monitored database name
--type type = monitored type (db or Host)
--interval interval = The monitoring time interval, this is very important,
Strict accordance with the call
Interval
[Email protected] tmp]#/db_availability--host=10.20.0.55--user=root--passwd=root--port=3306--dbname=test6-- rhost=10.20.0.56--ruser=root--rpasswd=root--rport=3306--rdbname=mysql--type=db--interval 60
IPAddr 10.20.0.56:
database:3306 vailability is:
Month 100%
3month 100%
Year 100%
Total 100%
Uptime (s) 1116020
Downtime (s) 0
[Email protected] tmp]#
[Email protected] tmp]#/db_availability--host=10.20.0.55--user=root--passwd=root--port=3306--dbname=test6-- rhost=10.20.0.65--ruser=root--rpasswd=root--rport=3306--rdbname=mysql--type=db--interval 60
IPAddr 10.20.0.65:
database:3306 vailability is:
Month 97.62%
3month 99.22%
Year 99.8%
Total 99.98%
Uptime (s) 0
Downtime (s) 61620
[Email protected] tmp]#
Briefly:
This tool can be monitored for database and host in the last one months, 3 months, a year and all the time within the availability (by default, when not monitored, database and host is available, not in the Uptime/uptime+downtime way), You can also see the online and offline time of database and host during the monitored period. This allows you to understand how the database and host are used during each period.
Usage Environment:
Ability to monitor availability and offline time for MySQL services and servers
How to use:
This tool is a monitoring configuration center that writes configuration monitoring information, and then analyzes the collected data in real time, which can be deployed to the server, through the concurrent batch inspection of a large number of database and host
Installation method:
This tool is developed in Python and has been packaged, can be downloaded directly using, no environmental dependencies
Special Note:
1. The interval parameter is particularly important, in order to increase the accuracy of the availability rate, this interval must be selected in the same time interval as the tool was called.
Database script for Configuration center:
CREATE TABLE ' db_availability ' (
' ID ' INT (one) UNSIGNED Zerofill not NULL auto_increment,
' Createtime ' DATETIME null DEFAULT null COMMENT ' creation time ',
' UpdateTime ' DATETIME null DEFAULT null COMMENT ' Update Time ',
' Downtime ' INT (one) NULL DEFAULT ' 0 ' COMMENT ' down time, unit of measurement seconds ',
' Uptime ' INT (one) NULL DEFAULT ' 0 ' COMMENT ' online time, unit of measurement seconds ',
' Weekavailability ' DECIMAL (10,4) NULL DEFAULT ' 1.0000 ' COMMENT ' weekly online rate ',
' Monthavailability ' DECIMAL (10,4) NULL DEFAULT ' 1.0000 ' COMMENT ' monthly online rate ',
' Month3availability ' DECIMAL (10,4) NULL DEFAULT ' 1.0000 ' COMMENT ' 3 month online rate ',
' Yearavailability ' DECIMAL (10,4) NULL DEFAULT ' 1.0000 ' COMMENT ' annual online rate ',
' Allavailability ' DECIMAL (10,4) NULL DEFAULT ' 1.0000 ' COMMENT ' total online rate ',
' Type ' VARCHAR (+) null DEFAULT null COMMENT ' two types: host and DB ',
' Interval ' INT (one) null DEFAULT null COMMENT ' time interval, unit of measure seconds ',
' IPAddr ' VARCHAR (+) null DEFAULT null COMMENT ' IP address ',
' Port ' VARCHAR (+) null DEFAULT null,
' Hostname ' VARCHAR (+) null DEFAULT null COMMENT ' host name ',
' IDC ' VARCHAR (+) null DEFAULT null COMMENT ' belongs to IDC ',
PRIMARY KEY (' id '),
UNIQUE INDEX ' ipaddr_port_type ' (' ipaddr ', ' Port ', ' type ')
)
Collate= ' Utf8_general_ci '
Engine=innodb;
CREATE TABLE ' Db_downtime_detail ' (
' ID ' INT (one) not NULL auto_increment,
' IPAddr ' VARCHAR (+) null DEFAULT null COMMENT ' IP address ',
' Port ' VARCHAR (+) null DEFAULT null,
' Hostname ' VARCHAR (+) null DEFAULT null COMMENT ' host name ',
' Createtime ' DATETIME null DEFAULT null COMMENT ' creation time ',
' Interval ' INT (one) null DEFAULT null COMMENT ' time interval, unit of measure seconds ',
' Type ' VARCHAR ($) null DEFAULT null COMMENT ' downtime type: Host and DB ',
' IDC ' VARCHAR (+) null DEFAULT null COMMENT ' belongs to IDC ',
PRIMARY KEY (' id '),
INDEX ' Createtime ' (' Createtime ')
)
Comment= ' Downtime detail time record table '
Collate= ' Utf8_general_ci '
Engine=innodb;
----END----
Database Availability Monitoring Tool