adding dbtest
This commit is contained in:
parent
e10a731562
commit
7d15fb8258
1 changed files with 28 additions and 0 deletions
28
php/dbtest.php
Normal file
28
php/dbtest.php
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// simple script to test if MySQL is reachable (healthcheck)
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
$user = 'healthcheck';
|
||||||
|
$pass = 'checkhealth';
|
||||||
|
$host = '172.22.150.133';
|
||||||
|
$database = 'test';
|
||||||
|
$query = "select count(*) from health";
|
||||||
|
|
||||||
|
$link = mysql_connect($host,$user,$pass);
|
||||||
|
if ($link) {
|
||||||
|
if (mysql_select_db($database,$link)) {
|
||||||
|
if (mysql_query($query,$link)) {
|
||||||
|
mysql_close($link);
|
||||||
|
print("OK\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$status = mysql_error();
|
||||||
|
if ($link) { mysql_close(); }
|
||||||
|
|
||||||
|
header("X-Health-Status: down",false,503);
|
||||||
|
print($status."\n");
|
||||||
|
|
||||||
|
?>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue