Author: SkateTime: 20141223 Database Availability monitoring tool [root @ skatedb66tmp] #. db_availability -- helpusage: Usedtoviewserveravailabilityv0.1, (C) CopyrightSkate2014 [-h] -- hostHOST -- userUSER -- passwdPASSWD [-- portPORT] [-- dbname
Author: Skate Time: 2014/12/23 Database Availability monitoring tool [root @ skatedb66 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
Author: Skate
Time: 2014/12/23
Database Availability Monitoring Tool
[Root @ skatedb66 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 passwo [from the Internet (http://www.68idc.cn)] rd
-- Port 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,
Please fill out in strict accordance with the call
Interval
[Root @ skatedb66 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.0000%
3 month 100.0000%
Year 100.0000%
Total 100.0000%
Uptime (s) 1116020
Downtime (s) 0
[Root @ skatedb66 tmp] #
[Root @ skatedb66 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.00000.65:
Database: 3306 vailability is:
Month 97.6200%
3 month 99.2200%
Year 99.8000%
Total 99.9800%
Uptime (s) 0
Download time (s) 61620
[Root @ skatedb66 tmp] #
Brief description:
This tool can obtain the availability of the database and host in the last month, three months, one year, and all time through monitoring (by default, the database and host are available when not monitored, it is not calculated using the uptime/uptime + downtime method), and you can also see the online and offline time of the database and host in the monitored period. In this way, you can understand the usage of databases and hosts in various periods.
Environment:
Monitor the availability and offline time of mysql service and server
Usage:
This tool writes the configuration monitoring information to the monitoring configuration center, and then analyzes the collected data in real time. You can deploy this tool on the server and check a large number of databases and hosts in batches through concurrency.
Installation Method:
This tool is developed and packaged using python. You can directlyDownloadUse, no environment dependency
Note:
1. The interval parameter is particularly important. To improve the availability accuracy, the interval must be the same as the call interval of the tool.
Database script of the configuration center:
Create table 'db _ availability '(
'Id' INT (11) unsigned zerofill not null AUTO_INCREMENT,
'Createtime' datetime null default null comment' creation time ',
'Updatetime' datetime null default null comment' update time ',
'Downtime' INT (11) null default '0' comment' downtime, measured in seconds ',
'Uptime' INT (11) null default '0' comment' online time, measured in seconds ',
'Weekavailability 'decimal (0000) null default '1. 'comment' week on-line rate ',
'Monthavailability 'DECIMAL (0000) null default '1. 'comment' monthly on-line rate ',
'Month3availability 'DECIMAL (0000) null default '1. 'comment' 3-month on-line rate ',
'Earavailability 'decimal (0000) null default '1. 'comment' annual on-line rate ',
'Allavailable' DECIMAL (0000) null default '1. 'comment' total on-line rate ',
'Type' VARCHAR (50) null default null comment' two types: host and db ',
'Interval 'int (11) null default null comment' time interval, measurement unit second ',
'Ipaddr 'VARCHAR (50) null default null comment 'IP address ',
'Port' VARCHAR (50) null default null,
'Hostname' VARCHAR (50) null default null comment 'host name ',
'Idc 'VARCHAR (50) null default null comment' idc ',
Primary key ('id '),
Unique index 'ipaddr _ port_type '('ipadd', 'Port', 'type ')
)
COLLATE = 'utf8 _ general_ci'
ENGINE = InnoDB;
Create table 'db _ downtime_detail '(
'Id' INT (11) not null AUTO_INCREMENT,
'Ipaddr 'VARCHAR (50) null default null comment 'IP address ',
'Port' VARCHAR (50) null default null,
'Hostname' VARCHAR (50) null default null comment 'host name ',
'Createtime' datetime null default null comment' creation time ',
'Interval 'int (11) null default null comment' time interval, measurement unit second ',
'Type' VARCHAR (50) null default null comment' downtime type: host and db ',
'Idc 'VARCHAR (50) null default null comment' idc ',
Primary key ('id '),
INDEX 'createtime' ('createtime ')
)
COMMENT = 'downtime detailed time record table'
COLLATE = 'utf8 _ general_ci'
ENGINE = InnoDB;
---- End ----