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


PHP CommonFunctions::executeProgram方法代码示例

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


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

示例1: __construct

 /**
  * fill the private content var through command or data access
  */
 public function __construct()
 {
     parent::__construct();
     switch (defined('PSI_SENSOR_LMSENSORS_ACCESS') ? strtolower(PSI_SENSOR_LMSENSORS_ACCESS) : 'command') {
         case 'command':
             if (CommonFunctions::executeProgram("sensors", "", $lines)) {
                 // Martijn Stolk: Dirty fix for misinterpreted output of sensors,
                 // where info could come on next line when the label is too long.
                 $lines = str_replace(":\n", ":", $lines);
                 $lines = str_replace("\n\n", "\n", $lines);
                 $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
             }
             break;
         case 'data':
             if (CommonFunctions::rfts(APP_ROOT . '/data/lmsensors.txt', $lines)) {
                 $lines = str_replace(":\n", ":", $lines);
                 $lines = str_replace("\n\n", "\n", $lines);
                 $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
             }
             break;
         default:
             $this->error->addConfigError('__construct()', 'PSI_SENSOR_LMSENSORS_ACCESS');
             break;
     }
 }
开发者ID:CrusherXRay,项目名称:phpsysinfo,代码行数:28,代码来源:class.lmsensors.inc.php

示例2: _users

 /**
  * Number of Users
  *
  * @return void
  */
 protected function _users()
 {
     if (CommonFunctions::executeProgram('who', '', $strBuf, PSI_DEBUG)) {
         if (strlen(trim($strBuf)) > 0) {
             $lines = preg_split('/\\n/', $strBuf);
             $this->sys->setUsers(count($lines));
         }
     } elseif (CommonFunctions::executeProgram('uptime', '', $buf, PSI_DEBUG) && preg_match("/,\\s+(\\d+)\\s+user[s]?,/", $buf, $ar_buf)) {
         //} elseif (CommonFunctions::executeProgram('uptime', '', $buf) && preg_match("/,\s+(\d+)\s+user[s]?,\s+load average[s]?:\s+(.*),\s+(.*),\s+(.*)$/", $buf, $ar_buf)) {
         $this->sys->setUsers($ar_buf[1]);
     } else {
         $processlist = glob('/proc/*/cmdline', GLOB_NOSORT);
         if (($total = count($processlist)) > 0) {
             $count = 0;
             $buf = "";
             for ($i = 0; $i < $total; $i++) {
                 if (CommonFunctions::rfts($processlist[$i], $buf, 0, 4096, false)) {
                     $name = str_replace(chr(0), ' ', trim($buf));
                     if (preg_match("/^-/", $name)) {
                         $count++;
                     }
                 }
             }
             if ($count > 0) {
                 $this->sys->setUsers($count);
             }
         }
     }
 }
开发者ID:arris69,项目名称:phpsysinfo,代码行数:34,代码来源:class.OS.inc.php

示例3: __construct

 /**
  * fill the private content var through tcp or file access
  */
 public function __construct()
 {
     parent::__construct();
     switch (strtolower(PSI_SENSOR_ACCESS)) {
         case 'tcp':
             $fp = fsockopen("localhost", 411, $errno, $errstr, 5);
             if ($fp) {
                 $lines = "";
                 while (!feof($fp)) {
                     $lines .= fread($fp, 1024);
                 }
                 $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
             } else {
                 $this->error->addError("fsockopen()", $errno . " " . $errstr);
             }
             break;
         case 'command':
             CommonFunctions::executeProgram('mbmon', '-c 1 -r', $lines, PSI_DEBUG);
             $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
             break;
         default:
             $this->error->addConfigError('__construct()', 'PSI_SENSOR_ACCESS');
             break;
     }
 }
开发者ID:sorrowchen,项目名称:openfiler-cn,代码行数:28,代码来源:class.MBMon.inc.php

示例4: __construct

 /**
  * read the data into an internal array and also call the parent constructor
  *
  * @param String $enc encoding
  */
 public function __construct($enc)
 {
     $buffer = "";
     parent::__construct(__CLASS__, $enc);
     switch (strtolower(PSI_PLUGIN_DMRAID_ACCESS)) {
         case 'command':
             if (PSI_OS == 'FreeBSD') {
                 CommonFunctions::executeProgram("graid", "list", $buffer);
             } else {
                 CommonFunctions::executeProgram("dmraid", "-s -vv 2>&1", $buffer);
             }
             break;
         case 'data':
             CommonFunctions::rfts(APP_ROOT . "/data/dmraid.txt", $buffer);
             break;
         default:
             $this->global_error->addConfigError("__construct()", "PSI_PLUGIN_DMRAID_ACCESS");
             break;
     }
     if (trim($buffer) != "") {
         if (PSI_OS == 'FreeBSD') {
             $this->_filecontent = preg_split("/Consumers:\r?\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
         } else {
             $this->_filecontent = preg_split("/(\r?\n\\*\\*\\* )|(\r?\n--> )/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
         }
     } else {
         $this->_filecontent = array();
     }
 }
开发者ID:FleuryK,项目名称:phpsysinfo,代码行数:34,代码来源:class.dmraid.inc.php

示例5: execute

 public function execute()
 {
     $this->_lines = array();
     switch (strtolower(PSI_PLUGIN_UPRECORDS_ACCESS)) {
         case 'command':
             $lines = "";
             $oldtz = getenv("TZ");
             putenv("TZ=GMT");
             $options = "";
             if (defined('PSI_PLUGIN_UPRECORDS_MAX_ENTRIES')) {
                 if (PSI_PLUGIN_UPRECORDS_MAX_ENTRIES === false) {
                     $options = " -m 0";
                 } elseif (PSI_PLUGIN_UPRECORDS_MAX_ENTRIES === true) {
                     $options = " -m 1";
                 } elseif (PSI_PLUGIN_UPRECORDS_MAX_ENTRIES > 1 && PSI_PLUGIN_UPRECORDS_MAX_ENTRIES != 10) {
                     $options = " -m " . PSI_PLUGIN_UPRECORDS_MAX_ENTRIES;
                 }
             }
             if (CommonFunctions::executeProgram('uprecords', '-a -w' . $options, $lines) && !empty($lines)) {
                 $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
             }
             putenv("TZ=" . $oldtz);
             break;
         case 'data':
             if (CommonFunctions::rfts(APP_ROOT . "/data/uprecords.txt", $lines) && !empty($lines)) {
                 $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
             }
             break;
         default:
             $this->error->addConfigError('__construct()', 'PSI_PLUGIN_UPRECORDS_ACCESS');
             break;
     }
 }
开发者ID:kampee,项目名称:phpsysinfo,代码行数:33,代码来源:class.uprecords.inc.php

示例6: __construct

 public function __construct()
 {
     parent::__construct();
     switch (defined('PSI_SENSOR_SPEEDFAN_ACCESS') ? strtolower(PSI_SENSOR_SPEEDFAN_ACCESS) : 'command') {
         case 'command':
             if (CommonFunctions::executeProgram("SpeedFanGet.exe", "", $buffer, PSI_DEBUG) && strlen($buffer) > 0) {
                 if (preg_match("/^Temperatures:\\s+(.+)\$/m", $buffer, $out)) {
                     $this->_filecontent["temp"] = $out[1];
                 }
                 if (preg_match("/^Fans:\\s+(.+)\$/m", $buffer, $out)) {
                     $this->_filecontent["fans"] = $out[1];
                 }
                 if (preg_match("/^Voltages:\\s+(.+)\$/m", $buffer, $out)) {
                     $this->_filecontent["volt"] = $out[1];
                 }
             }
             break;
         case 'data':
             if (CommonFunctions::rfts(APP_ROOT . '/data/speedfan.txt', $buffer) && strlen($buffer) > 0) {
                 if (preg_match("/^Temperatures:\\s+(.+)\$/m", $buffer, $out)) {
                     $this->_filecontent["temp"] = $out[1];
                 }
                 if (preg_match("/^Fans:\\s+(.+)\$/m", $buffer, $out)) {
                     $this->_filecontent["fans"] = $out[1];
                 }
                 if (preg_match("/^Voltages:\\s+(.+)\$/m", $buffer, $out)) {
                     $this->_filecontent["volt"] = $out[1];
                 }
             }
             break;
         default:
             $this->error->addConfigError('__construct()', 'PSI_SENSOR_SPEEDFAN_ACCESS');
             break;
     }
 }
开发者ID:FleuryK,项目名称:phpsysinfo,代码行数:35,代码来源:class.speedfan.inc.php

示例7: __construct

 /**
  * read the data into an internal array and also call the parent constructor
  *
  * @param String $enc encoding
  */
 public function __construct($enc)
 {
     parent::__construct(__CLASS__, $enc);
     switch (strtolower(PSI_PLUGIN_UPDATENOTIFIER_ACCESS)) {
         case 'command':
             if (PSI_PLUGIN_UPDATENOTIFIER_UBUNTU_LANDSCAPE_FORMAT === true) {
                 CommonFunctions::executeProgram("/usr/lib/update-notifier/apt-check", "--human-readable", $buffer_info);
             } else {
                 CommonFunctions::executeProgram("/usr/lib/update-notifier/apt-check", "2>&1", $buffer_info);
             }
             break;
         case 'data':
             if (defined('PSI_PLUGIN_UPDATENOTIFIER_FILE') && is_string(PSI_PLUGIN_UPDATENOTIFIER_FILE)) {
                 CommonFunctions::rfts(PSI_PLUGIN_UPDATENOTIFIER_FILE, $buffer_info);
             } else {
                 CommonFunctions::rfts("/var/lib/update-notifier/updates-available", $buffer_info);
             }
             break;
         default:
             $this->global_error->addConfigError("__construct()", "PSI_PLUGIN_UPDATENOTIFIER_ACCESS");
             break;
     }
     // Remove blank lines
     $this->_filecontent = preg_split("/\r?\n/", $buffer_info, -1, PREG_SPLIT_NO_EMPTY);
 }
开发者ID:FleuryK,项目名称:phpsysinfo,代码行数:30,代码来源:class.updatenotifier.inc.php

示例8: _network

 /**
  * get network information
  *
  * @return void
  */
 private function _network()
 {
     if (CommonFunctions::executeProgram('netstat', '-nibd | grep Link', $netstat, PSI_DEBUG)) {
         $lines = preg_split("/\n/", $netstat, -1, PREG_SPLIT_NO_EMPTY);
         foreach ($lines as $line) {
             $ar_buf = preg_split("/\\s+/", $line);
             if (!empty($ar_buf[0])) {
                 $dev = new NetDevice();
                 $dev->setName($ar_buf[0]);
                 if (strlen($ar_buf[3]) < 15) {
                     $dev->setTxBytes($ar_buf[8]);
                     $dev->setRxBytes($ar_buf[5]);
                     $dev->setDrops($ar_buf[10]);
                     $dev->setErrors($ar_buf[4] + $ar_buf[7]);
                 } else {
                     $dev->setTxBytes($ar_buf[9]);
                     $dev->setRxBytes($ar_buf[6]);
                     $dev->setErrors($ar_buf[5] + $ar_buf[8]);
                     $dev->setDrops($ar_buf[11]);
                 }
                 $this->sys->setNetDevices($dev);
             }
         }
     }
 }
开发者ID:kamaulynder,项目名称:Ushahidi_Chile,代码行数:30,代码来源:class.FreeBSD.inc.php

示例9: __construct

 /**
  * get all information from all configured ups and store output in internal array
  */
 public function __construct()
 {
     parent::__construct();
     if (defined('PSI_UPS_NUT_LIST') && is_string(PSI_UPS_NUT_LIST)) {
         if (preg_match(ARRAY_EXP, PSI_UPS_NUT_LIST)) {
             $upses = eval(PSI_UPS_NUT_LIST);
         } else {
             $upses = array(PSI_UPS_NUT_LIST);
         }
         foreach ($upses as $ups) {
             CommonFunctions::executeProgram('upsc', '-l ' . trim($ups), $output, PSI_DEBUG);
             $ups_names = preg_split("/\n/", $output, -1, PREG_SPLIT_NO_EMPTY);
             foreach ($ups_names as $ups_name) {
                 CommonFunctions::executeProgram('upsc', trim($ups_name) . '@' . trim($ups), $temp, PSI_DEBUG);
                 if (!empty($temp)) {
                     $this->_output[trim($ups_name) . '@' . trim($ups)] = $temp;
                 }
             }
         }
     } else {
         //use default if address and port not defined
         CommonFunctions::executeProgram('upsc', '-l', $output, PSI_DEBUG);
         $ups_names = preg_split("/\n/", $output, -1, PREG_SPLIT_NO_EMPTY);
         foreach ($ups_names as $ups_name) {
             CommonFunctions::executeProgram('upsc', trim($ups_name), $temp, PSI_DEBUG);
             if (!empty($temp)) {
                 $this->_output[trim($ups_name)] = $temp;
             }
         }
     }
 }
开发者ID:phpsysinfo,项目名称:phpsysinfo,代码行数:34,代码来源:class.nut.inc.php

示例10: __construct

 /**
  * get all information from all configured ups in config.php and store output in internal array
  */
 public function __construct()
 {
     parent::__construct();
     CommonFunctions::executeProgram('powersoftplus', '-p', $temp);
     if (!empty($temp)) {
         $this->_output[] = $temp;
     }
 }
开发者ID:l1ght13aby,项目名称:Ubilling,代码行数:11,代码来源:class.powersoftplus.inc.php

示例11: __construct

 /**
  * get all information from all configured ups and store output in internal array
  */
 public function __construct()
 {
     parent::__construct();
     CommonFunctions::executeProgram('pmset', '-g batt', $temp);
     if (!empty($temp)) {
         $this->_output[] = $temp;
     }
 }
开发者ID:bbspike,项目名称:sentora-core,代码行数:11,代码来源:class.pmset.inc.php

示例12: __construct

 /**
  * fill the private content var through command
  */
 public function __construct()
 {
     parent::__construct();
     $lines = "";
     //        CommonFunctions::executeProgram('sysctl', '-w hw.sensors', $lines);
     CommonFunctions::executeProgram('sysctl', 'hw.sensors', $lines);
     $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
 }
开发者ID:CrusherXRay,项目名称:phpsysinfo,代码行数:11,代码来源:class.hwsensors.inc.php

示例13: _temperature

 /**
  * get temperature information
  *
  * @return void
  */
 private function _temperature()
 {
     if (PSI_OS == 'Linux') {
         $hwpaths = glob("/sys/devices/platform/coretemp.*/", GLOB_NOSORT);
         if (($totalh = count($hwpaths)) > 0) {
             $buf = "";
             for ($h = 0; $h < $totalh; $h++) {
                 $tempsensor = glob($hwpaths[$h] . "temp*_input", GLOB_NOSORT);
                 if (($total = count($tempsensor)) > 0) {
                     $buf = "";
                     for ($i = 0; $i < $total; $i++) {
                         if (CommonFunctions::rfts($tempsensor[$i], $buf, 1, 4096, false) && trim($buf) != "") {
                             $dev = new SensorDevice();
                             $dev->setValue(trim($buf) / 1000);
                             $label = preg_replace("/_input\$/", "_label", $tempsensor[$i]);
                             $crit = preg_replace("/_input\$/", "_crit", $tempsensor[$i]);
                             $max = preg_replace("/_input\$/", "_max", $tempsensor[$i]);
                             $crit_alarm = preg_replace("/_input\$/", "_crit_alarm", $tempsensor[$i]);
                             if (CommonFunctions::fileexists($label) && CommonFunctions::rfts($label, $buf, 1, 4096, false) && trim($buf) != "") {
                                 $dev->setName(trim($buf));
                             } else {
                                 $labelname = trim(preg_replace("/_input\$/", "", pathinfo($tempsensor[$i], PATHINFO_BASENAME)));
                                 if ($labelname !== "") {
                                     $dev->setName($labelname);
                                 } else {
                                     $dev->setName('unknown');
                                 }
                             }
                             if (CommonFunctions::fileexists($crit) && CommonFunctions::rfts($crit, $buf, 1, 4096, false) && trim($buf) != "") {
                                 $dev->setMax(trim($buf) / 1000);
                                 if (CommonFunctions::fileexists($crit_alarm) && CommonFunctions::rfts($crit_alarm, $buf, 1, 4096, false) && trim($buf) === "1") {
                                     $dev->setEvent("Critical Alarm");
                                 }
                             } elseif (CommonFunctions::fileexists($max) && CommonFunctions::rfts($max, $buf, 1, 4096, false) && trim($buf) != "") {
                                 $dev->setMax(trim($buf) / 1000);
                             }
                             $this->mbinfo->setMbTemp($dev);
                         }
                     }
                 }
             }
         }
     } else {
         $smp = 1;
         CommonFunctions::executeProgram('sysctl', '-n kern.smp.cpus', $smp);
         for ($i = 0; $i < $smp; $i++) {
             $temp = 0;
             if (CommonFunctions::executeProgram('sysctl', '-n dev.cpu.' . $i . '.temperature', $temp)) {
                 $temp = preg_replace('/C/', '', $temp);
                 $dev = new SensorDevice();
                 $dev->setName("CPU " . ($i + 1));
                 $dev->setValue($temp);
                 //                    $dev->setMax(70);
                 $this->mbinfo->setMbTemp($dev);
             }
         }
     }
 }
开发者ID:CrusherXRay,项目名称:phpsysinfo,代码行数:63,代码来源:class.coretemp.inc.php

示例14: __construct

 /**
  * get all information from all configured ups and store output in internal array
  */
 public function __construct()
 {
     parent::__construct();
     CommonFunctions::executeProgram('upsc', '-l', $output);
     $ups_names = preg_split("/\n/", $output, -1, PREG_SPLIT_NO_EMPTY);
     foreach ($ups_names as $value) {
         CommonFunctions::executeProgram('upsc', $value, $temp);
         $this->_output[$value] = $temp;
     }
 }
开发者ID:HaakonME,项目名称:porticoestate,代码行数:13,代码来源:class.nut.inc.php

示例15: __construct

 /**
  * read the data into an internal array and also call the parent constructor
  *
  * @param String $enc target encoding
  */
 public function __construct($enc)
 {
     parent::__construct(__CLASS__, $enc);
     switch (strtolower(PSI_PLUGIN_PSSTATUS_ACCESS)) {
         case 'command':
             if (PSI_OS == 'WINNT') {
                 try {
                     $objLocator = new COM('WbemScripting.SWbemLocator');
                     $wmi = $objLocator->ConnectServer('', 'root\\CIMv2');
                     $process_wmi = CommonFunctions::getWMI($wmi, 'Win32_Process', array('Caption', 'ProcessId'));
                     foreach ($process_wmi as $process) {
                         $this->_filecontent[] = array(strtolower(trim($process['Caption'])), trim($process['ProcessId']));
                     }
                 } catch (Exception $e) {
                 }
             } else {
                 if (defined('PSI_PLUGIN_PSSTATUS_PROCESSES') && is_string(PSI_PLUGIN_PSSTATUS_PROCESSES)) {
                     if (preg_match(ARRAY_EXP, PSI_PLUGIN_PSSTATUS_PROCESSES)) {
                         $processes = eval(PSI_PLUGIN_PSSTATUS_PROCESSES);
                     } else {
                         $processes = array(PSI_PLUGIN_PSSTATUS_PROCESSES);
                     }
                     if (defined('PSI_PLUGIN_PSSTATUS_USE_REGEX') && PSI_PLUGIN_PSSTATUS_USE_REGEX === true) {
                         foreach ($processes as $process) {
                             CommonFunctions::executeProgram("pgrep", "-n -x " . $process, $buffer, PSI_DEBUG);
                             if (strlen($buffer) > 0) {
                                 $this->_filecontent[] = array($process, $buffer);
                             }
                         }
                     } else {
                         foreach ($processes as $process) {
                             CommonFunctions::executeProgram("pidof", "-s " . $process, $buffer, PSI_DEBUG);
                             if (strlen($buffer) > 0) {
                                 $this->_filecontent[] = array($process, $buffer);
                             }
                         }
                     }
                 }
             }
             break;
         case 'data':
             CommonFunctions::rfts(APP_ROOT . "/data/psstatus.txt", $buffer);
             $processes = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
             foreach ($processes as $process) {
                 $ps = preg_split("/[\\s]?\\|[\\s]?/", $process, -1, PREG_SPLIT_NO_EMPTY);
                 if (count($ps) == 2) {
                     $this->_filecontent[] = array(trim($ps[0]), trim($ps[1]));
                 }
             }
             break;
         default:
             $this->global_error->addError("switch(PSI_PLUGIN_PSSTATUS_ACCESS)", "Bad psstatus configuration in phpsysinfo.ini");
             break;
     }
 }
开发者ID:phpsysinfo,项目名称:phpsysinfo,代码行数:60,代码来源:class.psstatus.inc.php


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