Skip to content

vSphere API v6 causes segfault after a certain number of machines #24

Description

@rmyhren

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();
?>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions