# Can we monitor M-S data consistency by using pt-table-checksum through shell script

**URL:** <https://forums.percona.com/t/can-we-monitor-m-s-data-consistency-by-using-pt-table-checksum-through-shell-script/11221>\
**Category:** MySQL & MariaDB\
**Tags:** percona\
**Created:** [July 6, 2021, 3:28am UTC](https://forums.percona.com/t/can-we-monitor-m-s-data-consistency-by-using-pt-table-checksum-through-shell-script/11221 "2021-07-06T03:28:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vasu1](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/vasu1/32/3519_2.png) [@vasu1](https://forums.percona.com/u/vasu1)\
**Post date:** [July 6, 2021, 3:28am UTC](https://forums.percona.com/t/can-we-monitor-m-s-data-consistency-by-using-pt-table-checksum-through-shell-script/11221/1 "2021-07-06T03:28:19Z")

</div>

Hello Team,

I am planning to monitor the M-S replication data consistency by using pt-table-checksum and send the report to mail … Here for HA if we are using maxscale , how we can do this ? becasue whenever it is prompt M-S , S-M , how we can monitor ?

Pls guide me

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [July 6, 2021, 3:44pm UTC](https://forums.percona.com/t/can-we-monitor-m-s-data-consistency-by-using-pt-table-checksum-through-shell-script/11221/2 "2021-07-06T15:44:59Z")

</div>

pt-table-checksum should be ran directly to the source, not through maxscale. You will need to write a wrapper script to run pt-t-c, then check the exit code ($?). If not 0, then there are differences, then the script should send an email. You will need to have an email relay server setup on whichever server is executing pt-t-c and you will also need to have replica monitoring configured within pt-t-c correctly.

---

<div class="post-metadata">

**Author:** ![vasu1](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/vasu1/32/3519_2.png) [@vasu1](https://forums.percona.com/u/vasu1)\
**Post date:** [July 7, 2021, 5:28am UTC](https://forums.percona.com/t/can-we-monitor-m-s-data-consistency-by-using-pt-table-checksum-through-shell-script/11221/3 "2021-07-07T05:28:08Z")

</div>

Hi @matthewb

We have replication setup with Master - Slave , and max scale setup to monitor and promte as a master from slave , from slave to master …Monitor is in place …  
Now i want to run this script in maxscale server based on the current master status , the script will run and check the pt-t-c utility and sent mail notification .

Do you have sample script on this ?

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [July 7, 2021, 2:25pm UTC](https://forums.percona.com/t/can-we-monitor-m-s-data-consistency-by-using-pt-table-checksum-through-shell-script/11221/4 "2021-07-07T14:25:46Z")

</div>

> [@vasu1](#):
>
> Do you have sample script on this ?

I do not. This is something custom to everyone. You simply need to write a ~10-20 line bash script to ask maxscale who the current master is, and then run pt-t-c against that master and send an email if the exit code is not 0.
