VMware Cloud Community
mmorent
Contributor
Contributor

vSphere API - Performance Monitor

I try to get the information from the performance monitor from within a PHP script.

I can login, but when I try to user per PerformanceManager I get the error: SoapFault exception: [ServerFaultCode] A specified parameter was not correct.

But I can't figure out what is wrong.

This is my code:

try {  

        $server = "my-esxi-server";

        $username = "root";

        $password = "root-password";

       

  $client = new SoapClient("https://".$server."/sdk/vimService.wsdl", array("location"=>"https://".$server."/sdk/", "trace"=>1));

  // setup service content

  $soap_message["_this"] = new SoapVar("ServiceInstance", XSD_STRING, "ServiceInstance");

  $result = $client->RetrieveServiceContent($soap_message);

  $service_instance = $result->returnval;

        print_r($service_instance);

  echo "\n\n<hr>\n\n";

  // login example via serviceinstance

  $soap_message["_this"] = $service_instance->sessionManager;

  $soap_message["userName"] = $username;

  $soap_message["password"] = $password;

  $result = $client->Login($soap_message);

  $soap_session = $result->returnval;

  print_r($soap_session);

  echo "\n\n<hr>\n\n";


        // setup property collector

  $soap_message["_this"] = $service_instance->perfManager;

  $soap_message["entity"] = "8";

  $result = $client->QueryPerfProviderSummary($soap_message);

        $performance_instance = $result->returnval;

  print_r($performance_instance);

  echo "\n\n<hr>\n\n";

       

  // logout example

  $soap_message["_this"] = $service_instance->sessionManager;

  $result = $client->Logout($soap_message);

} catch (Exception $e) {                         

  print_r($client->__getLastRequest());

  printf("%s\n",$e->__toString());

  return false;                            

}

Kind regards,

Maarten

Tags (3)
0 Kudos
0 Replies