本文整理汇总了PHP中get_server_load函数的典型用法代码示例。如果您正苦于以下问题:PHP get_server_load函数的具体用法?PHP get_server_load怎么用?PHP get_server_load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_server_load函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getStatusCode
function getStatusCode($url, $followRedirects = false)
{
global $http_codes;
$url = str_replace("+", "%2b", $url);
$url = str_replace(" ", "%20", $url);
$proxy = get_config("linkschecker", "proxyserver");
$proxyport = get_config("linkschecker", "proxyport");
$proxyusername = get_config("linkschecker", "proxyusername");
$proxypassword = get_config("linkschecker", "proxypassword");
$max_load = 0.4;
while (get_server_load() > $max_load) {
usleep(500000);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
if ($proxy != "") {
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
//curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_PROXYPORT, $proxyport);
if ($proxyusername != "") {
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyusername . ':' . $proxypassword);
}
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 Gecko/20100101 Firefox/4.0.1");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$result = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);
if ($error) {
return "<span class='code599'>" . preg_replace('/[^\\/\\-a-z\\s]/i', '', $error) . "</span>";
} else {
return "<span class='code" . $http_code . "'>" . $http_code . " " . $http_codes[$http_code] . "</span>";
}
}
开发者ID:smaranda,项目名称:linkschecker,代码行数:43,代码来源:locallib.php
示例2: check_load_status
function check_load_status($return = false)
{
global $_CORE_CONFIG, $_CLASS;
static $load_status = null;
if (!is_null($load_status)) {
return $load_status;
}
$load_status = 0;
if ($load = get_server_load()) {
if ($_CORE_CONFIG['server']['limit_load'] && $load > doubleval($_CORE_CONFIG['server']['limit_load']) && VIPERAL != 'Admin') {
if (VIPERAL == 'Admin' || isset($_CLASS['core_user']) && $_CLASS['core_user']->is_admin) {
return $load_status;
}
if ($return) {
return $load_status = true;
}
trigger_error('503:SITE_UNAVAILABLE');
}
}
return $load_status;
}
开发者ID:BackupTheBerlios,项目名称:viperals-svn,代码行数:21,代码来源:functions.php
示例3: while
$i = 0;
while ($cpu = $cpus->Next()) {
$cpuload += $cpu->LoadPercentage;
$i++;
}
$cpuload = round($cpuload / $i, 2);
return "$cpuload%";
}
else {
return false;
}
}
}
$load_ave = get_server_load(true);
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1';";
if ($DB) {echo "|$stmt|\n";}
if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
开发者ID:h4ck3rm1k3,项目名称:vicidial-asterisk-gui,代码行数:31,代码来源:AST_timeonVDADall.php
示例4: error
$db->delete_query("sessions", "ip='" . $db->escape_string($session->ipaddress) . "' OR uid='{$mybb->user['uid']}'");
} else {
$db->delete_query("sessions", "ip='" . $db->escape_string($session->ipaddress) . "'");
}
error($lang->error_banned);
}
$closed_bypass = array("member.php" => array("login", "do_login", "logout"), "captcha.php");
// If the board is closed, the user is not an administrator and they're not trying to login, show the board closed message
if ($mybb->settings['boardclosed'] == 1 && $mybb->usergroup['cancp'] != 1 && !in_array($current_page, $closed_bypass) && (!is_array($closed_bypass[$current_page]) || !in_array($mybb->input['action'], $closed_bypass[$current_page]))) {
// Show error
$lang->error_boardclosed .= "<blockquote>{$mybb->settings['boardclosed_reason']}</blockquote>";
error($lang->error_boardclosed);
exit;
}
// Load Limiting
if ($mybb->usergroup['cancp'] != 1 && $mybb->settings['load'] > 0 && ($load = get_server_load()) && $load != $lang->unknown && $load > $mybb->settings['load']) {
// User is not an administrator and the load limit is higher than the limit, show an error
error($lang->error_loadlimit);
}
// If there is a valid referrer in the URL, cookie it
if (!$mybb->user['uid'] && $mybb->settings['usereferrals'] == 1 && (isset($mybb->input['referrer']) || isset($mybb->input['referrername']))) {
if (isset($mybb->input['referrername'])) {
$condition = "username='" . $db->escape_string($mybb->input['referrername']) . "'";
} else {
$condition = "uid='" . intval($mybb->input['referrer']) . "'";
}
$query = $db->simple_select("users", "uid", $condition, array('limit' => 1));
$referrer = $db->fetch_array($query);
if ($referrer['uid']) {
my_setcookie("mybb[referrer]", $referrer['uid']);
}
开发者ID:benn0034,项目名称:SHIELDsite2.old,代码行数:31,代码来源:global.php
示例5: update
public function update()
{
return json_encode(array('load' => get_server_load(), 'time' => time()));
}
开发者ID:WattyRev,项目名称:games,代码行数:4,代码来源:data.php
示例6: foreach
$cpu_num = 0;
$load_total = 0;
foreach ($server as $cpu) {
$cpu_num++;
$load_total += $cpu->loadpercentage;
}
$load = round($load_total / $cpu_num, 2);
file_put_contents("./load.cache", $load);
}
} else {
$sys_load = sys_getloadavg();
$load = round($sys_load[0], 2);
}
return (int) $load;
}
$avg_load = get_server_load();
$load = str_pad(strstr($avg_load, ".") === false ? $avg_load . "." : $avg_load, 4, "0", STR_PAD_RIGHT);
echo "<load>{$load}</load>\n";
$uptime_array = array("days" => "N/A", "hours" => "N/A", "mins" => "N/A", "secs" => "N/A");
function format_uptime($uptime)
{
$days = floor($uptime / 60 / 60 / 24);
$hours = str_pad(floor($uptime / 60 / 60) % 24, 2, "0", STR_PAD_LEFT);
$mins = str_pad(floor($uptime / 60) % 60, 2, "0", STR_PAD_LEFT);
$secs = str_pad(floor($uptime % 60), 2, "0", STR_PAD_LEFT);
return array("days" => $days, "hours" => $hours, "mins" => $mins, "secs" => $secs);
}
if (stristr(PHP_OS, 'win') != false) {
$fileModTime = filemtime("./uptime.cache");
$uptime = 0;
$cache = @file_get_contents("./uptime.cache");
开发者ID:kadivar,项目名称:sentora-whmcs,代码行数:31,代码来源:status.php
示例7: debug_page
/**
* Prints a debug information page
*/
function debug_page()
{
global $db, $debug, $templates, $templatelist, $mybb, $maintimer, $globaltime, $ptimer, $parsetime, $lang;
$totaltime = $maintimer->totaltime;
$phptime = $maintimer->format($maintimer->totaltime - $db->query_time);
$query_time = $maintimer->format($db->query_time);
$percentphp = number_format($phptime / $maintimer->totaltime * 100, 2);
$percentsql = number_format($query_time / $maintimer->totaltime * 100, 2);
$phpversion = PHP_VERSION;
$serverload = get_server_load();
if ($mybb->settings['gzipoutput'] != 0) {
$gzipen = "Enabled";
} else {
$gzipen = "Disabled";
}
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">";
echo "<head>";
echo "<title>MyBB Debug Information</title>";
echo "</head>";
echo "<body>";
echo "<h1>MyBB Debug Information</h1>\n";
echo "<h2>Page Generation</h2>\n";
echo "<table bgcolor=\"#666666\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";
echo "<td bgcolor=\"#CCCCCC\" colspan=\"4\"><b><span style=\"size:2;\">Page Generation Statistics</span></b></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Page Generation Time:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$totaltime} seconds</font></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">No. DB Queries:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$db->query_count}</font></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">PHP Processing Time:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$phptime} seconds ({$percentphp}%)</font></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">DB Processing Time:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$query_time} seconds ({$percentsql}%)</font></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Extensions Used:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$mybb->config['database']['type']}, xml</font></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Global.php Processing Time:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$globaltime} seconds</font></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">PHP Version:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$phpversion}</font></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Server Load:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$serverload}</font></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">GZip Encoding Status:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$gzipen}</font></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">No. Templates Used:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">" . count($templates->cache) . " (" . intval(count(explode(",", $templatelist))) . " Cached / " . intval(count($templates->uncached_templates)) . " Manually Loaded)</font></td>\n";
echo "</tr>\n";
$memory_usage = get_memory_usage();
if (!$memory_usage) {
$memory_usage = $lang->unknown;
} else {
$memory_usage = get_friendly_size($memory_usage) . " ({$memory_usage} bytes)";
}
$memory_limit = @ini_get("memory_limit");
echo "<tr>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Memory Usage:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$memory_usage}</font></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Memory Limit:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$memory_limit}</font></td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<h2>Database Connections (" . count($db->connections) . " Total) </h2>\n";
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";
echo "<td style=\"background: #fff;\">" . implode("<br />", $db->connections) . "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<br />\n";
echo "<h2>Database Queries (" . $db->query_count . " Total) </h2>\n";
echo $db->explain;
echo "<h2>Template Statistics</h2>\n";
if (count($templates->cache) > 0) {
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";
echo "<td style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - " . count($templates->cache) . " Total</strong></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td style=\"background: #fff;\">" . implode(", ", array_keys($templates->cache)) . "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<br />\n";
}
if (count($templates->uncached_templates) > 0) {
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";
echo "<td style=\"background-color: #ccc;\"><strong>Templates Requiring Additional Calls (Not Cached at Startup) - " . count($templates->uncached_templates) . " Total</strong></td>\n";
echo "</tr>\n";
//.........这里部分代码省略.........
开发者ID:khanfusiion,项目名称:mybb,代码行数:101,代码来源:functions.php
示例8: sys_getloadavg
return 'unknown';
}
if (function_exists("sys_getloadavg")) {
$load = sys_getloadavg();
return $load[0];
}
if (@file_exists('/proc/loadavg')) {
$load = @file_get_contents('/proc/loadavg');
$serverload = explode(' ', $load);
$serverload[0] = round($serverload[0], 4);
if (!$serverload) {
$load = @exec('uptime');
$load = split('load averages?: ', $load);
$serverload = explode(',', $load[1]);
}
} else {
$load = @exec('uptime');
$load = split('load averages?: ', $load);
$serverload = explode(',', $load[1]);
}
$returnload = trim($serverload[0]);
if (!$returnload) {
$returnload = 'unknown';
}
return $returnload;
}
$load = get_server_load();
if (is_float($load) and $load > 80) {
header('HTTP/1.1 503 Too busy, try again later');
die('Server too busy. Please try again later.');
}
开发者ID:atarubi,项目名称:nuke-viet,代码行数:31,代码来源:getloadavg.php
示例9: action
/**
This is where you perform the action when the API is called, the parameter given is an instance of stdClass, this method should return an instance of stdClass.
*/
public function action()
{
global $mybb;
require_once MYBB_ROOT . "inc/functions.php";
return (object) get_server_load();
}
开发者ID:Shade-,项目名称:MyBB-RESTful-API-System,代码行数:9,代码来源:serverapi.class.php
示例10: mb_substr
if (mb_strripos($POSTS['filename'], ":") !== false) {
$POSTS['filename'] = mb_substr($POSTS['filename'], mb_strripos($POSTS['filename'], ":") - 1, mb_strlen($POSTS['filename']));
}
$POSTS['filename'] = mb_convert_encoding($POSTS['filename'], 'BIG5', 'UTF-8');
}
if (touch($POSTS['filename'])) {
echo "1";
} else {
echo "0";
}
exit;
break;
case 'getSystemStatus':
check_login(true);
//取得系統資料
$system_loading = get_server_load();
?>
系統負載:<?php
echo $system_loading;
?>
<br>
記憶體使用:<span id='mem_span_usage'>計算中...</span> / <span id='mem_span'>計算中...</span>
<script language="javascript">
$(document).ready(function(){
myAjax_async("?mode=getMemoryTotal","","#mem_span",function(){});
myAjax_async("?mode=getMemoryUsage","","#mem_span_usage",function(){});
});
</script>
<br>
硬碟狀態:<br>
<div style="margin-left:15px;">
开发者ID:shadowjohn,项目名称:mycode,代码行数:31,代码来源:mycode.php
示例11: strtolower
{
$os = strtolower(PHP_OS);
if (strpos($os, "win") === false) {
if (file_exists("/proc/loadavg")) {
$load = file_get_contents("/proc/loadavg");
$load = explode(' ', $load);
return $load;
} elseif (function_exists("shell_exec")) {
$load = explode(' ', `uptime`);
return $load;
} else {
return "";
}
}
}
list($one, $two, $three) = get_server_load();
//bar width
$width = 300;
//bar height
$height = 20;
$real_load = $one / 2;
$img_handle = imagecreate($width, $height);
$box_color = imagecolorallocate($img_handle, 255, 255, 255);
$bar_color = imagecolorallocate($img_handle, 0, 195, 255);
$text_color = imagecolorallocate($img_handle, 0, 0, 0);
$real_load = $real_load > 1 ? 1 : $real_load;
imagerectangle($img_handle, 0, 0, $width, $height, $box_color);
imagefilledrectangle($img_handle, 0, 0, (int) $width * $real_load, $height, $bar_color);
imagestring($img_handle, 5, $width / 2 - 15, $height / 2 - 7, $real_load * 100 . '%', $text_color);
header("Content-type: image/png");
imagepng($img_handle);
开发者ID:asadovkamran,项目名称:etap_backup,代码行数:31,代码来源:serverload.php
示例12: class_check
* Project Leaders: Mindless,putyn,kidvision.
**/
if (!defined('IN_INSTALLER09_ADMIN')) {
$HTMLOUT = '';
$HTMLOUT .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\r\n\t\t\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n\t\t<html xmlns='http://www.w3.org/1999/xhtml'>\r\n\t\t<head>\r\n\t\t<title>Error!</title>\r\n\t\t</head>\r\n\t\t<body>\r\n\t<div style='font-size:33px;color:white;background-color:red;text-align:center;'>Incorrect access<br />You cannot access this file directly.</div>\r\n\t</body></html>";
echo $HTMLOUT;
exit;
}
require_once INCL_DIR . 'user_functions.php';
require_once CLASS_DIR . 'class_check.php';
class_check(UC_SYSOP);
$lang = array_merge($lang, load_language('ad_index'));
$HTMLOUT = '';
//==Windows Server Load
$HTMLOUT .= "\r\n <div class='roundedCorners' style='text-align:left;width:80%;border:1px solid black;padding:5px;'>\r\n <div style='background:transparent;height:25px;'><span style='font-weight:bold;font-size:12pt;'>{$lang['index_serverload']}</span></div>\r\n <br />\r\n <table width='100%' border='1' cellspacing='0' cellpadding='1'>\r\n\t\t<tr><td align='center'>\r\n\t\t<table class='main' border='0' width='402'>\r\n <tr><td style='padding: 0px; background-image: url({$INSTALLER09['pic_base_url']}loadbarbg.gif); background-repeat: repeat-x'>";
$perc = get_server_load();
$percent = min(100, $perc);
if ($percent <= 70) {
$pic = "loadbargreen.gif";
} elseif ($percent <= 90) {
$pic = "loadbaryellow.gif";
} else {
$pic = "loadbarred.gif";
}
$width = $percent * 4;
$HTMLOUT .= "<img height='15' width='{$width}' src=\"{$INSTALLER09['pic_base_url']}{$pic}\" alt='{$percent}%' /><br />Currently {$percent}% CPU usage.<br /></td></tr></table></td></tr></table></div><br />";
//==End
/*
//==Server Load linux
$HTMLOUT .="
<div class='roundedCorners' style='text-align:left;width:80%;border:1px solid black;padding:5px;'>
开发者ID:CharlieHD,项目名称:U-232-V2,代码行数:31,代码来源:load.php
示例13: __destruct
public function __destruct()
{
global $start_timer, $load_timer, $db;
$load_time = $start_timer - $load_timer;
$end_timer = microtime(true);
$total_time = $end_timer - $start_timer;
$php_time = number_format($total_time - $db->query_time, 7);
$query_time = number_format($db->query_time, 7);
if ($total_time > 0) {
$percentphp = number_format($php_time / $total_time * 100, 2);
$percentsql = number_format($query_time / $total_time * 100, 2);
} else {
// if we've got a super fast script... all we can do is assume something
$percentphp = 0;
$percentsql = 0;
}
$phpversion = PHP_VERSION;
$serverload = get_server_load();
$current_memory_usage = get_memory_usage();
if ($current_memory_usage) {
$memory_usage = " / Memory Usage: " . get_friendly_size($current_memory_usage);
} else {
$memory_usage = '';
}
$this->trace0("Generated in {$total_time} seconds ({$percentphp}% PHP / {$percentsql}% MySQL) / Initialize Load Time: {$load_time} / SQL Queries: {$db->query_count}{$memory_usage} PHP version: {$phpversion} / Server Load: {$serverload}");
}
开发者ID:dgrp,项目名称:merge-system,代码行数:26,代码来源:class_debug.php
注:本文中的get_server_load函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论