[vbox-dev] getStatistic method issues

Nikolay Igotti Nikolay.Igotti at Sun.COM
Tue Feb 16 13:38:08 GMT 2010


    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