2017 © Pedro Peláez
 

project db-ping

Verify a Database server is responding.

image

ofbeaton/db-ping

Verify a Database server is responding.

  • Sunday, February 12, 2017
  • by ofbeaton
  • Repository
  • 1 Watchers
  • 4 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 6 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

db-ping

db-ping verifies a database server is responding by executing a query in a timed loop., (*1)

Latest Stable Version Minimum PHP Version Build Status, (*2)

Optionally includes slave replication checks., (*3)

PHP 5.6+ console command that uses PDO to provide the database drivers: - [x] MySQL - [x] ODBC (i.e. Microsoft SQL Server ...), (*4)

Updates

The project is considered in a usable state and feature complete., (*5)

This project is used in corporate applications. As such, the authors are unlikely to update it on a regular basis, but instead when the corporate applications that use it run into problems. You should expect updates in the 5-10yr range., (*6)

Issues and PRs will be monitored, and we will continue to work with the community to provide updates as they are contributed., (*7)

Installing via phar

Before proceeding, you need a working PHP 5.6+ installation., (*8)

The recommended way to install db-ping is by downloading the phar., (*9)

See Releases for downloads., (*10)

Next, run the phar from the command line:, (*11)

php db-ping.phar help

php db-ping.phar mysql --pass=mysecretpassword

php db-ping.phar ODBC -d OdbcName -u user -p password

Testing

Smoke test

If there is no mysql server running locally, pinging will give a connection refused error as below, (*12)

$ php bin/db-ping mysql
DB-PING 127.0.0.1:3306
from 127.0.0.1:3306: connection refused. delay=2000ms, exec=0ms, since success=0s, since fail=0s
from 127.0.0.1:3306: connection refused. delay=2000ms, exec=0ms, since success=0s, since fail=2.0006s

Against a real MySql server

Launch a temporary mysql server:, (*13)

docker run --name some-mysql --rm -e MYSQL_ROOT_PASSWORD=my-secret-pw -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -p 3306:3306 mysql, (*14)

Wait a few seconds while it initializes, then open another terminal and ping it:, (*15)

$ php bin/db-ping mysql -u user -p pass
DB-PING 127.0.0.1:3306
from 127.0.0.1:3306: connected. delay=2000ms, exec=0ms, since success=0s, since fail=0s
from 127.0.0.1:3306: check passed. delay=2000ms, exec=0ms, since success=0s, since fail=0s
from 127.0.0.1:3306: check passed. delay=2000ms, exec=0ms, since success=2.0022s, since fail=0s
from 127.0.0.1:3306: check passed. delay=2000ms, exec=0ms, since success=4.0028s, since fail=0s

To stop the dockerfile: docker stop some-mysql, (*16)

Against a real database server via ODBC

  1. Set up your php server for ODBC
  2. Add the server you'd like to test against to the /etc/odbc.ini file (on linux)
  3. Ping it
$ php bin/db-ping ODBC -d MarketflowAcc -u rou -p rou
DB-PING odbc:MarketflowAcc
from odbc:MarketflowAcc: connected. delay=2000ms, exec=0ms, since success=0s, since fail=0s
from odbc:MarketflowAcc: check passed. delay=2000ms, exec=0ms, since success=0s, since fail=0s
from odbc:MarketflowAcc: check passed. delay=2000ms, exec=0ms, since success=2.0058s, since fail=0s
from odbc:MarketflowAcc: check passed. delay=2000ms, exec=0ms, since success=4.0071s, since fail=0s
from odbc:MarketflowAcc: check passed. delay=2000ms, exec=0ms, since success=6.0083s, since fail=0s

The ping SQL query can be repeated more than once per ping with the repeat option. This is useful to make the ping test more stressful:, (*17)

$ php bin/db-ping ODBC -d MarketflowAcc -u rou -p rou --repeat 100

The output format can be controlled with the format option:, (*18)

$ php bin/db-ping ODBC -d MarketflowAcc -u rou -p rou --repeat 100 --format te
DB-PING odbc:MarketflowAcc
2017-01-11 14:55:35, 0
2017-01-11 14:55:35, 3
2017-01-11 14:55:37, 3
2017-01-11 14:55:39, 3
2017-01-11 14:55:41, 3

Also, et instead of te would shuffle the order, (*19)

Unit tests

Run vbin/phing check, (*20)

License

This software is distributed under the MIT License. Please see License file for more information., (*21)

The Versions

12/02 2017
05/08 2016

0.3.1

0.3.1.0 https://github.com/ofbeaton/db-ping

Verify a Database server is responding.

  Sources   Download

MIT

The Requires

 

The Development Requires

database mysql db ping

05/08 2016

0.3.0

0.3.0.0 https://github.com/ofbeaton/db-ping

Verify a Database server is responding.

  Sources   Download

MIT

The Requires

 

The Development Requires

database mysql db ping

05/08 2016

0.2.0

0.2.0.0 https://github.com/ofbeaton/db-ping

Verify a Database server is responding.

  Sources   Download

MIT

The Requires

 

The Development Requires

database mysql db ping

05/08 2016

0.1.2

0.1.2.0 https://github.com/ofbeaton/db-ping

Verify a Database server is responding.

  Sources   Download

MIT

The Requires

 

The Development Requires

database mysql db ping

05/08 2016

0.1.1

0.1.1.0 https://github.com/ofbeaton/db-ping

Verify a Database server is responding.

  Sources   Download

MIT

The Requires

 

The Development Requires

database mysql db ping

05/08 2016

0.1.0

0.1.0.0 https://github.com/ofbeaton/db-ping

Verify a Database server is responding.

  Sources   Download

MIT

The Requires

 

The Development Requires

database mysql db ping