API Get VPS CPU Stats

From Virtualizor Wiki
Jump to: navigation, search

Get VPS CPU Stats

Example Code

<?php

    require_once('admin.php');

    $key =  'uketenhrhpunty5lhgwkcuxxxxxxxxxx';

    $pass = 'yrsofc3tg3tre7bjpfppspxxxxxxxxxx';

    $ip = 'xxx.xxx.xxx.xxx';

    $admin = new Virtualizor_Admin_API($ip, $key, $pass);

    $output = $admin->vscpu();
    print_r($output);
?>

Returns:

Array
(
    [title] => VPS CPU Utilization
    [vpsusage] => Array
        (
            [1063] => 0.0
            [1005] => 10.0
            [1039] => 97.9
            [997] => 0
            [1056] => 2.0
            [1055] => 8.0
            [1049] => 0.0
            [998] => 0.0
            [1053] => 0.0
            [1003] => 2.0
            [1000] => 2.0
            [1040] => 0.0
            [1041] => 0.0
        )

    [available] => Array
        (
            [manu] => intel
            [limit] => 3100
            [used] => 869.77
            [free] => 2230.23
            [percent] => 28.06
            [percent_free] => 71.94
        )

    [vpses] => Array
        (
            [997] => Array
                (
                    [vpsid] => 997
                    [vps_name] => 1001
                    [serid] => 0
                    [time] => 0
                    [edittime] => 1397556952
                    [virt] => 
                    [uid] => 1
                    [plid] => 0
                    [hostname] => nucdp_donot_delete
                    [osid] => 188
                    [iso] => 
                    [sec_iso] => 
                    [boot] => cda
                    [space] => 55
                    [inodes] => 0
                    [ram] => 4096
                    [burst] => 0
                    [swap] => 2048
                    [cpu] => 0
                    [cores] => 4
                    [cpu_percent] => 0.00
                    [bandwidth] => 0
                    [network_speed] => 0
                    [io] => 0
                    [ubc] => 
                    [acpi] => 1
                    [apic] => 1
                    [pae] => 1
                    [shadow] => 0
                    [vnc] => 1
                    [hvm] => 0
                    [suspended] => 0
                    [rescue] => 0
                    [band_suspend] => 0
                    [tuntap] => 0
                    [ppp] => 0
                    [ploop] => 0
                    [dns_nameserver] => a:2:{i:0;s:7:"4.2.2.1";i:1;s:7:"4.2.2.2";}
                    [osreinstall_limit] => 0
                    [preferences] => 
                    [nic_type] => default
                    [vif_type] => 
                    [virtio] => 0
                    [disk] => 
                    [kvm_cache] => 0
                    [io_mode] => 0
                    [vnc_keymap] => en-us
                    [routing] => 0
                    [mg] => 
                    [webuzo] => 0
                )

            [998] => Array
                (
                    [vpsid] => 998
                    [vps_name] => 1078
                    [serid] => 0
                    [time] => 0
                    [edittime] => 1401971342
                    [virt] => 
                    [uid] => 50
                    [plid] => 0
                    [hostname] => nucdpISO
                    [osid] => 0
                    [iso] => nuCDP-CentOS-LiveCD.iso
                    [sec_iso] => 
                    [boot] => dca
                    [space] => 10
                    [inodes] => 0
                    [ram] => 2048
                    [burst] => 0
                    [swap] => 0
                    [cpu] => 1024
                    [cores] => 4
                    [cpu_percent] => 0.00
                    [bandwidth] => 0
                    [network_speed] => 0
                    [io] => 0
                    [ubc] => 
                    [acpi] => 1
                    [apic] => 1
                    [pae] => 1
                    [shadow] => 0
                    [vnc] => 1
                    [hvm] => 0
                    [suspended] => 0
                    [rescue] => 0
                    [band_suspend] => 0
                    [tuntap] => 0
                    [ppp] => 0
                    [ploop] => 0
                    [dns_nameserver] => a:2:{i:0;s:7:"4.2.2.1";i:1;s:7:"4.2.2.2";}
                    [osreinstall_limit] => 0
                    [preferences] => 
                    [nic_type] => default
                    [vif_type] => 
                    [virtio] => 0
                    [disk] => 
                    [kvm_cache] => 0
                    [io_mode] => 0
                    [vnc_keymap] => en-us
                    [routing] => 0
                    [mg] => 
                    [webuzo] => 0
                )
		.
		.
		.
		.

			
    [timenow] => 1402915286
    [time_taken] => 0.018
)