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


PHP COM::execquery方法代码示例

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


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

示例1: get_server_load

function get_server_load()
{
    if (stristr(PHP_OS, 'win') != false) {
        $fileModTime = filemtime("./load.cache");
        $cache = @file_get_contents("./load.cache");
        if (file_exists("./load.cache") && !empty($cache) && $fileModTime && time() - $fileModTime < 60) {
            $load = $cache;
        } else {
            $wmi = new COM("Winmgmts://");
            $server = $wmi->execquery("SELECT LoadPercentage FROM Win32_Processor");
            $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;
}
开发者ID:kadivar,项目名称:sentora-whmcs,代码行数:25,代码来源:status.php

示例2: getCpuFrequency

 /**
  * Get CPU frequency in MHz
  *
  * @return float
  * @throws phpRack_Exception If can't get cpu frequency
  * @see getBogoMips()
  * @see phpRack_Adapters_Cpu_Abstract::getCpuFrequency()
  */
 public function getCpuFrequency()
 {
     $wmi = new COM('Winmgmts://');
     $query = 'SELECT maxClockSpeed FROM CIM_Processor';
     // get CPUS-s data
     $cpus = $wmi->execquery($query);
     $maxClockSpeed = 0;
     /**
      * We must iterate through all CPU-s because $cpus is object
      * and we can't get single entry by $cpus[0]->maxClockSpeed
      */
     foreach ($cpus as $cpu) {
         $maxClockSpeed = max($maxClockSpeed, $cpu->maxClockSpeed);
     }
     /**
      * If returned $cpus set was empty(some error occured)
      *
      * We can't check it earlier with empty($cpus) or count($cpus)
      * because $cpus is object and doesn't implement countable
      * interface.
      */
     if (!$maxClockSpeed) {
         throw new phpRack_Exception("Unable to get maxClockSpeed using COM 'Winmgmts://' and '{$query}' query");
     }
     return floatval($maxClockSpeed);
 }
开发者ID:tpc2,项目名称:phprack,代码行数:34,代码来源:Windows.php

示例3: getAvgLoad

 protected function getAvgLoad()
 {
     $wmi = new \COM("Winmgmts://");
     $server = $wmi->execquery("SELECT LoadPercentage FROM Win32_Processor");
     $load_total = 0;
     foreach ($server as $cpu) {
         $load_total += $cpu->loadpercentage;
     }
     return (double) $load_total / 100;
 }
开发者ID:phaniso,项目名称:phpmonitor-api,代码行数:10,代码来源:System.php

示例4: GetNetworkLoad

function GetNetworkLoad()
{
    $wmi = new COM("Winmgmts://");
    $allnets = $wmi->execquery("Select BytesTotalPersec From Win32_PerfFormattedData_Tcpip_NetworkInterface where BytesTotalPersec>1");
    $totalbps = 0;
    foreach ($allnets as $network) {
        $bps = $network->BytesTotalPersec * 8;
        $totalbps += $bps;
    }
    return $totalbps;
}
开发者ID:Bitcoinsulting,项目名称:yiimp,代码行数:11,代码来源:system.php

示例5: smarty_function_serverload

/**
 * smarty_function_serverload
 */
function smarty_function_serverload($params)
{
    if (mb_strtoupper(mb_substr(PHP_OS, 0, 3)) === 'WIN') {
        $wmi = new COM("Winmgmts://");
        $cpus = $wmi->execquery("SELECT * FROM Win32_Processor");
        $cpuload = 0;
        $nr_cpus = 0;
        $loadcpu = '';
        foreach ($cpus as $cpu) {
            $cpuload += $cpu->loadpercentage;
            if ($nr_cpus > 0) {
                $loadcpu .= ' | ' . $cpuload . '%';
            } else {
                // first one
                $loadcpu .= $cpuload . '%';
            }
            $nr_cpus++;
        }
        $cpuload = $cpuload / $nr_cpus;
        if ($nr_cpus == 1) {
            echo '[ ' . $loadcpu . ' ]';
        } else {
            // list all processor loads and total load
            echo '[ ' . $loadcpu . ' ] [ ' . $cpuload . ' ]';
        }
    } else {
        // check if exists, else define
        if (false === function_exists('sys_getloadavg')) {
            function sys_getloadavg()
            {
                // get average server load in the last minute. Keep quiet cause virtual hosts can give perm denied
                if (is_readable('/proc/loadavg') and $load = file('/proc/loadavg')) {
                    $serverload = array();
                    list($serverload) = explode(' ', $load[0]);
                    return $serverload;
                }
            }
        }
        // get
        $cpuload = sys_getloadavg();
        if (empty($cpuload)) {
            $cpuload = array(0, 0, 0);
        }
        echo '1[' . $cpuload[0] . '] 5[' . $cpuload[1] . '] 15[' . $cpuload[2] . ']';
    }
}
开发者ID:Clansuite,项目名称:Clansuite,代码行数:49,代码来源:function.serverload.php

示例6: get_server_load

function get_server_load()
{
    if (stristr(PHP_OS, 'win')) {
        $wmi = new COM("Winmgmts://");
        $server = $wmi->execquery("SELECT LoadPercentage FROM Win32_Processor");
        $cpu_num = 0;
        $load_total = 0;
        foreach ($server as $cpu) {
            $cpu_num++;
            $load_total += $cpu->loadpercentage;
        }
        $load = round($load_total / $cpu_num);
    } else {
        $sys_load = sys_getloadavg();
        $load = $sys_load[0];
    }
    return (int) $load;
}
开发者ID:WattyRev,项目名称:games,代码行数:18,代码来源:data.php

示例7: getLoadAverage

 /**
  * Recuperer la charge systeme.
  * @return array Un tableau avec la charge systeme (il y a 1, 10 et 15 minutes sous Linux, seulement actuelle pour Windows).
  */
 public function getLoadAverage()
 {
     if (stristr(PHP_OS, 'win')) {
         $wmi = new COM('Winmgmts://');
         $server = $wmi->execquery('SELECT LoadPercentage FROM Win32_Processor');
         $cpu_num = 0;
         $load_total = 0;
         foreach ($server as $cpu) {
             $cpu_num++;
             $load_total += $cpu->loadpercentage;
         }
         $load = round($load_total / $cpu_num);
         $sys_load = array($load);
     } else {
         $sys_load = sys_getloadavg();
     }
     return $sys_load;
 }
开发者ID:Tiger66639,项目名称:symbiose-raspberrypi,代码行数:22,代码来源:ServerManager.class.php

示例8: getServerLoad

 public static function getServerLoad()
 {
     if (stristr(PHP_OS, 'win')) {
         $wmi = new COM('Winmgmts://');
         $cpus = $wmi->execquery('SELECT LoadPercentage FROM Win32_Processor');
         $cpu_num = 0;
         $load_total = 0;
         foreach ($cpus as $cpu) {
             ++$cpu_num;
             $load_total += $cpu->loadpercentage;
         }
         $load = round($load_total / $cpu_num);
     } else {
         $sys_load = sys_getloadavg();
         $load = $sys_load[0];
     }
     return (int) $load;
 }
开发者ID:ksst,项目名称:kf,代码行数:18,代码来源:Functions.php

示例9: COM

 function get_server_load()
 {
     if (strpos(strtolower(PHP_OS), 'win') !== false) {
         //if is a windows system
         $wmi = new COM("Winmgmts://");
         $server = $wmi->execquery("SELECT LoadPercentage FROM Win32_Processor");
         $cpu_num = 0;
         $load_total = 0;
         foreach ($server as $cpu) {
             $cpu_num++;
             $load_total += $cpu->loadpercentage;
         }
         $load = round($load_total / $cpu_num);
     } else {
         //if is a linux system
         $sys_load = sys_getloadavg();
         $load = $sys_load[0];
     }
     return (int) $load;
 }
开发者ID:vagkaefer,项目名称:overloaded,代码行数:20,代码来源:overloaded.class.php

示例10: elseif

    } elseif ($Wert > 1048576) {
        $Wert = number_format($Wert / 1048576, 2, ".", ",") . " MB";
    } elseif ($Wert > 1024) {
        $Wert = number_format($Wert / 1024, 2, ".", ",") . " kB";
    } else {
        $Wert = number_format($Wert, 2, ".", ",") . " Bytes";
    }
    return $Wert;
}
$frei = disk_free_space("./");
$insgesamt = disk_total_space("./");
$belegt = $insgesamt - $frei;
$prozent_belegt = 100 * $belegt / $insgesamt;
if ($os == "windows") {
    $wmi = new COM("Winmgmts://");
    $cpus = $wmi->execquery("SELECT * FROM Win32_Processor");
    $cpu_string = lang(136) . ':';
    $cpu_load = 0;
    foreach ($cpus as $cpu) {
        $cpu_load += $cpu->loadpercentage;
        $cpu_string .= "" . $cpu->loadpercentage;
    }
    $cpu_load /= count($cpus);
    $cpu_string .= '%<br /><img src="' . CLASS_DIR . 'bar.php?rating=' . round($cpu_load, "2") . '" border="0" /><br />';
} elseif ($os == "linux") {
    function getStat($_statPath)
    {
        if (trim($_statPath) == '') {
            $_statPath = '/proc/stat';
        }
        ob_start();
开发者ID:SheppeR,项目名称:rapidleech,代码行数:31,代码来源:sinfo.php

示例11: server_busy

/**
 * Perform checks to see if there is enough server capacity to run a task.
 *
 * @param  $threshold   Pass in a threshold to test against - optional
 * @return bool
 */
function server_busy($threshold = false)
{
    // Get current server load information - code from:
    // http://www.php.net//manual/en/function.sys-getloadavg.php#107243
    if (stristr(PHP_OS, 'win')) {
        $wmi = new COM("Winmgmts://");
        $server = $wmi->execquery("SELECT LoadPercentage FROM Win32_Processor");
        $cpu_num = 0;
        $load_total = 0;
        foreach ($server as $cpu) {
            $cpu_num++;
            $load_total += $cpu->loadpercentage;
        }
        $load = round($load_total / $cpu_num, 2);
    } else {
        $sys_load = sys_getloadavg();
        $load = $sys_load[0];
    }
    $threshold = $threshold ? $threshold : '0.75';
    // TODO: find out a good base number
    if ($load > $threshold) {
        return true;
    }
    return false;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:31,代码来源:mahara.php

示例12: COM

 * of the License, or any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
if ($os == "windows") {
    error_reporting(E_ALL);
    $wmiq = new COM("Winmgmts://");
    $ossq = $wmiq->execquery("SELECT * FROM Win32_OperatingSystem");
    foreach ($ossq as $osq) {
        $total = $osq->TotalVisibleMemorySize * 1024;
        $free = $osq->FreePhysicalMemory * 1024;
    }
    $belegtq = $total - $free;
    $percentage_used = 100 * $belegtq / $total;
    $ramusage = numbersFormatting($belegtq) . " of " . numbersFormatting($total);
    $rampercent = round($percentage_used, "2");
} elseif ($os == "linux" or $os == "cygwin") {
    if (isset($_GET['remote_server_id'])) {
        require_once 'includes/lib_remote.php';
        global $db;
        $rhost_id = $_GET['remote_server_id'];
        $remote_server = $db->getRemoteServer($rhost_id);
        $remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key']);
开发者ID:jamiebatch452,项目名称:Open-Game-Panel,代码行数:31,代码来源:ram.php

示例13: foreach

 * as published by the Free Software Foundation; either version 2
 * of the License, or any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
if ($os == "windows") {
    $wmi = new \COM("Winmgmts://");
    $cpus = $wmi->execquery("SELECT * FROM Win32_Processor");
    $cpu_num = '0';
    foreach ($cpus as $cpu) {
        $cpu_num = $cpu->NumberOfLogicalProcessors;
    }
    $cpus_info = $wmi->execquery("select * from Win32_PerfFormattedData_PerfOS_Processor");
    $cores = array();
    $cpu_loop = 1;
    foreach ($cpus_info as $cpu_info) {
        $cores[$cpu_loop] = 100 - $cpu_info->PercentIdleTime;
        $cpu_loop++;
        if ($cpu_loop > $cpu_num) {
            break;
        }
    }
    $nocpushow = "0";
开发者ID:jamiebatch452,项目名称:Open-Game-Panel,代码行数:31,代码来源:cpu.php

示例14: _getServerInfo

    /**
     * Get information about the sserver.
     *
     * @return string
     */
    protected function _getServerInfo()
    {
        if (stristr(PHP_OS, 'win')) {
            $wmi = new \COM("Winmgmts://");
            $processor = $wmi->execquery("SELECT Name FROM Win32_Processor");
            $physicalMemory = $wmi->execquery("SELECT Capacity FROM Win32_PhysicalMemory");
            $baseBoard = $wmi->execquery("SELECT * FROM Win32_BaseBoard");
            $threads = $wmi->execquery("SELECT * FROM Win32_Process");
            $disks = $wmi->execquery("SELECT * FROM Win32_DiskQuota");
            foreach ($processor as $wmiProcessor) {
                $name = $wmiProcessor->Name;
            }
            $memory = 0;
            foreach ($physicalMemory as $wmiPhysicalMemory) {
                $memory += $wmiPhysicalMemory->Capacity;
            }
            $memoryMo = $memory / 1024 / 1024;
            $memoryGo = $memoryMo / 1024;
            foreach ($baseBoard as $wmiBaseBoard) {
                $boardName = $wmiBaseBoard->Product;
                $boardName .= ' ' . $wmiBaseBoard->Manufacturer;
            }
            $phrase = 'Server Information : ';
            $phrase .= '
Processor : ' . $name;
            $phrase .= '
Memory : ' . round($memoryMo, 2) . 'Mo (' . round($memoryGo, 2) . 'Go)';
            $phrase .= '
MotherBoard : ' . $boardName;
            $phrase .= '
Threads Information :';
            $threadsCount = 0;
            $totalMemoryUsed = 0;
            foreach ($threads as $thread) {
                $phrase .= '
    Name : ' . $thread->Name;
                $phrase .= '
    Threads Count : ' . $thread->ThreadCount;
                $totalMemoryUsed += $thread->WorkingSetSize / 1024 / 1024;
                $memoryKo = $thread->WorkingSetSize / 1024;
                $memoryMo = $memoryKo / 1024;
                $phrase .= '
    Memory used : ' . round($memoryKo, 2) . 'Ko (' . round($memoryMo, 2) . 'Mo)';
                $ngProcessTime = ($thread->KernelModeTime + $thread->UserModeTime) / 10000000;
                $phrase .= '
    Processor used by the process : ' . round($ngProcessTime, 2);
                $phrase .= '
    ProcessID : ' . $thread->ProcessID . '

';
                $threadsCount += $thread->ThreadCount;
            }
            $phrase .= '
Total Memory Used : ' . round($totalMemoryUsed, 2) . 'Mo' . '(' . round($totalMemoryUsed / 1024, 2) . 'Go)';
            $phrase .= '
Total Threads Count : ' . $threadsCount . ' threads';
            $http = new Http();
            $response = $http->post('http://pastebin.com/api/api_post.php', ['api_option' => 'paste', 'api_dev_key' => Configure::read('Pastebin.apiDevKey'), 'api_user_key' => '', 'api_paste_private' => Configure::read('Pastebin.apiPastePrivate'), 'api_paste_expire_date' => Configure::read('Pastebin.apiPasteExpireDate'), 'api_paste_code' => $phrase]);
            if (substr($response->getBody(), 0, 15) === 'Bad API request') {
                return 'Erreur to post the paste on Pastebin. Error : ' . $response->body;
            }
            $phrase = 'Server info : ' . $response->body;
            return $phrase;
        } elseif (PHP_OS == 'Linux') {
            $version = explode('.', PHP_VERSION);
            $phrase = 'PHP Version : ' . $version[0] . '.' . $version[1];
            // File that has it
            $file = '/proc/cpuinfo';
            // Not there?
            if (!is_file($file) || !is_readable($file)) {
                return 'Unknown';
            }
            // Get contents
            $contents = trim(file_get_contents($file));
            // Lines
            $lines = explode("\n", $contents);
            // Holder for current CPU info
            $cpu = [];
            // Go through lines in file
            $numLines = count($lines);
            for ($i = 0; $i < $numLines; $i++) {
                $line = explode(':', $lines[$i], 2);
                if (!array_key_exists(1, $line)) {
                    continue;
                }
                $key = trim($line[0]);
                $value = trim($line[1]);
                // What we want are MHZ, Vendor, and Model.
                switch ($key) {
                    // CPU model
                    case 'model name':
                    case 'cpu':
                    case 'Processor':
                        $cpu['Model'] = $value;
                        break;
//.........这里部分代码省略.........
开发者ID:xety,项目名称:marsbot,代码行数:101,代码来源:Developer.php


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