Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

can anybody help me to display details about the VM using PHP code. am using Ubuntu server and used KVM as hypervisor. Am trying to display cores, ram, memory alloted each VM.

i have tried all the shell commands in php using shell_exec and exec.

Without installing any tool.

share|improve this question
add comment

1 Answer 1

You can install libvirt php extension to communicate wit libvirtd. See the instructions here.

http://libvirt.org/compiling.html

Once installed you can tryout some sample examples like :

<?php
 print_r( libvirt_version() );
?>

Sample Output of above code will be something like:

Array
(
    [libvirt.release] => 0
    [libvirt.minor] => 0
    [libvirt.major] => 1
    [connector.version] => 0.4.5
    [connector.major] => 0
    [connector.minor] => 4
    [connector.release] => 5
)
php

Refer http://libvirt.org/php/examples.html for more examples.

The complete API reference can be found here: http://libvirt.org/php/api-reference.html

Hope this helps

share|improve this answer
    
is it possible to have php code alone to get the output. i dont want any tool to be installed –  Poorni Ma Oct 31 '12 at 6:22
1  
Its not a tool its a PHP extension. –  aneeshep Dec 7 '12 at 12:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.