mirror of
https://github.com/cytopia/devilbox.git
synced 2024-12-21 21:57:47 +00:00
REL-0.9 Adding information about DNS status
This commit is contained in:
parent
dfa8ff99dc
commit
f7893ead14
@ -12,6 +12,7 @@
|
||||
* Load required files
|
||||
*************************************************************/
|
||||
loadFile('Php');
|
||||
loadFile('Dns');
|
||||
loadFile('Httpd');
|
||||
loadFile('Mysql');
|
||||
loadFile('Pgsql');
|
||||
@ -23,6 +24,7 @@ loadFile('Memcd');
|
||||
* Get availability
|
||||
*************************************************************/
|
||||
$avail_php = \devilbox\Php::isAvailable($GLOBALS['PHP_HOST_NAME']);
|
||||
$avail_dns = \devilbox\Dns::isAvailable($GLOBALS['DNS_HOST_NAME']);
|
||||
$avail_httpd = \devilbox\Httpd::isAvailable($GLOBALS['HTTPD_HOST_NAME']);
|
||||
$avail_mysql = \devilbox\Mysql::isAvailable($GLOBALS['MYSQL_HOST_NAME']);
|
||||
$avail_pgsql = \devilbox\Pgsql::isAvailable($GLOBALS['PGSQL_HOST_NAME']);
|
||||
@ -30,7 +32,6 @@ $avail_redis = \devilbox\Redis::isAvailable($GLOBALS['REDIS_HOST_NAME']);
|
||||
$avail_memcd = \devilbox\Memcd::isAvailable($GLOBALS['MEMCD_HOST_NAME']);
|
||||
|
||||
|
||||
|
||||
/*************************************************************
|
||||
* Test Connectivity
|
||||
*************************************************************/
|
||||
@ -161,6 +162,23 @@ if ($avail_memcd) {
|
||||
);
|
||||
}
|
||||
|
||||
// ---- BIND ----
|
||||
if ($avail_dns) {
|
||||
$host = $GLOBALS['DNS_HOST_NAME'];
|
||||
$succ = \devilbox\Dns::testConnection($error, $host);
|
||||
$connection['Bind'][$host] = array(
|
||||
'error' => $error,
|
||||
'host' => $host,
|
||||
'succ' => $succ
|
||||
);
|
||||
$host = \devilbox\Dns::getIpAddress($GLOBALS['DNS_HOST_NAME']);
|
||||
$succ = \devilbox\Dns::testConnection($error, $host);
|
||||
$connection['Bind'][$host] = array(
|
||||
'error' => $error,
|
||||
'host' => $host,
|
||||
'succ' => $succ
|
||||
);
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
* Test Health
|
||||
@ -195,6 +213,12 @@ $HEALTH_PERCENT = 100 - ceil(100 * $HEALTH_FAILS / $HEALTH_TOTAL);
|
||||
|
||||
function getCirle($name) {
|
||||
switch ($name) {
|
||||
case 'dns':
|
||||
$class = 'bg-info';
|
||||
$version = loadClass('Dns')->getVersion();
|
||||
$available = $GLOBALS['avail_'.$name];
|
||||
$name = loadClass('Dns')->getName();
|
||||
break;
|
||||
case 'php':
|
||||
$class = 'bg-info';
|
||||
$version = loadClass('Php')->getVersion();
|
||||
@ -207,12 +231,6 @@ function getCirle($name) {
|
||||
$available = $GLOBALS['avail_'.$name];
|
||||
$name = loadClass('Httpd')->getName();
|
||||
break;
|
||||
case 'httpd':
|
||||
$class = 'bg-info';
|
||||
$version = loadClass('Httpd')->getVersion();
|
||||
$available = $GLOBALS['avail_'.$name];
|
||||
$name = loadClass('Httpd')->getName();
|
||||
break;
|
||||
case 'mysql':
|
||||
$class = 'bg-warning';
|
||||
$version = loadClass('Mysql')->getVersion();
|
||||
@ -328,15 +346,15 @@ function getCirle($name) {
|
||||
<div class="dash-box-head"><i class="fa fa-cog" aria-hidden="true"></i> Base Stack</div>
|
||||
<div class="dash-box-body">
|
||||
<div class="row">
|
||||
<div class="col-xl-4 col-lg-6 col-md-6 col-sm-12 col-xs-4" style="margin-bottom:15px;">
|
||||
<?php echo getCirle('dns'); ?>
|
||||
</div>
|
||||
<div class="col-xl-4 col-lg-6 col-md-6 col-sm-12 col-xs-4" style="margin-bottom:15px;">
|
||||
<?php echo getCirle('php'); ?>
|
||||
</div>
|
||||
<div class="col-xl-4 col-lg-6 col-md-6 col-sm-12 col-xs-4" style="margin-bottom:15px;">
|
||||
<?php echo getCirle('httpd'); ?>
|
||||
</div>
|
||||
<div class="col-xl-4 col-lg-6 col-md-6 col-sm-12 col-xs-4" style="margin-bottom:15px;">
|
||||
<?php echo getCirle('dns'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -390,6 +408,7 @@ function getCirle($name) {
|
||||
<div class="dash-box-head"><i class="fa fa-info-circle" aria-hidden="true"></i> PHP Container Setup</div>
|
||||
<div class="dash-box-body">
|
||||
<table class="table table-striped table-hover table-bordered table-sm font-small">
|
||||
<p><small>You can also enter the php container and work from inside. The following is available inside the container:</small></p>
|
||||
<thead class="thead-inverse">
|
||||
<tr>
|
||||
<th colspan="2">Settings</th>
|
||||
@ -410,23 +429,45 @@ function getCirle($name) {
|
||||
</tr>
|
||||
<tr>
|
||||
<th>DNS</th>
|
||||
<td>Enabled</td>
|
||||
<td><?php if ($avail_dns): ?>Enabled<?php else: ?><span class="text-danger">Offline</span><?php endif;?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Postfix</th>
|
||||
<td>Enabled</td>
|
||||
<td><?php echo $Docker->getEnv('ENABLE_MAIL') ? 'Enabled' : '<span class="bg-danger">No</span> Disabled';?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Xdebug</th>
|
||||
<td>Enabled</td>
|
||||
<td>
|
||||
<?php $Xdebug = ($Docker->getEnv('PHP_XDEBUG_ENABLE') == 0) ? '' : $Docker->getEnv('PHP_XDEBUG_ENABLE'); ?>
|
||||
<?php if ($Xdebug == $Docker->PHP_config('xdebug.remote_enable')): ?>
|
||||
<?php echo $Docker->PHP_config('xdebug.remote_enable') == 1 ? 'Yes' : 'No'; ?>
|
||||
<?php else: ?>
|
||||
<?php echo '<span class="text-danger">not installed</span>.env file setting differs from custom php .ini file</span><br/>'; ?>
|
||||
<?php echo 'Effective setting: '.$Docker->PHP_config('xdebug.remote_enable'); ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Xdebug Remote</th>
|
||||
<td>192.168.0.215</td>
|
||||
<td>
|
||||
<?php if ($Docker->getEnv('PHP_XDEBUG_REMOTE_HOST') == $Docker->PHP_config('xdebug.remote_host')): ?>
|
||||
<?php echo $Docker->PHP_config('xdebug.remote_host'); ?>
|
||||
<?php else: ?>
|
||||
<?php echo '<span class="text-danger">not installed</span>.env file setting differs from custom php .ini file</span><br/>'; ?>
|
||||
<?php echo 'Effective setting: '.$Docker->PHP_config('xdebug.remote_host'); ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Xdebug Port</th>
|
||||
<td>9000</td>
|
||||
<td>
|
||||
<?php if ($Docker->getEnv('PHP_XDEBUG_REMOTE_PORT') == $Docker->PHP_config('xdebug.remote_port')): ?>
|
||||
<?php echo $Docker->PHP_config('xdebug.remote_port'); ?>
|
||||
<?php else: ?>
|
||||
<?php echo '<span class="text-danger">not installed</span>.env file setting differs from custom php .ini file</span><br/>'; ?>
|
||||
<?php echo 'Effective setting: '.$Docker->PHP_config('xdebug.remote_port'); ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -484,7 +525,7 @@ function getCirle($name) {
|
||||
<tbody>
|
||||
<?php foreach ($connection as $name => $docker): ?>
|
||||
<tr>
|
||||
<th rowspan="3" class="align-middle"><?php echo $name; ?> connect</th>
|
||||
<th rowspan="<?php echo count($docker);?>" class="align-middle"><?php echo $name; ?> connect</th>
|
||||
<?php $i=1; foreach ($docker as $conn): ?>
|
||||
|
||||
<?php if ($conn['succ']): ?>
|
||||
@ -575,6 +616,13 @@ function getCirle($name) {
|
||||
<td><?php echo \devilbox\Memcd::getIpAddress($GLOBALS['MEMCD_HOST_NAME']); ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if ($avail_dns): ?>
|
||||
<tr>
|
||||
<th>bind</th>
|
||||
<td><?php echo $GLOBALS['DNS_HOST_NAME']; ?></td>
|
||||
<td><?php echo \devilbox\Dns::getIpAddress($GLOBALS['DNS_HOST_NAME']); ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -636,6 +684,16 @@ function getCirle($name) {
|
||||
<td>11211</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if ($avail_dns): ?>
|
||||
<tr>
|
||||
<th>bind</th>
|
||||
<td>
|
||||
<?php echo loadClass('Docker')->getEnv('LOCAL_LISTEN_ADDR').loadClass('Docker')->getEnv('HOST_PORT_BIND');?>/tcp<br/>
|
||||
<?php echo loadClass('Docker')->getEnv('LOCAL_LISTEN_ADDR').loadClass('Docker')->getEnv('HOST_PORT_BIND');?>/udp
|
||||
</td>
|
||||
<td>53/tcp<br/>53/udp</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -739,6 +797,13 @@ function getCirle($name) {
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if ($avail_dns): ?>
|
||||
<tr>
|
||||
<th>bind</th>
|
||||
<td>-</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -800,6 +865,13 @@ function getCirle($name) {
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if ($avail_dns): ?>
|
||||
<tr>
|
||||
<th>bind</th>
|
||||
<td>-</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -861,6 +933,13 @@ function getCirle($name) {
|
||||
<td>/var/log/memcached</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if ($avail_dns): ?>
|
||||
<tr>
|
||||
<th>bind</th>
|
||||
<td>-</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
127
.devilbox/www/include/lib/Dns.php
Normal file
127
.devilbox/www/include/lib/Dns.php
Normal file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
namespace devilbox;
|
||||
|
||||
/**
|
||||
* @requires devilbox::Logger
|
||||
*/
|
||||
class Dns extends _Base implements _iBase
|
||||
{
|
||||
|
||||
/*********************************************************************************
|
||||
*
|
||||
* Statics
|
||||
*
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* Dns instance
|
||||
* @var Dns|null
|
||||
*/
|
||||
protected static $instance = null;
|
||||
|
||||
private static $_available = null;
|
||||
|
||||
/**
|
||||
* Singleton Instance getter.
|
||||
*
|
||||
* @param string $user Username
|
||||
* @param string $pass Password
|
||||
* @param string $host Host
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getInstance($host = null, $user = null, $pass = null)
|
||||
{
|
||||
if (!isset(static::$instance)) {
|
||||
static::$instance = new static();
|
||||
}
|
||||
return static::$instance;
|
||||
}
|
||||
/**
|
||||
* @overwrite
|
||||
* @param string $hostname [description]
|
||||
* @return boolean [description]
|
||||
*/
|
||||
public static function isAvailable($hostname)
|
||||
{
|
||||
if (self::$_available === null) {
|
||||
|
||||
$output = '';
|
||||
$exit_code = -1;
|
||||
$cmd = 'dig +time=1 +tries=1 @172.16.238.100 version.bind chaos TXT';
|
||||
exec($cmd, $output, $exit_code);
|
||||
|
||||
if ($exit_code != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
self::$_available[$hostname] = ($exit_code != 0) ? false : true;
|
||||
|
||||
}
|
||||
return self::$_available;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Connect to Httpd
|
||||
*
|
||||
* @param string $err Reference to error message
|
||||
* @param string $host Redis hostname
|
||||
* @return boolean
|
||||
*/
|
||||
public static function testConnection(&$err, $host, $user = '', $pass = '')
|
||||
{
|
||||
return self::isAvailable($host);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*********************************************************************************
|
||||
*
|
||||
* Construct/Destructor
|
||||
*
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* Use singleton getInstance() instead.
|
||||
*
|
||||
* @param string $user Username
|
||||
* @param string $pass Password
|
||||
* @param string $host Host
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************************
|
||||
*
|
||||
* Interface required functions
|
||||
*
|
||||
*********************************************************************************/
|
||||
|
||||
public function getName($default = 'Bind')
|
||||
{
|
||||
return $default;
|
||||
}
|
||||
|
||||
public function getVersion()
|
||||
{
|
||||
$output = '';
|
||||
$exit_code = -1;
|
||||
$cmd = 'dig +time=1 +tries=1 @172.16.238.100 version.bind chaos TXT | grep -iE "^version\.bind.*TXT"';
|
||||
|
||||
exec($cmd, $output, $exit_code);
|
||||
|
||||
$version = $this->egrep('/"[0-9.-]+.*"/', isset($output[0]) ? $output[0] : '');
|
||||
$version = $this->egrep('/[0-9.-]+/', $version);
|
||||
$version = $version ? $version : '';
|
||||
return $version;
|
||||
}
|
||||
}
|
@ -58,8 +58,6 @@ class Httpd extends _Base implements _iBase
|
||||
$err = false;
|
||||
|
||||
// Silence errors and try to connect
|
||||
//error_reporting(0);
|
||||
|
||||
$url = 'http://'.$host.'/not-existing-page-which-returns-404.php';
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_NOBODY, true);
|
||||
@ -67,7 +65,6 @@ class Httpd extends _Base implements _iBase
|
||||
curl_exec($ch);
|
||||
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
error_reporting(-1);
|
||||
|
||||
if ($http_code == 0) {
|
||||
$err = 'Failed to connect to Httpd host on '.$host;
|
||||
|
@ -118,16 +118,18 @@ class Memcd extends _Base implements _iBase
|
||||
$memcd = new \Memcached('_devilbox');
|
||||
$list = $memcd->getServerList();
|
||||
|
||||
// if (!empty($list)) {
|
||||
// $memcd->resetServerList();
|
||||
// }
|
||||
if (empty($list)) {
|
||||
//$memcd->setOption(\Memcached::OPT_RECV_TIMEOUT, 1000);
|
||||
//$memcd->setOption(\Memcached::OPT_SEND_TIMEOUT, 1000);
|
||||
//$memcd->setOption(\Memcached::OPT_RECV_TIMEOUT, 100);
|
||||
//$memcd->setOption(\Memcached::OPT_SEND_TIMEOUT, 100);
|
||||
$memcd->setOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
|
||||
$memcd->setOption(\Memcached::OPT_BINARY_PROTOCOL, false);
|
||||
//$memcd->setOption(\Memcached::OPT_SERVER_FAILURE_LIMIT, 50);
|
||||
//$memcd->setOption(\Memcached::OPT_CONNECT_TIMEOUT, 500);
|
||||
//$memcd->setOption(\Memcached::OPT_RETRY_TIMEOUT, 300);
|
||||
//$memcd->setOption(\Memcached::OPT_CONNECT_TIMEOUT, 100);
|
||||
//$memcd->setOption(\Memcached::OPT_RETRY_TIMEOUT, 100);
|
||||
//$memcd->setOption(\Memcached::OPT_REMOVE_FAILED_SERVERS, true);
|
||||
|
||||
$memcd->addServer($host, 11211);
|
||||
}
|
||||
|
||||
@ -137,16 +139,16 @@ class Memcd extends _Base implements _iBase
|
||||
$memcd->quit();
|
||||
$err = 'Failed to connect to Memcached host on '.$host;
|
||||
}
|
||||
if (!isset($stats[$host.':11211']['pid'])) {
|
||||
else if (!isset($stats[$host.':11211']['pid'])) {
|
||||
$memcd->quit();
|
||||
$err = 'Failed to connect to Memcached host on '.$host;
|
||||
}
|
||||
if ($stats[$host.':11211']['pid'] < 1) {
|
||||
else if ($stats[$host.':11211']['pid'] < 1) {
|
||||
$memcd->quit();
|
||||
$err = 'Failed to connect to Memcached host on '.$host;
|
||||
}
|
||||
|
||||
if ($err === false) {
|
||||
else if ($err === false) {
|
||||
$memcd->set('devilbox-version', $GLOBALS['DEVILBOX_VERSION'].' ('.$GLOBALS['DEVILBOX_DATE'].')');
|
||||
$this->_memcached = $memcd;
|
||||
} else {
|
||||
|
@ -21,7 +21,7 @@ class _Base
|
||||
public static function isAvailable($hostname)
|
||||
{
|
||||
if (!isset(self::$_available[$hostname])) {
|
||||
$ip = gethostbyname($hostname);
|
||||
$ip = self::getIpAddress($hostname);
|
||||
self::$_available[$hostname] = ($ip == $hostname) ? false : true;
|
||||
}
|
||||
return self::$_available[$hostname];
|
||||
|
Loading…
Reference in New Issue
Block a user