- <?php
- function mksize($bytes) {
- if ($bytes < 1000 * 1024)
- if ($bytes < 1000 * 1048576)
- if ($bytes < 1000 * 1073741824)
- }
- // Operating system
- if ($temp) {
- "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 = "";
- $distro = $distro[1];
- } else do {
- break;
- }
- if (!$distro) {
- $distro = "Unknown";
- }
- $operatingsystem = "$distro ($osarray[0] $osarray[2])";
- } else {
- $operatingsystem = "(N/A)";
- }
- // Users and load information
- if ($reguptime) {
- $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 = "--";
- }
- // RAM usage
- $memtotal = $memtotal[1] * 1024;
- $memfree = $memfree[1] * 1024;
- $buffers = $buffers[1] * 1024;
- $cached = $cached[1] * 1024;
- $memused = mksize($memtotal - $memfree - $buffers - $cached);
- $memtotal = mksize($memtotal);
- echo("OS: $operatingsystem\n");
- echo("RAM Usage: $memused/$memtotal\n");
- echo("Uptime: $up\n");
- echo("Current Users: $users[0]\n");
- echo("Load:\n\tNow: $loadnow\n\tLast5 mins: $load5\n\tLast 15mins: $load15\n");
- ?>
PHP sysinfo script
Posted by Admin on Mon 31st May 2010 06:30
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.