我正在扫描一个子网来收集网络上资产的WMI信息。但是,如果机器被卡在POST中或有一些未知的问题,它将冻结脚本,永远不会转移到下一台机器。问题是,是否有办法在PHP COM WbemScripting.SWbemLocator?上设置超时。
$host = 10.1.1.5; //Host is online, but may be hung trying to shutdown
//Check if host is online
if(@$fp = fsockopen($host,135,$errCode,$errStr,0.1))
{
//Create new connection
$WbemLocator = new COM ("WbemScripting.SWbemLocator");
//Connect to remote workstation
$WbemServices = $WbemLocator->ConnectServer($host, 'root\\cimv2',$user,$password);
$WbemServices->Security_->ImpersonationLevel = 3;
//Basic WMI query
$system = $WbemServices->execQuery("Select * from Win32_ComputerSystem");
foreach($pcsystem AS $n){
$hostname = $n->Name; //Hostname
}
//Process all data ->Insert into DB
}
//Move on to next machine. In this case, the script will never move on发布于 2020-05-18 22:50:28
简单地说,不是,因为它是一个COM对象,而不是一个PHP对象,并且没有直接控制它的工具。
更长、更推测的答案是,您可以尝试通过注册表(特别是TCP参数 )来调整TcpInitialRtt,尽管除非您在一个非常可靠和不拥挤的网络上运行,否则似乎没有太多的空间来改变这种行为。你可能会弄坏机器上运行的其他东西。
https://stackoverflow.com/questions/61880143
复制相似问题