/HeartbeatOne

A MySql master-salve replication lag time checker more like pt-heartbeat.

Primary LanguagePHPMIT LicenseMIT

简体中文

HeartbeatOne

A MySql master-salve replication lag time checker tool implementation by PHP more like pt-heartbeat.

ScreenShot

(command line sample)
image

(log file sample)
image

Istall&Usage

Install

Download this project zip file and deploy on your any one php machine which can access MySql server.

Setting

Change the setting.php according to your actual situation.

<?php

/**
 * Default setting sample
 * 
 */

return [
    'mysqlMasterHost' => '', // Write server host

    'mysqlMasterUser' => '',

    'mysqlMasterPwd' => '',

    'mysqlSlaveHosts' => [], // Slaves host of the master

    'mysqlSlaveUser' => '', // Read server username

    'mysqlSlavePwd' => '',

    'interval' => 1, // Frequency for update monitor time in seconds

    'averages' => [1, 5, 30], // Latest period slave lagging average time in seconds, can be more than three and even more, su as [1, 5, 30, 60 ...]

    'logFilePath' => '/val/logs/',

    'logFileName' => 'HeartbeatOne-Monitor',

    'mysqlDriver' => 'mysqli', // Only support `mysqlli` or `PDO` driver
];

Create Monitor Table

Import heartbeat.sql to your MySQl master server which you want tracing.

Running

Just run following command in cli, you can see dealy time report and wirte to log in the meanwhile if everything is ok.

php heartbeat.php

For the production suggest run in background then only wirte delay data to log file.

nohup php heartbeat.php > /dev/null &

Details

  • Notice! The monitor log content will be clear every 24hours