vadimcomanescu/vmwarephp

vSphere API v6 causes segfault after a certain number of machines

rmyhren opened this issue · 0 comments

With the small script below, I get a segfault after looping through roughly half of our VMs.
Can you help me understand why? And if I am lucky, fix it?

Br
Robert

End of output

Ubuntu Linux (64-bit)
Number of virt : 1275
521
Microsoft Windows 7 (32-bit)
Number of virt : 1275
522
Microsoft Windows 7 (64-bit)
Number of virt : 1275
523
Segmentation fault

Code

<?php
   function CollectVMInfos()
  {
      require_once 'collectors/library/Vmwarephp/Autoloader.php';
      $autoloader = new \Vmwarephp\Autoloader;
      $autoloader->register();

      $sVSphereServer = "host";
      $sLogin = "user";
      $sPassword = "password";

      $vhost = new \Vmwarephp\Vhost($sVSphereServer, $sLogin, $sPassword);

      var_dump("vSphere API type: ".$vhost->getApiType().", version: ".$vhost->getApiVersion());

      //$aVirtualMachines = $vhost->findAllManagedObjects('VirtualMachine', array('config', 'runtime', 'guest', 'network', 'storage'));
      $aVirtualMachines = $vhost->findAllManagedObjects('VirtualMachine', array('config'));
      $i=0;
      foreach($aVirtualMachines as $oVirtualMachine)
      {
        echo "Number of virt : ".count($aVirtualMachines)."\n";
        echo $i++."\n";
        //var_dump($oVirtualMachine->config);
        //echo $oVirtualMachine->config->name."\n";
        echo $oVirtualMachine->config->guestFullName."\n";
      }
  }


CollectVMInfos();
?>