Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
Server load
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Support

2021-11-05 21:11:39
hi can anyone help with this i get only part of server load (only OS and RAM). Thanx in advance

Current Load: NA
Load 5 mins ago: --
Load 15 mins ago: --
OS: Debian 10.11 (Linux 4.19.0-17-cloud-amd64)
RAM Used: 1.96 GB/7.61 GB
Uptime: --

2021-11-05 21:53:38
what hosting are you using? what are the server specs? what version php, stuff like that? Is it cloud based? Shared hosting?
TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
2021-11-05 22:08:16
its a VPS, i have instaled on it directadmin because i have on it more domains, 4 vCore,       8 GB,160 GB SSD NVMe, PHP version 7.2
2021-11-06 04:05:00
i remember having some issue here, i cant think of exactly what it was but i remember a few pieces not working and i spent some time playing with the code, this is my server block - you can delete the two serverload4/5.php from the backend folder if this code works

in serverload_block.php
after begin_block(T_("SERVER_LOAD"));  and  before //echo("<b>Current Users:</b> $users[0]<br>

replace with this
    if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") {
       // Get total physical memory (this is in bytes)
       $cmd = "wmic ComputerSystem get TotalPhysicalMemory";
       @exec($cmd, $outputTotalPhysicalMemory);
       // Get free physical memory (this is in kibibytes!)
       $cmd = "wmic OS get FreePhysicalMemory";
       @exec($cmd, $outputFreePhysicalMemory);
       if ($outputTotalPhysicalMemory && $outputFreePhysicalMemory) {
           // Find total value
           foreach ($outputTotalPhysicalMemory as $line) {
               if ($line && preg_match("/^[0-9]+\$/", $line)) {
                   $memoryTotal = $line;
                   break;
               }
           }
           // Find free value
           foreach ($outputFreePhysicalMemory as $line) {
               if ($line && preg_match("/^[0-9]+\$/", $line)) {
                   $memoryFree = $line;
                   $memoryFree *= 1024; // convert from kibibytes to bytes
                   break;
               }
           }
       }
       $memtotal = mksize($memoryFree);
       $memused = mksize($memoryTotal);

       $users = ["none"];
       $loadnow = "";
       $load5 = "";
       $load15 = "";
       $operatingsystem = "";
       $up = "";

   } else {
       // Users and load information
       $reguptime = exec("uptime");
       if ($reguptime) {
           if (preg_match("/up (.*), *(\d) (users?), .*: (.*), (.*), (.*)/", $reguptime, $uptime)) {
               $up = preg_replace("!(\d\d):(\d\d)!", '\1h\2m', $uptime[1]);
               $users[0] = $uptime[2];
               $users[1] = $uptime[3];
               $loadnow = $uptime[4];
               $load5 = $uptime[5];
               $load15 = $uptime[6];
           }
       } else {
           $up = "--";
           $users[0] = "NA";
           $users[1] = "--";
           $loadnow = "NA";
           $load5 = "--";
           $load15 = "--";
       }

       // Operating system
       $temp = file_get_contents("/proc/version");
       if ($temp) {
           $osarray = explode(" ", $temp);
           $distros = [
               "Gentoo", "/etc/gentoo-release",
               "Fedora Core", "/etc/fedora-release",
               "Slackware", "/etc/slackware-version",
               "Cobalt", "/etc/cobalt-release",
               "Debian", "/etc/debian_version",
               "Mandrake", "/etc/mandrake-release",
               "Mandrake", "/etc/mandrakelinux-release",
               "Yellow Dog", "/etc/yellowdog-release",
               "Red Hat", "/etc/redhat-release",
               "Arch Linux", "/etc/arch-release",
           ];

           $distro = "";
           if (file_exists("/etc/lsb-release")) {
               $lsb = file_get_contents("/etc/lsb-release");
               preg_match('!DISTRIB_DESCRIPTION="(.*)"!', $lsb, $distro);
               $distro = $distro[1];
           } else {
               do {
                   if (file_exists($distros[1])) {
                       $distro = file_get_contents($distros[1]);
                       $distro = "$distros[0] " . preg_replace("/[^0-9]*([0-9.]+)[^0-9.]{0,1}.*/", "\\1", $distro);
                       break;
                   }
                   array_shift($distros);
                   array_shift($distros);
               } while (count($distros));
           }

           if (!$distro) {
               $distro = "Unknown Distro";
           }

           $operatingsystem = "$distro ($osarray[0] $osarray[2])";
       } else {
           $operatingsystem = "(N/A)";
       }

       // RAM usage
       $meminfo = @file_get_contents("/proc/meminfo");
       preg_match("!^MemTotal:\s*(.*) kB!m", $meminfo, $memtotal);
       $memtotal = $memtotal[1] * 1024;
       preg_match("!^MemFree:\s*(.*) kB!m", $meminfo, $memfree);
       $memfree = $memfree[1] * 1024;
       preg_match("!^Buffers:\s*(.*) kB!m", $meminfo, $buffers);
       $buffers = $buffers[1] * 1024;
       preg_match("!^Cached:\s*(.*) kB!m", $meminfo, $cached);
       $cached = $cached[1] * 1024;

       $memused = mksize($memtotal - $memfree - $buffers - $cached);
       $memtotal = mksize($memtotal);
   }

2021-11-06 13:35:12
thx M-Jay it wasnt working but i managed to make other SERVERLOAD script, with some code from old one. fell free to try it. just replace  blocks/serverload_block.php

if you like it update GITHUB  :bigsmile


http://www.girlshare.ro/3770128224.5

Last edited by djlive on 2021-11-06 13:48:35
2021-11-06 17:37:16
thank you it works well  :bigsmile
2022-01-07 23:40:25
litlle update to serverload feel free to test it  
2022-01-07 23:40:46
litlle update to serverload feel free to test it  
2022-03-13 03:46:08
great ,, thanks
2022-03-13 11:25:39
litlle update

http://www.girlshare.ro/3770176502.4
Last edited by djlive on 2022-03-13 11:26:54
2025-04-04 08:52:10
i use dedi-server now
that my file
fix to me
php 7.4
serverload_block.php
<?php
//SERVER LOAD BLOCK
if (!$site_config["MEMBERSONLY"] || $CURUSER) {
   begin_block(T_("SERVER_LOAD"));
   ?>
   <table border="0" width="100%" cellspacing="0" cellpadding="0">
   <tr>
   <td align="center">
   <?php
   if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") {
       if (!class_exists("COM"))
           echo "COM support not available.";
   } else {
       // Load information
       $reguptime = exec("uptime");
       if ($reguptime) {
           if (preg_match("/up\s+(?:(\d+)\s+days?,\s+)?(?:(\d+):(\d+))?,/", $reguptime, $uptimeMatches)) {
               $days = isset($uptimeMatches[1]) ? $uptimeMatches[1] : 0;
               $hours = isset($uptimeMatches[2]) ? $uptimeMatches[2] : 0;
               $minutes = isset($uptimeMatches[3]) ? $uptimeMatches[3] : 0;

               // Build a user-friendly uptime string
               $up = [];
               if ($days > 0) $up[] = "$days day" . ($days > 1 ? "s" : "");
               if ($hours > 0) $up[] = "$hours hour" . ($hours > 1 ? "s" : "");
               if ($minutes > 0) $up[] = "$minutes minute" . ($minutes > 1 ? "s" : "");

               $up = implode(", ", $up);
           } else {
               $up = "--";
           }

           // Extract load averages and user count
           if (preg_match("/(\d+) (users?), .*: (.*), (.*), (.*)/", $reguptime, $loadMatches)) {
               $users[0] = $loadMatches[1];
               $users[1] = $loadMatches[2];
               $loadnow = $loadMatches[3];
               $load5 = $loadMatches[4];
               $load15 = $loadMatches[5];
           } else {
               $users[0] = "NA";
               $users[1] = "--";
               $loadnow = "NA";
               $load5 = "--";
               $load15 = "--";
           }
       } else {
           $up = "--";
           $users[0] = "NA";
           $users[1] = "--";
           $loadnow = "NA";
           $load5 = "--";
           $load15 = "--";
       }

       // Operating system
       $operatingsystem = defined('PHP_OS_FAMILY') ? PHP_OS_FAMILY : php_uname('s') . " " . php_uname('r');

       // RAM usage
       $meminfo = file_get_contents("/proc/meminfo");
       preg_match("/^MemTotal:\s*(?P<total>\d+) kB.*^MemFree:\s*(?P<free>\d+) kB.*^Buffers:\s*(?P<buffers>\d+) kB.*^Cached:\s*(?P<cached>\d+) kB/ms", $meminfo, $matches);

       $memtotal = $matches['total'] * 1024;
       $memfree = $matches['free'] * 1024;
       $buffers = $matches['buffers'] * 1024;
       $cached = $matches['cached'] * 1024;

       $memused = mksize($memtotal - $memfree - $buffers - $cached);
       $memtotal = mksize($memtotal);
       $phpload = round(memory_get_usage() / 1000000, 2);

       // Disk space
       $fs = "/";
       $disk_total_space = disk_total_space($fs);
       $disk_free_space = disk_free_space($fs);
       $disk_used_space = $disk_total_space - $disk_free_space;

       echo ("<b>Total HDD: </b>" . round($disk_total_space / (1024 * 1024 * 1024)) . " GB<br />");
       echo ("<b>HDD Used: </b>" . round($disk_used_space / (1024 * 1024 * 1024)) . " GB<br />");
       echo ("<b>Percent Used: </b>" . round(($disk_used_space / $disk_total_space) * 100) . " %<br /><hr />");

       // CPU Information
       $cpuinfo = file_get_contents('/proc/cpuinfo');
       preg_match_all('/^model name\s+\:\s+(.*)$/m', $cpuinfo, $modelMatches);
       $totalCores = count($modelMatches[1]);
       $cpuModel = $modelMatches[1][0] ?? "Unknown";

       echo "<b>CPU:</b> $cpuModel<br />";
       echo "<b>Total Cores:</b> $totalCores<br /><hr />";

       // Display server stats
       echo("<b>" . T_("CURRENT_LOAD") . ":</b> $loadnow<br />");
       echo("<b>" . T_("LOAD_5_MINS") . ":</b> $load5<br />");
       echo("<b>" . T_("LOAD_15_MINS") . ":</b> $load15<br /><hr />");
       echo("<b>PHP Load:</b> $phpload MB<br />");
       echo("<b>OS:</b> $operatingsystem<br />");
       echo("<b>" . T_("RAM_USED") . ":</b> $memused of $memtotal<br />");
       echo("<b>" . T_("UPTIME") . ":</b> $up<br />");
   }
   ?>
   </td>
   </tr>
   </table>
   <?php
   end_block();
}
?>
Last edited by leech24 on 2025-04-17 01:33:21
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 9
  • Members: 0
  • Guests online: 9
  • Comments: 3
  • Messages: 1,728