Added check if server is "up"
Clicking the OS icon on the card will ping either the ipv4 or hostname if ipv4 empy/null. If reached then the icon will return green else it will turn red.
This commit is contained in:
parent
07ea6ac27d
commit
ec9a931ff6
|
@ -1290,6 +1290,18 @@ button.close {
|
||||||
color: #537cf7;
|
color: #537cf7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.os-icon {
|
||||||
|
color: #6f6b6b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.green-fa {
|
||||||
|
color: #51bf51;
|
||||||
|
}
|
||||||
|
|
||||||
|
.red-fa {
|
||||||
|
color: #bf5151;
|
||||||
|
}
|
||||||
|
|
||||||
.tab-pane {
|
.tab-pane {
|
||||||
margin-top: .8rem
|
margin-top: .8rem
|
||||||
}
|
}
|
||||||
|
|
19
assets/js/scripts.min.js
vendored
19
assets/js/scripts.min.js
vendored
|
@ -294,6 +294,25 @@ $(document).on("click", "#fillIpv4", function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(document).on("click", "#checkUpStatus", function () {
|
||||||
|
var host_name = $(this).attr('value');
|
||||||
|
var icon = $(this).children().first();
|
||||||
|
if (host_name) {
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: "check_up.php",
|
||||||
|
data: {"type": "check_up", "host": host_name},
|
||||||
|
success: function (result) {
|
||||||
|
if (result == 1) {
|
||||||
|
icon.addClass("green-fa");
|
||||||
|
} else {
|
||||||
|
icon.addClass("red-fa");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$('#virt').change(function(){
|
$('#virt').change(function(){
|
||||||
if($(this).val() == 'DEDI'){
|
if($(this).val() == 'DEDI'){
|
||||||
$('#dedi_cpu').prop("checked", true);
|
$('#dedi_cpu').prop("checked", true);
|
||||||
|
|
|
@ -38,6 +38,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||||
}
|
}
|
||||||
} elseif ($_GET['type'] == 'dns_search') {
|
} elseif ($_GET['type'] == 'dns_search') {
|
||||||
$idle->getIpForDomain($_GET['hostname'], $_GET['type']);
|
$idle->getIpForDomain($_GET['hostname'], $_GET['type']);
|
||||||
|
} elseif ($_GET['type'] == 'check_up') {
|
||||||
|
echo $idle->checkIsUp($_GET['host']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
|
16
class.php
16
class.php
|
@ -859,7 +859,7 @@ class idlers extends helperFunctions
|
||||||
protected function vpsCard(string $id)
|
protected function vpsCard(string $id)
|
||||||
{
|
{
|
||||||
$select = $this->dbConnect()->prepare("
|
$select = $this->dbConnect()->prepare("
|
||||||
SELECT servers.id,servers.hostname,servers.`cpu`,servers.cpu_freq,servers.ram,servers.ram_type,servers.`disk`,
|
SELECT servers.id,servers.hostname,servers.ipv4,servers.`cpu`,servers.cpu_freq,servers.ram,servers.ram_type,servers.`disk`,
|
||||||
servers.disk_type,servers.os,servers.virt,servers.was_special,locations.name as location,providers.name as provider,pricing.price,pricing.currency,pricing.term,pricing.next_dd
|
servers.disk_type,servers.os,servers.virt,servers.was_special,locations.name as location,providers.name as provider,pricing.price,pricing.currency,pricing.term,pricing.next_dd
|
||||||
FROM servers INNER JOIN locations on servers.location = locations.id INNER JOIN providers on servers.provider = providers.id
|
FROM servers INNER JOIN locations on servers.location = locations.id INNER JOIN providers on servers.provider = providers.id
|
||||||
INNER JOIN pricing on servers.id = pricing.server_id WHERE servers.id = ? LIMIT 1;");
|
INNER JOIN pricing on servers.id = pricing.server_id WHERE servers.id = ? LIMIT 1;");
|
||||||
|
@ -874,7 +874,8 @@ class idlers extends helperFunctions
|
||||||
$this->HTMLphrase('h4', 'hostname-header', $data['hostname']);
|
$this->HTMLphrase('h4', 'hostname-header', $data['hostname']);
|
||||||
$this->tagClose('div');
|
$this->tagClose('div');
|
||||||
$this->colOpen('col-12 col-xl-2 os-col');
|
$this->colOpen('col-12 col-xl-2 os-col');
|
||||||
$this->outputString($this->osIntToIcon($data['os']));
|
(empty($data['ipv4']) || is_null($data['ipv4'])) ? $host = $data['hostname'] : $host = $data['ipv4'];
|
||||||
|
$this->outputString('<a id="checkUpStatus" href="#" value="' . $host . '">' . $this->osIntToIcon($data['os']) . '</a>');
|
||||||
$this->tagClose('div', 3);
|
$this->tagClose('div', 3);
|
||||||
$this->tagOpen('div', 'card-body');
|
$this->tagOpen('div', 'card-body');
|
||||||
$this->HTMLphrase('h6', 'price', '$' . $data['price'] . ' ' . $data['currency'] . ' ' . $this->paymentTerm($data['term']));
|
$this->HTMLphrase('h6', 'price', '$' . $data['price'] . ' ' . $data['currency'] . ' ' . $this->paymentTerm($data['term']));
|
||||||
|
@ -2799,6 +2800,17 @@ class idlers extends helperFunctions
|
||||||
return "";//Doesnt exist/null/empty/invalid
|
return "";//Doesnt exist/null/empty/invalid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function checkIsUp(string $host, int $port = 80, int $wait_time = 1): int
|
||||||
|
{//Check if host/ip is "up"
|
||||||
|
if ($fp = @fsockopen($host, $port, $errCode, $errStr, $wait_time)) {
|
||||||
|
$result = 1;
|
||||||
|
} else {
|
||||||
|
$result = 0;
|
||||||
|
}
|
||||||
|
@fclose($fp);
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class itemInsert extends idlers
|
class itemInsert extends idlers
|
||||||
|
|
Loading…
Reference in New Issue
Block a user