[vbox-dev] getStatistic method issues

Igor Shkodyrev mobspot at gmail.com
Thu Feb 18 19:33:20 GMT 2010


Nikolay,
thank you for your helpful response.
The workaround you've provided worked for me also.
The code became working except the one thing: it became working only
in case of "local" run of vboxshell.

When i try to run it through SOAP i do get the following exception:
===
vbox> stats3 winvm2
['stats3', 'winvm2']
Version is 3.1.4
 One can use setvar <mach> <var> <value> to change variable, using name in [].
  Name [name]: winvm2
  ID [n/a]: eb982658-4169-47f7-89be-1af6e7c52934
  OS Type [n/a]: Windows XP
VirtualBox error: A session for the machine 'winvm2' is currently open
(or being closed) (0x2159738887)
<VirtualBox_services_types.RuntimeFault_Holder object at 0x938706c>
Traceback (most recent call last):
  File "./vboxshell2.py", line 1260, in interpret
    done = runCommand(ctx, cmd)
  File "./vboxshell2.py", line 1179, in runCommand
    return runCommandArgs(ctx, args)
  File "./vboxshell2.py", line 1172, in runCommandArgs
    return ci[1](ctx, args)
  File "./vboxshell2.py", line 632, in stats3Cmd
    vb.openSession(session, mach.id )
  File "/home/isv/home/diplom/src/VirtualBox_wrappers.py", line 1047,
in openSession
    val=self.mgr.getPort().IVirtualBox_openSession(req)
  File "/home/isv/home/diplom/src/VirtualBox_services.py", line 644,
in IVirtualBox_openSession
    response = self.binding.Receive(IVirtualBox_openSessionResultMsg.typecode)
  File "/usr/lib/pymodules/python2.6/ZSI/client.py", line 536, in Receive
    return _Binding.Receive(self, replytype, **kw)
  File "/usr/lib/pymodules/python2.6/ZSI/client.py", line 455, in Receive
    raise FaultException(msg)
FaultException: VirtualBox error: A session for the machine 'winvm2'
is currently open (or being closed) (0x2159738887)
<VirtualBox_services_types.RuntimeFault_Holder object at 0x938706c>
vbox> quit
===

while vboxwebsrv outs the following:
===
240: accepted connection from IP=192.168.3.101 socket=10...
-- entering __vbox__IMachine_USCOREgetId
   findRefFromId(): looking up objref 92429ce44c1e2314-0000000000000034
   findRefFromId(): sessid 92429CE44C1E2314, objid 34
   calling COM method COMGETTER(Id)
   done calling COM method
   convert COM output "id" back to caller format
   done converting COM output "id" back to caller format
-- leaving __vbox__IMachine_USCOREgetId, rc: 0x0 (0)
Request served
241: accepted connection from IP=192.168.3.101 socket=10...
-- entering __vbox__IVirtualBox_USCOREopenSession
   findRefFromId(): looking up objref 92429ce44c1e2314-000000000000002d
   findRefFromId(): sessid 92429CE44C1E2314, objid 2D
   findRefFromId(): looking up objref 92429ce44c1e2314-000000000000002c
   findRefFromId(): sessid 92429CE44C1E2314, objid 2C
   calling COM method OpenSession
   error, raising SOAP exception
API return code:            0x80BB0007 (VBOX_E_INVALID_OBJECT_STATE)
COM error info result code: 0x80BB0007
COM error info text:        A session for the machine 'winvm2' is
currently open (or being closed)
-- leaving __vbox__IVirtualBox_USCOREopenSession, rc: 0x80BB0007 (-2135228409)
#### SOAP FAULT: VirtualBox error: A session for the machine 'winvm2'
is currently open (or being closed) (0x2159738887) [SOAP-ENV:Client]
Request served
===


In my opinion, note about statisticsUpdateInterval method mandatory
call should be added to SDK Reference either.
Anyway, big thanks for making the code working.

Thanks.

2010/2/16 Nikolay Igotti <Nikolay.Igotti at sun.com>:
>   Igor,
>
> Your code sample misses important piece of initialization, namely it shall
> read as:
>
>  console = session.console
>  guest = console.guest
>  guest.statisticsUpdateInterval = 10
>  ^^^^^^^^ this setter initializes statistics gathering
>  guestadd_ver1 = guest.additionsVersion
>  print guestadd_ver1
>
>  cpu = 0
>  threads = guest.getStatistic( cpu, ctx['ifaces'].GuestStatisticType_Threads
> )
>   ^^^^^^^^^^^ Also please use symbolic constants, not raw numbers.
>
>
> After adding this piece of code guest statistic collection works for me with
> Win XP guests and current additions build. To avoid further problems like
> that, I'll add command to print guest stats into
> vboxshell.py
>
> Thanks,
>  Nikolay
>
> Igor Shkodyrev wrote:
>>
>> Sander, yes i know, as i mentioned, now i'm trying to get it working
>> under WinXP as guest OS with Guest Additions installed.
>>
>> Klaus,
>> how can i make statistics to get updated by the Guest Additions? I
>> already set the GuestStatisticsUpdateInterval to 1 seconds, but still
>> have no success.
>>
>> By the way, when i try to receive my VM statistics using "VBoxManage
>> showvminfo
>> winvm2 --machinereadable" and "VBoxManage showvminfo winvm2
>> --statistics" command, i don't get anything useful related to
>> statistics except "StatGuestSample=0"
>>
>> I do receive some general info like vmname, ostype and so on, but i
>> don't get anything statistic's-related [nothing of GuestStatisticType
>> SDK's list (MemoryLoad, PhysMemTotal, PhysMemAvailable and so on)]
>> except "StatGuestSample=0" (or string "Guest statistics for sample 0:"
>> in --statistics case) while i guess i should...
>>
>> I'm trying to get it working on WinXP as host + WinXP as guest. Vb is
>> latest (3.1.4), GA - ver.1.4
>> Vbox.log has been attached.
>>
>> 2010/2/16 Sander van Leeuwen <Sander.Vanleeuwen at sun.com>:
>>
>>>
>>> Another important detail: guest statistics are only implemented in the
>>> windows guest additions.
>>>
>>> Klaus Espenlaub wrote:
>>>
>>>>
>>>> Igor Shkodyrev wrote:
>>>>
>>>>>
>>>>> But does the getStatistic method work for python bindings at all?
>>>>> I already spent a bunch of time trying to get this method working for
>>>>> all kinds of hosts/guests combinations (Ubuntu/WinXP as host +
>>>>> Ubuntu/WinXP as guest) and couldn't succeed in it, i get the mentioned
>>>>> errors.
>>>>>
>>>>
>>>> What does make you think the python bindings are special in any way?
>>>> They're autogenerated like the others, with some manually written glue
>>>> code
>>>> which can certainly handle getStatistic.
>>>>
>>>> You get an error clearly saying that the arguments you're passing are
>>>> incorrect.
>>>>
>>>> The API code implements exactly 4 parameter validity checks:
>>>> * first parameter must be 0
>>>> * second parameter must be a valid guest statistic type
>>>> * third parameter must be a valid pointer (automatically true for
>>>> python)
>>>> * finally if the guest statistic is not available, i.e. because it
>>>> hasn't
>>>> been updated by the guest additions
>>>>
>>>> I suspect the last condition is what you're running into.
>>>>
>>>> The API you're insisting on using hasn't been adapted to guest SMP
>>>> support
>>>> so far, that's why there is the CPU number = 0 check. No client has
>>>> called
>>>> this API in quite some time.
>>>>
>>>> Klaus
>>>>
>>>>
>>>>>
>>>>> 2010/1/29 Klaus Espenlaub <Klaus.Espenlaub at sun.com>:
>>>>>
>>>>>>
>>>>>> Igor Shkodyrev schrieb:
>>>>>>
>>>>>>>
>>>>>>> Hello,
>>>>>>> my Vbox v3.1.2 is running on Linux Ubuntu Desktop 9.10 as a host
>>>>>>> system, as a guest system i use Ubuntu Server 9.10 with Guest
>>>>>>> Additions installed.
>>>>>>> I tried to write a function on Python which returns information about
>>>>>>> the OS running inside the virtual machine, for this purpose i was
>>>>>>> going to use methods of IGuest interface.
>>>>>>>
>>>>>>
>>>>>> The statistics stuff was only implemented for Windows guests. For
>>>>>> others
>>>>>> it's still on the todo list (low priority).
>>>>>>
>>>>>> So the behavior you see is about as good as it gets. The only thing I
>>>>>> can't
>>>>>> explain is the odd error code you get.
>>>>>>
>>>>>> Klaus
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> At first i tried to modify existing vboxshell.py script in order to
>>>>>>> implement own function 'stats3':
>>>>>>>
>>>>>>> ----
>>>>>>> def stats3Cmd(ctx, args):
>>>>>>> print args
>>>>>>> vers = ctx['vb'].version
>>>>>>> print "Version is", vers
>>>>>>>
>>>>>>> if (len(args) < 2):
>>>>>>> print "usage: stats3 [vmname|uuid]"
>>>>>>> return 0
>>>>>>>
>>>>>>> mach = argsToMach(ctx,args)
>>>>>>> if mach == None:
>>>>>>> return 0
>>>>>>> os = ctx['vb'].getGuestOSType(mach.OSTypeId)
>>>>>>> print " Name [name]: %s" %(mach.name)
>>>>>>> print " ID [n/a]: %s" %(mach.id)
>>>>>>> print " OS Type [n/a]: %s" %(os.description)
>>>>>>>
>>>>>>> manager = ctx['mgr']
>>>>>>> vb = ctx['vb']
>>>>>>> session = manager.getSessionObject(vb)
>>>>>>> if mach.sessionState == ctx['ifaces'].SessionState_Open:
>>>>>>> vb.openExistingSession(session, mach.id )
>>>>>>> else:
>>>>>>> vb.openSession(session, mach.id )
>>>>>>>
>>>>>>> console = session.console
>>>>>>> guest = console.guest
>>>>>>> guestadd_ver1 = guest.additionsVersion
>>>>>>> print guestadd_ver1
>>>>>>>
>>>>>>> cpu = 0
>>>>>>> threads = guest.getStatistic( cpu, 4 )
>>>>>>> print threads
>>>>>>>
>>>>>>> return 0
>>>>>>>
>>>>>>> ----
>>>>>>>
>>>>>>> after execution this function i've got the following traceback:
>>>>>>> ----
>>>>>>> $ python vboxshell2.py
>>>>>>> Running VirtualBox version 3.1.2
>>>>>>> vbox> stats3 ubuntusrv1
>>>>>>> ['stats3', 'ubuntusrv1']
>>>>>>> Version is 3.1.2
>>>>>>> Name [name]: ubuntusrv1
>>>>>>> ID [n/a]: 1c58fc27-ed25-4e82-b041-47c312296b82
>>>>>>> OS Type [n/a]: Ubuntu
>>>>>>> 65540
>>>>>>> 0x80070057 (Invalid argument value (NS_ERROR_INVALID_ARG))
>>>>>>> Traceback (most recent call last):
>>>>>>> File "vboxshell2.py", line 1258, in interpret
>>>>>>> done = runCommand(ctx, cmd)
>>>>>>> File "vboxshell2.py", line 1177, in runCommand
>>>>>>> return runCommandArgs(ctx, args)
>>>>>>> File "vboxshell2.py", line 1170, in runCommandArgs
>>>>>>> return ci[1](ctx, args)
>>>>>>> File "vboxshell2.py", line 642, in stats3Cmd
>>>>>>> threads = guest.getStatistic( cpu, 4 )
>>>>>>> File "<XPCOMObject method 'getStatistic'>", line 3, in getStatistic
>>>>>>> Exception: 0x80070057 (Invalid argument value (NS_ERROR_INVALID_ARG))
>>>>>>> vbox>
>>>>>>> ----
>>>>>>>
>>>>>>> after this i tried to implement this function to work over
>>>>>>> vboxwebsrv,
>>>>>>> but .. no luck again:
>>>>>>> ----
>>>>>>> $ python vboxtests.py
>>>>>>>
>>>>>>> Version is 3.1.2
>>>>>>> revision is 56127
>>>>>>> host is Linux
>>>>>>> home folder /home/isv/.VirtualBox
>>>>>>> machs_list:ubuntusrv1
>>>>>>>
>>>>>>> Traceback (most recent call last):
>>>>>>> File "vboxtests.py", line 90, in <module>
>>>>>>> main()
>>>>>>> File "vboxtests.py", line 85, in main
>>>>>>> machineInfo(manager, machine)
>>>>>>> File "vboxtests.py", line 61, in machineInfo
>>>>>>> memory_available = guest.getStatistic( cpu, 4 )
>>>>>>> File "/home/isv/home/diplom/src/VirtualBox_wrappers.py", line 4114,
>>>>>>> in getStatistic
>>>>>>> val=self.mgr.getPort().IGuest_getStatistic(req)
>>>>>>> File "/home/isv/home/diplom/src/VirtualBox_services.py", line 3746,
>>>>>>> in IGuest_getStatistic
>>>>>>> response =
>>>>>>> self.binding.Receive(IGuest_getStatisticResultMsg.typecode)
>>>>>>> File "/usr/lib/pymodules/python2.6/ZSI/client.py", line 536, in
>>>>>>> Receive
>>>>>>> return _Binding.Receive(self, replytype, **kw)
>>>>>>> File "/usr/lib/pymodules/python2.6/ZSI/client.py", line 455, in
>>>>>>> Receive
>>>>>>> raise FaultException(msg)
>>>>>>> ZSI.FaultException: VirtualBox error: (0x0)
>>>>>>> <VirtualBox_services_types.RuntimeFault_Holder object at 0xa9fa28c>
>>>>>>> ----
>>>>>>>
>>>>>>> the following output fragment in vboxwebsrv was printed while
>>>>>>> executing the getStatistic method:
>>>>>>> ---
>>>>>>> 25: accepted connection from IP=127.0.0.1 socket=9...
>>>>>>> -- entering __vbox__IGuest_USCOREgetStatistic
>>>>>>> findRefFromId(): looking up objref 41f8a9570158f2dd-0000000000000007
>>>>>>> findRefFromId(): sessid 41F8A9570158F2DD, objid 7
>>>>>>> calling COM method GetStatistic
>>>>>>> error, raising SOAP exception
>>>>>>> API return code: 0x80070057 (NS_ERROR_INVALID_ARG)
>>>>>>> COM error info result code: 0x0
>>>>>>> COM error info text: <NULL>
>>>>>>> -- leaving __vbox__IGuest_USCOREgetStatistic, rc: 0x80070057
>>>>>>> (-2147024809)
>>>>>>> #### SOAP FAULT: VirtualBox error: (0x0) [SOAP-ENV:Client]
>>>>>>> Request served
>>>>>>> ---
>>>>>>>
>>>>>>>
>>>>>>> was anyone able to implement any function with use of getStatistic
>>>>>>> method?
>>>>>>> if yes, any example of getStatistic use will be very appreciated.
>>>>>>>
>>>>>>> Thanks.
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> vbox-dev mailing list
>>>>>>> vbox-dev at virtualbox.org
>>>>>>> http://vbox.innotek.de/mailman/listinfo/vbox-dev
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> Dr. Klaus Espenlaub
>>>>>> Sun Microsystems GmbH
>>>>>> Werkstrasse 24
>>>>>> 71384 Weinstadt
>>>>>> Germany
>>>>>>
>>>>>> =====================================================================
>>>>>> Sitz der Gesellschaft:
>>>>>> Sun Microsystems GmbH, Sonnenallee 1, D-85551 Kirchheim-Heimstetten
>>>>>> Amtsgericht Muenchen: HRB 161028
>>>>>> Geschaeftsfuehrer: Thomas Schroeder, Wolfgang Engels, Wolf Frenkel
>>>>>> Vorsitzender des Aufsichtsrates: Martin Haering
>>>>>> =====================================================================
>>>>>>
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> vbox-dev mailing list
>>>>> vbox-dev at virtualbox.org
>>>>> http://vbox.innotek.de/mailman/listinfo/vbox-dev
>>>>>
>>>>
>>>>
>>>
>>> --
>>> Kind regards / Mit freundlichen Gruessen / Met vriendelijke groet
>>>
>>> --
>>>
>>> Sun Microsystems GmbH        Sander van Leeuwen
>>> Werkstrasse 24               Senior Staff Engineer, VirtualBox
>>> 71384 Weinstadt, Germany     mailto:Sander.Vanleeuwen at sun.com
>>>
>>>
>>> ================================================
>>> Sitz der Gesellschaft:
>>> Sun Microsystems GmbH, Sonnenallee 1, D-85551 Kirchheim-Heimstetten
>>> Amtsgericht M nchen: HRB 161028
>>> Gesch„ftsf hrer: Thomas Schr”der, Wolfgang Engels
>>> Vorsitzender des Aufsichtsrates: Martin H„ring
>>> ================================================
>>>
>>>
>>
>> >
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> vbox-dev mailing list
>> vbox-dev at virtualbox.org
>> http://vbox.innotek.de/mailman/listinfo/vbox-dev
>
>




More information about the vbox-dev mailing list