<commit_before>mysql-slave-healthcheck-agent
=============================

Description
------------

`mysql-slave-healthcheck-agent` is a HTTP daemon to show an information of "SHOW SLAVE STATUS" in JSON format.

This is useful for HAProxy's health check access instead of `option mysql-check`.

```
# haproxy.cfg
listen mysql
       bind     127.0.0.1:3306
       mode     tcp
       balance  roundrobin
       option   httpchk
       server   slave1 192.168.1.11:3306 check port 5000
       server   slave2 192.168.1.12:3306 check port 5000
```

Usage
------

```
$ mysql-slave-healthcheck-agent
2014/05/21 00:04:28 Listing port 5000
2014/05/21 00:04:28 dsn root:@tcp(127.0.0.1:3306)/?charset=utf8
```

```
$ curl localhost:5000 | jq .
{
  "Connect_Retry": 60,
  "Exec_Master_Log_Pos": 1048,
  "Last_Errno": 0,
  "Last_Error": "",
  "Master_Host": "db-master",
  "Master_Log_File": "mysql-bin.000006",
  "Master_Port": 3306,
  ...
  "Until_Log_File": "",
  "Until_Log_Pos": 0
}
```

* The query "SHOW SLAVE STATUS" was succeeded, return HTTP status 200 and JSON.
* If could not connect to the MySQL or the MySQL is not a slave, return HTTP status 500.

Options
-------

* -port : http listen port number. default 5000.
* -dsn : Data Source Name for MySQL. default "root:@tcp(127.0.0.1:3306)/?charset=utf8"
  see also https://github.com/go-sql-driver/mysql#dsn-data-source-name

How to build
------------

    $ go install github.com/fujiwara/mysql-slave-healthcheck-agent

How to build (cross compile)
------------

Install gox.
<commit_msg>fix readme<commit_after>mysql-slave-healthcheck-agent
=============================

Description
------------

`mysql-slave-healthcheck-agent` is a HTTP daemon to show an information of "SHOW SLAVE STATUS" in JSON format.

This is useful for HAProxy's health check access instead of `option mysql-check`.

```
# haproxy.cfg
listen mysql
       bind     127.0.0.1:3306
       mode     tcp
       balance  roundrobin
       option   httpchk
       server   slave1 192.168.1.11:3306 check port 5000
       server   slave2 192.168.1.12:3306 check port 5000
```

Usage
------

```
$ mysql-slave-healthcheck-agent
2014/05/21 00:04:28 Listing port 5000
2014/05/21 00:04:28 dsn root:@tcp(127.0.0.1:3306)/?charset=utf8
```

```
$ curl localhost:5000 | jq .
{
  "Connect_Retry": 60,
  "Exec_Master_Log_Pos": 1048,
  "Last_Errno": 0,
  "Last_Error": "",
  "Master_Host": "db-master",
  "Master_Log_File": "mysql-bin.000006",
  "Master_Port": 3306,
  ...
  "Until_Log_File": "",
  "Until_Log_Pos": 0
}
```

* The query "SHOW SLAVE STATUS" was succeeded, return HTTP status 200 and JSON.
* If could not connect to the MySQL or the MySQL is not a slave, return HTTP status 500.

Options
-------

* -port : http listen port number. default 5000.
* -dsn : Data Source Name for MySQL. default "root:@tcp(127.0.0.1:3306)/?charset=utf8"
  see also https://github.com/go-sql-driver/mysql#dsn-data-source-name

How to build
------------

    $ go get github.com/fujiwara/mysql-slave-healthcheck-agent

How to build (cross compile)
------------

Install gox.

{'fraction_non_alphanumeric': 0.16812723141837066, 'fraction_numerical': 0.08568646543330087, 'mean_word_length': 2.9819121447028425, 'pattern_counts': {'":': 18, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 10, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5227920', 'n_tokens_mistral': 1265, 'n_tokens_neox': 1060, 'n_words': 293}