function Do_command ($commandName, $args) {
$buffer = "";
if (false = = ($command = Find_command ($commandName)) return false;
if ($fp = @popen ("$command $args", ' R ')) {
while (! @feof ($fp)) {
$buffer. = @fgets ($fp, 4096);
}
Return trim ($buffer);
}
return false;
}
Windows System Probes
function Sys_windows () {
$objLocator = new COM ("WbemScripting.SWbemLocator");
$WMI = $objLocator->connectserver ();
$prop = $wmi->get ("win32_pnpentity");
Cpu
$cpuinfo = Getwmi ($wmi, "Win32_Processor", Array ("Name", "L2cachesize", "numberofcores"));
$res [' CPU '] [' num '] = $cpuinfo [0][' numberofcores '];
if (null = = $res [' CPU '] [' num ']) {
$res [' CPU '] [' num '] = 1;
}
for ($i =0; $i < $res [' CPU '] [' num ']; $i + +) {
$res [' CPU '] [' model ']. = $cpuinfo [0][' Name ']. <br> ";
$res [' CPU '] [' cache ']. = $cpuinfo [0][' L2cachesize ']. <br> ";
}
SysInfo
$sysinfo = Getwmi ($wmi, "Win32_OperatingSystem", Array (' LastBootUpTime ', ' totalvisiblememorysize ', ' Freephysicalmemory ', ' Caption ', ' csdversion ', ' serialnumber ', ' installdate ');
$res [' win_n '] = $sysinfo [0][' Caption ']. " ". $sysinfo [0][' CSDVersion ']." <b> serial number </b>:{$sysinfo [0][' SerialNumber ']} on. Date (' Y-month D-Day h:i:s ', Strtotime (substr ($sysinfo [0][' InstallDate '],0,14))]. " Installation ";
UPTIME
$res [' uptime '] = $sysinfo [0][' LastBootUpTime '];
$sys _ticks = 3600*8 + Time ()-Strtotime (substr ($res [' uptime '],0,14)];
$min = $sys _ticks/60;
$hours = $min/60;
$days = Floor ($hours/24);
$hours = Floor ($hours-($days * 24));
$min = Floor ($min-($days *)-($hours * 60));
if ($days!== 0) $res [' uptime '] = $days. " Days ";
if ($hours!== 0) $res [' uptime ']. = $hours. " Hours ";
$res [' uptime ']. = $min. " Minutes ";
MEMORY
$res [' memtotal '] = $sysinfo [0][' totalvisiblememorysize '];
$res [' memfree '] = $sysinfo [0][' freephysicalmemory '];
$res [' memused '] = $res [' memtotal ']-$res [' Memfree '];
$res [' mempercent '] = round ($res [' memused ']/$res [' memtotal ']*100,2);
$swapinfo = Getwmi ($wmi, "Win32_PageFileUsage", Array (' allocatedbasesize ', ' currentusage '));
TODO SWP Area get
$res [' swaptotal '] = $swapinfo [0][allocatedbasesize];
$res [' swapused '] = $swapinfo [0][currentusage];
$res [' swapfree '] = $res [' swaptotal ']-$res [' swapused '];
$res [' swappercent '] = (floatval ($res [' swaptotal '])!=0)? Round ($res [' swapused ']/$res [' Swaptotal ']*100,2]: 0;
Loadpercentage
$loadinfo = Getwmi ($wmi, "Win32_Processor", Array ("Loadpercentage"));
$res [' loadavg '] = $loadinfo [0][' loadpercentage '];
return $res;
}
function Getwmi ($WMI, $strClass, $strValue = Array ()) {
$arrData = Array ();
$objWEBM = $wmi->get ($strClass);
$arrProp = $objWEBM->properties_;
$arrWEBMCol = $objWEBM->instances_ ();
foreach ($arrWEBMCol as $objItem) {
@reset ($arrProp);
$arrInstance = Array () ;
foreach ($arrProp as $propItem) {
eval ($value = $objItem->. $propItem-> Name. ";");
if (Empty ($strValue)) {
$arrInstance [$propItem->name] = Trim ($ Value);
} else {
if (In_array ($propItem->name, $strValue)) {
& nbsp; $arrInstance [$propItem->name] = Trim ($value);
}
}
}
$arrData [] = $arrInstance;
}
return $arrData;
}