<commit_before>mysql probe
==========
golang application that checks a mysql database and creates a series of HTTP responses stored as
flat text files that xinetd can return quickly for haproxy health checks.

## Installation

1. Install golang 1.3+
2. `go get github.com/haikulearning/mysql_probe`

### MySQL configuration
A user must be created with the following perms:
PROCESS
REPLICATION CLIENT
like such:
CREATE USER mysql_probe@'%' IDENTIFIED BY '<PASSWORD>';
GRANT PROCESS,REPLICATION CLIENT ON *.* TO mysql_probe@'%';


## Create package for distribution
Install fpm and run ./package https://github.com/jordansissel/fpm

## Configuration
Edit /etc/mysqlprobe/config.yaml

## Running
mysql_probe --help will provide available options.

## Checks
Checks can be named and run at configured intervals. Each check can 'roll up' multiple checks and
return an alarm if any of the checks fail.
### Global check options
These options apply to an entire instance of mysql_probe.
host: hostname to connect to
user: user to login to mysql with
pass: <PASSWORD> to <PASSWORD> with
interval: seconds to wait before rerunning this check. This is calculated as starting when the previous check has finished to prevent pileups.

### Individual check options
name: display name of this check. must be unique.
type: required check name
result_files: a list of files to place this result as http responses in text

### replication_delay
Checks that replication is not delayed over configured seconds.
#### Options
max_delay: in seconds, if replication delayed > this number, consider check failed.

### connection_count
Count the existing connections to this server and fail if connection count is too great.
#### Options
max_connections: if there are more than this many connections to the server, fail

### assert
Run a query that returns a number and compare the results
#### Options
query: query to run
fail_if_gt: compare the numeric result of query and fail if the returned value is greater than this number.
fail_if_lt: compare the numeric result of query and fail if the returned value is less than this number.

## Development phases
1. Build checks with completely hardcoded configuration to check localhost.
2. Build configuration parser so this app does not need to be recompiled every time config changes.
3. Build rollup checks into configuration.

## Phase 1 hardcoded config
Check config.go for hardcoded values, host, username, password.
Run replcation_delay check and output to /var/run/mysql_probe/replcation_delay.http.txt
Run connection_count check and output to /var/run/mysql_probe/connection_count.http.txt

## Testing
A dockerfile is available in docker/test for spinning up an instance of this app.

## haproxy Configuration Example
TOOD: Add an example haproxy config using these checks to build a resilient failover configuration.

## xinetd Configuration Example
TODO: Add an example of using xinetd to return these http txt files as http requests.

## Copyright
Copyright 2014 <NAME><commit_msg>A big reorganization of the README<commit_after># mysql probe

A golang application that checks a mysql database and creates a series of HTTP responses stored as flat text files that xinetd can return quickly for haproxy health checks.

## Installation

1. Install golang 1.3+
2. `go get github.com/haikulearning/mysql_probe`

### MySQL configuration

Create a MySQL user with the following permissions:
* PROCESS
* REPLICATION CLIENT

For example:

````sql
CREATE USER mysql_probe@'%' IDENTIFIED BY 'As<PASSWORD>UvKK';
GRANT PROCESS,REPLICATION CLIENT ON *.* TO mysql_probe@'%';
````

## Running

mysql_probe --help will provide available options.

### Checks

For now, a default set of checks are hard-coded to run:
* "Connection Count Less Than X" with the following values:
  * 1, 10, 50, 100, 150, 200, 250, 300, 600, 1200, 2400
* "Replication Delay Less Than X" with the following values (in seconds):
  * 0, 10, 30, 60, 120, 300, 600, 1200, 2400

### haproxy Configuration Example
TOOD: Add an example haproxy config using these checks to build a resilient failover configuration.

### xinetd Configuration Example
TODO: Add an example of using xinetd to return these http txt files as http requests.

## Development

````bash
$ get go -u github.com/haikulearning/mysql_probe
$ cd $GOPATH/src/github.com/haikulearning/mysql_probe
$ make
````

## Testing
A dockerfile is available in docker/test for spinning up an instance of this app.

## Roadmap
1. Build checks with completely hardcoded configuration to check localhost.
2. Build configuration parser so this app does not need to be recompiled every time config changes.
3. Build rollup checks into configuration.

### Phase 1 hardcoded config
Check config.go for hardcoded values, host, username, password.
Run replcation_delay check and output to /var/run/mysql_probe/replcation_delay.http.txt
Run connection_count check and output to /var/run/mysql_probe/connection_count.http.txt

## Copyright

Copyright 2014 <NAME>
{'fraction_non_alphanumeric': 0.06686686686686687, 'fraction_numerical': 0.015815815815815815, 'mean_word_length': 4.775722543352601, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6826317', 'n_tokens_mistral': 1443, 'n_tokens_neox': 1304, 'n_words': 674}