当前位置: 首页>>代码示例>>PHP>>正文


PHP COM::InstancesOf方法代码示例

本文整理汇总了PHP中COM::InstancesOf方法的典型用法代码示例。如果您正苦于以下问题:PHP COM::InstancesOf方法的具体用法?PHP COM::InstancesOf怎么用?PHP COM::InstancesOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在COM的用法示例。


在下文中一共展示了COM::InstancesOf方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getServerLoad

 /**
  * Get server load ... if linux, returns all three averages, if windows, returns
  * average load for all CPU cores
  *
  * @return string|null
  */
 public static function getServerLoad()
 {
     if (function_exists('sys_getloadavg')) {
         $a = sys_getloadavg();
         foreach ($a as $k => $v) {
             $a[$k] = round($v, 2);
         }
         return implode(', ', $a);
     } else {
         $os = strtolower(PHP_OS);
         if (strpos($os, 'win') === false) {
             if (@file_exists('/proc/loadavg') && @is_readable('/proc/loadavg')) {
                 $load = file_get_contents('/proc/loadavg');
                 $load = explode(' ', $load);
                 return implode(',', $load);
             } else {
                 if (function_exists('shell_exec')) {
                     $load = @shell_exec('uptime');
                     $load = split('load average' . (PHP_OS == 'Darwin' ? 's' : '') . ':', $load);
                     return implode(',', $load);
                     //return $load[count($load)-1];
                 } else {
                     return null;
                 }
             }
         } else {
             if (class_exists('COM')) {
                 $wmi = new COM("WinMgmts:\\\\.");
                 $cpus = $wmi->InstancesOf('Win32_Processor');
                 $cpuload = 0;
                 $i = 0;
                 while ($cpu = $cpus->Next()) {
                     $cpuload += $cpu->LoadPercentage;
                     $i++;
                 }
                 $cpuload = round($cpuload / $i, 2);
                 return $cpuload . '%';
             }
         }
     }
     return null;
 }
开发者ID:nkammah,项目名称:Crash-Analytics,代码行数:48,代码来源:Server.php

示例2: get_server_load

function get_server_load($windows = false) {
$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[0];
}
elseif(function_exists("shell_exec")) {
$load = explode(' ', `uptime`);
return $load[count($load)-1];
}
else {
return false;
}
}
elseif($windows) {
if(class_exists("COM")) {
$wmi = new COM("WinMgmts:\\\\.");
$cpus = $wmi->InstancesOf("Win32_Processor");

$cpuload = 0;
$i = 0;
while ($cpu = $cpus->Next()) {
$cpuload += $cpu->LoadPercentage;
$i++;
}

$cpuload = round($cpuload / $i, 2);
return "$cpuload%";
}
else {
return false;
}
}
}
开发者ID:h4ck3rm1k3,项目名称:vicidial-asterisk-gui,代码行数:36,代码来源:AST_timeonVDADall.php

示例3: strtolower

 function get_server_load($windows = 0)
 {
     $serverload = "n/a";
     if (!($serverload = getCache("pool_load"))) {
         $numberOfCores = 8;
         $avgLoad = 0;
         $os = strtolower(PHP_OS);
         if (strpos($os, "win") === false) {
             if (file_exists("http://" . $poolname . "/loadavg.html")) {
                 $load = file_get_contents("http://" . $poolname . "/loadavg.html");
                 $load = explode(' ', $load);
                 $avgLoad = $load[0];
             } elseif (function_exists("shell_exec")) {
                 $load = explode(' ', `uptime`);
                 $avgLoad = $load[count($load) - 1];
             }
             //This may need to be adjusted depending on your system. This is assuming a dual core setup.
             if ($avgLoad > 1.9 * $numberOfCores) {
                 $serverload = "critical";
             } else {
                 if ($avgLoad > 1.5 * $numberOfCores) {
                     $serverload = "high";
                 } else {
                     if ($avgLoad > 0.5 * $numberOfCores) {
                         $serverload = "mid";
                     } else {
                         if ($avgLoad > 0 * $numberOfCores) {
                             $serverload = "low";
                         }
                     }
                 }
             }
         } elseif ($windows) {
             if (class_exists("COM")) {
                 $wmi = new COM("WinMgmts:\\\\.");
                 $cpus = $wmi->InstancesOf("Win32_Processor");
                 $cpuload = 0;
                 $i = 0;
                 while ($cpu = $cpus->Next()) {
                     $cpuload += $cpu->LoadPercentage;
                     $i++;
                 }
                 $cpuload = round($cpuload / $i, 2);
                 $avgLoad = $cpuload;
             }
             if ($avgLoad > 90) {
                 $serverload = "critical";
             } else {
                 if ($avgLoad > 66) {
                     $serverload = "high";
                 } else {
                     if ($avgLoad > 33) {
                         $serverload = "mid";
                     } else {
                         if ($avgLoad > 0) {
                             $serverload = "low";
                         }
                     }
                 }
             }
         }
         if ($serverload != "n/a") {
         }
         setCache("pool_load", $serverload, 60);
     }
     return $serverload;
 }
开发者ID:neofutur,项目名称:simplecoin,代码行数:67,代码来源:stats.php

示例4: get_server_load

function get_server_load($windows = 0)
{
    if (class_exists("COM")) {
        $wmi = new COM("WinMgmts:\\\\.");
        $cpus = $wmi->InstancesOf("Win32_Processor");
        $i = 1;
        // Use the while loop on PHP 4 and foreach on PHP 5
        //while ($cpu = $cpus->Next()) {
        foreach ($cpus as $cpu) {
            $cpu_stats = 0;
            $cpu_stats += $cpu->LoadPercentage;
            $i++;
        }
        return round($cpu_stats / 2);
        // remove /2 for single processor systems
    }
}
开发者ID:UniversalAdministrator,项目名称:U-232-V4,代码行数:17,代码来源:user_functions.php

示例5: COM

<?php

$wmi = new COM("Winmgmts://");
$cpus = $wmi->InstancesOf("Win32_Processor");
$os = $wmi->InstancesOf("Win32_OperatingSystem");
foreach ($os as $os) {
    $os = "{$os->Caption} {$os->CSDVersion}";
}
$os = preg_replace("/(Microsoft|\\(R\\)|, \\w+ Edition)/", "", $os);
$os = str_replace("Service Pack ", "SP", $os);
$system = $wmi->InstancesOf("Win32_ComputerSystem");
$ram = $wmi->InstancesOf("Win32_LogicalMemoryConfiguration");
foreach ($ram as $ram) {
    $ramtotal = $ram->TotalPhysicalMemory * 1024;
}
$ram = $wmi->InstancesOf("Win32_PerfRawData_PerfOS_Memory");
foreach ($ram as $ram) {
}
$ramused = $ramtotal - $ram->AvailableBytes;
$ramused = mksize($ramused);
$ramtotal = mksize($ramtotal);
$uptime = $wmi->InstancesOf("Win32_PerfFormattedData_PerfOS_System");
foreach ($uptime as $uptime) {
}
$uptime = mkprettytime2($uptime->SystemUpTime);
foreach ($cpus as $cpu) {
    $cpus1[] = $cpu->LoadPercentage;
    $totalusage += $cpu->LoadPercentage;
}
$cpucount = count($cpus1);
$totalusage = round($totalusage / $cpucount, 2);
开发者ID:lavanoid,项目名称:TorrentTrader3,代码行数:31,代码来源:serverload5.php


注:本文中的COM::InstancesOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。