Changeset 3250660
- Timestamp:
- 03/04/2025 07:53:38 PM (12 months ago)
- File:
-
- 1 edited
-
bitfire/tags/4.5.0/src/api.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
bitfire/tags/4.5.0/src/api.php
r3250658 r3250660 1699 1699 } 1700 1700 1701 $cpu = 1;1701 $cpu = $load = $mem_total = $mem_free = $cached = $swap = 1; 1702 1702 if (file_exists("/proc/cpuinfo") && is_readable("/proc/cpuinfo")) { 1703 1703 $raw = file_get_contents('/proc/cpuinfo'); … … 1707 1707 } 1708 1708 1709 $raw = file_get_contents('/proc/loadavg'); 1710 $load = explode(' ', $raw); 1711 1712 $raw = file_get_contents('/proc/meminfo'); 1713 1714 $mem_total = $mem_free = $cached = $swap = 0; 1715 if (preg_match('/MemTotal:\s+(\d+)/ims', $raw, $tmp)) { 1716 $mem_total = $tmp[1]; 1717 } 1718 if (preg_match('/MemFree:\s+(\d+)/ims', $raw, $tmp)) { 1719 $mem_free = $tmp[1]; 1720 } 1721 if (preg_match('/Cached:\s+(\d+)/ims', $raw, $tmp)) { 1722 $cached = $tmp[1]; 1723 } 1724 if (preg_match('/SwapTotal:\s+(\d+)/ims', $raw, $tmp)) { 1725 $swap1 = $tmp[1]; 1726 if (preg_match('/SwapFree:\s+(\d+)/ims', $raw, $tmp)) { 1727 $swap2 = $tmp[1]; 1728 $swap = intval($swap1) - intval($swap2); 1709 if (file_exists("/proc/loadavg") && is_readable("/proc/loadavg")) { 1710 $raw = file_get_contents('/proc/loadavg'); 1711 $load = explode(' ', $raw); 1712 } 1713 1714 if (file_exists("/proc/meminfo") && is_readable("/proc/meminfo")) { 1715 $raw = file_get_contents('/proc/meminfo'); 1716 1717 $mem_total = $mem_free = $cached = $swap = 0; 1718 if (preg_match('/MemTotal:\s+(\d+)/ims', $raw, $tmp)) { 1719 $mem_total = $tmp[1]; 1720 } 1721 if (preg_match('/MemFree:\s+(\d+)/ims', $raw, $tmp)) { 1722 $mem_free = $tmp[1]; 1723 } 1724 if (preg_match('/Cached:\s+(\d+)/ims', $raw, $tmp)) { 1725 $cached = $tmp[1]; 1726 } 1727 if (preg_match('/SwapTotal:\s+(\d+)/ims', $raw, $tmp)) { 1728 $swap1 = $tmp[1]; 1729 if (preg_match('/SwapFree:\s+(\d+)/ims', $raw, $tmp)) { 1730 $swap2 = $tmp[1]; 1731 $swap = intval($swap1) - intval($swap2); 1732 } 1729 1733 } 1730 1734 }
Note: See TracChangeset
for help on using the changeset viewer.