'Model B Revision 1.0', '0003' => 'Model B Revision 1.0 + ECN0001', '0004' => 'Model B Revision 2.0 (256 MB)', '0005' => 'Model B Revision 2.0 (256 MB)', '0006' => 'Model B Revision 2.0 (256 MB)', '0007' => 'Model A', '0008' => 'Model A', '0009' => 'Model A', '000d' => 'Model B Revision 2.0 (512 MB)', '000e' => 'Model B Revision 2.0 (512 MB)', '000f' => 'Model B Revision 2.0 (512 MB)', '0010' => 'Model B+', '0013' => 'Model B+', '0011' => 'Compute Module', '0012' => 'Model A+', 'a01041' => 'a01041', 'a21041' => 'a21041', '900092' => 'PiZero 1.2', '900093' => 'PiZero 1.3', '9000c1' => 'PiZero W', 'a02082' => 'Pi 3 Model B', 'a22082' => 'Pi 3 Model B' ); exec('cat /proc/cpuinfo', $cpuinfo_array); $rev = trim(array_pop(explode(':',array_pop(preg_grep("/^Revision/", $cpuinfo_array))))); if (array_key_exists($rev, $revisions)) { return $revisions[$rev]; } else { return 'Unknown Pi'; } } /** * * */ function DisplaySystem(){ $status = new StatusMessages(); if( isset($_POST['SaveLanguage']) ) { if (CSRFValidate()) { if(isset($_POST['locale'])) { $_SESSION['locale'] = $_POST['locale']; $status->addMessage('Language setting saved', 'success'); } } else { error_log('CSRF violation'); } } // define locales $arrLocales = array( 'en_GB.UTF-8' => 'English', 'de_DE.UTF-8' => 'Deutsch', 'fr_FR.UTF-8' => 'Français', 'it_IT.UTF-8' => 'Italiano', 'pt_BR.UTF-8' => 'Português', 'sv_SE.UTF-8' => 'Svenska' ); // hostname exec("hostname -f", $hostarray); $hostname = $hostarray[0]; // uptime $uparray = explode(" ", exec("cat /proc/uptime")); $seconds = round($uparray[0], 0); $minutes = $seconds / 60; $hours = $minutes / 60; $days = floor($hours / 24); $hours = floor($hours - ($days * 24)); $minutes = floor($minutes - ($days * 24 * 60) - ($hours * 60)); $uptime= ''; if ($days != 0) { $uptime .= $days . ' day' . (($days > 1)? 's ':' '); } if ($hours != 0) { $uptime .= $hours . ' hour' . (($hours > 1)? 's ':' '); } if ($minutes != 0) { $uptime .= $minutes . ' minute' . (($minutes > 1)? 's ':' '); } // mem used $memused_status = "primary"; exec("free -m | awk '/Mem:/ { total=$2 ; used=$3 } END { print used/total*100}'", $memarray); $memused = floor($memarray[0]); if ($memused > 90) { $memused_status = "danger"; } elseif ($memused > 75) { $memused_status = "warning"; } elseif ($memused > 0) { $memused_status = "success"; } // cpu load $cores = exec("grep -c ^processor /proc/cpuinfo"); $loadavg = exec("awk '{print $1}' /proc/loadavg"); $cpuload = floor(($loadavg * 100) / $cores); if ($cpuload > 90) { $cpuload_status = "danger"; } elseif ($cpuload > 75) { $cpuload_status = "warning"; } elseif ($cpuload > 0) { $cpuload_status = "success"; } ?>
showMessages(); ?>