Fix PHP 7 32
This commit is contained in:
34
network.php
34
network.php
@@ -1,49 +1,63 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
function bitmask()
|
function bitmask()
|
||||||
{
|
{
|
||||||
$cores = intval(shell_exec("/usr/bin/grep -c ^processor /proc/cpuinfo"));
|
$cores = intval(shell_exec("/usr/bin/grep -c ^processor /proc/cpuinfo"));
|
||||||
$half_cores = ceil($cores / 2);
|
$half_cores = ceil($cores / 2);
|
||||||
$bitmask = 0;
|
$bitmask = 0;
|
||||||
|
|
||||||
for ($i = 0; $i < $half_cores; $i++) {
|
for ($i = 0; $i < $half_cores; $i++) {
|
||||||
$bitmask |= (1 << $i);
|
$bitmask |= (1 << $i);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $bitmask;
|
return $bitmask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function netinter()
|
function netinter()
|
||||||
{
|
{
|
||||||
$interface = trim(shell_exec("/usr/bin/ip route get 1 | grep -Po '(?<=dev )(\S+)'"));
|
$interface = trim(shell_exec("/usr/bin/ip route get 1 | grep -Po '(?<=dev )(\S+)'"));
|
||||||
return $interface;
|
return $interface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function insertnet()
|
function insertnet()
|
||||||
{
|
{
|
||||||
$netface = netinter();
|
$netface = netinter();
|
||||||
$checknet = trim(shell_exec("/usr/bin/cat /sys/class/net/$netface/queues/rx-0/rps_cpus"));
|
if ($netface === '') {
|
||||||
|
echo "Não foi possível detectar interface de rede.\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = "/sys/class/net/$netface/queues/rx-0/rps_cpus";
|
||||||
|
|
||||||
|
$checknet = trim(@shell_exec("/usr/bin/cat $path"));
|
||||||
$bit = bitmask();
|
$bit = bitmask();
|
||||||
if (str_contains($checknet, $bit)) {
|
|
||||||
|
if ((int)$checknet === (int)$bit) {
|
||||||
deletecone("netsta");
|
deletecone("netsta");
|
||||||
shell_exec("/usr/bin/echo \"0\" > /sys/class/net/$netface/queues/rx-0/rps_cpus");
|
shell_exec("/usr/bin/echo \"0\" > $path");
|
||||||
echo "Balanceamento Desativado! \n";
|
echo "Balanceamento Desativado! \n";
|
||||||
} else {
|
} else {
|
||||||
deletecone("netsta");
|
deletecone("netsta");
|
||||||
incone("netsta", "null", "null", "null", "null");
|
incone("netsta", "null", "null", "null", "null");
|
||||||
shell_exec("/usr/bin/echo \"$bit\" > /sys/class/net/$netface/queues/rx-0/rps_cpus");
|
shell_exec("/usr/bin/echo \"$bit\" > $path");
|
||||||
echo "Balanceamento ativado! \n";
|
echo "Balanceamento ativado! \n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function checknet()
|
function checknet()
|
||||||
{
|
{
|
||||||
$netface = netinter();
|
$netface = netinter();
|
||||||
$checknet = trim(shell_exec("/usr/bin/cat /sys/class/net/$netface/queues/rx-0/rps_cpus"));
|
if ($netface === '') {
|
||||||
|
echo "OFF";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = "/sys/class/net/$netface/queues/rx-0/rps_cpus";
|
||||||
|
|
||||||
|
$checknet = trim(@shell_exec("/usr/bin/cat $path"));
|
||||||
$bit = bitmask();
|
$bit = bitmask();
|
||||||
if (str_contains($checknet, $bit)) {
|
|
||||||
|
if ((int)$checknet === (int)$bit) {
|
||||||
echo "ON";
|
echo "ON";
|
||||||
} else {
|
} else {
|
||||||
echo "OFF";
|
echo "OFF";
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
31 Year Of the Tubular Dragon
|
32 Year Of the Tubular Dragon
|
||||||
Reference in New Issue
Block a user