API Get Bandwidth Stats

From Virtualizor Wiki
Jump to: navigation, search
NOTE
This is OLD API Documentation. Click on the following link for New API Documentation
Admin API

Get Bandwidth 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);

    $post = array();
    $post['year'] = '2013';
    $post['month'] = '11';

    $output = $admin->bandwidth($post);
    print_r($output);
?>

Returns: <syntaxhighlight lang="php"> Array (

   [title] => Bandwidth Usage
   [bandwidth] => Array
       (
           [limit] => 507003.95
           [used] => 507002.95
           [usage] => Array
               (
                   [1] => 1426.66
                   [2] => 4930.06
                   [3] => 6.03
                   [4] => 4.82
                   [5] => 23.88
                   [6] => 28.44
                   [7] => 248.02
                   [8] => 1124.27
                   [9] => 2809.81
                   [10] => 86.51
                   [11] => 12446.72
                   [12] => 4571.61
                   [13] => 1029.73
                   [14] => 60.57
                   [15] => 3696.27
                   [16] => 3529.97
                   [17] => 10450.41
                   [18] => 86310.22
                   [19] => 126333.43
                   [20] => 51398.71
                   [21] => 41306.46
                   [22] => 30604.55
                   [23] => 30416.95
                   [24] => 35234.36
                   [25] => 21336.03
                   [26] => 19058.07
                   [27] => 14833.88
                   [28] => 835.61
                   [29] => 2275.39
                   [30] => 585.51
               )
           [in] => Array
               (
                   [usage] => Array
                       (
                           [1] => 1325.57
                           [2] => 4761.99
                           [3] => 4.98
                           [4] => 3.8
                           [5] => 15.86
                           [6] => 13.46
                           [7] => 219.27
                           [8] => 402.23
                           [9] => 2691.2
                           [10] => 38.53
                           [11] => 12080.05
                           [12] => 4324.7
                           [13] => 946.15
                           [14] => 21.38
                           [15] => 166.11
                           [16] => 103.92
                           [17] => 230.72
                           [18] => 27308.24
                           [19] => 63681.67
                           [20] => 25663.65
                           [21] => 12618.25
                           [22] => 14098.21
                           [23] => 11340.89
                           [24] => 17196.86
                           [25] => 10470.7
                           [26] => 9006.44
                           [27] => 6701.38
                           [28] => 375.11
                           [29] => 1487.33
                           [30] => 139.98
                       )
                   [used] => 227438.63
                   [limit] => 227439.63
                   [free] => 1
                   [limit_gb] => 222.10901367188
                   [used_gb] => 222.11
                   [free_gb] => 0.0009765625
                   [percent] => 99.999560322887
                   [percent_free] => 0.00043967711343385
               )
           [out] => Array
               (
                   [usage] => Array
                       (
                           [1] => 101.09
                           [2] => 168.08
                           [3] => 1.05
                           [4] => 1.01
                           [5] => 8.02
                           [6] => 14.98
                           [7] => 28.75
                           [8] => 722.04
                           [9] => 118.61
                           [10] => 47.98
                           [11] => 366.66
                           [12] => 246.91
                           [13] => 83.58
                           [14] => 39.19
                           [15] => 3530.17
                           [16] => 3426.05
                           [17] => 10219.69
                           [18] => 59001.98
                           [19] => 62651.77
                           [20] => 25735.06
                           [21] => 28688.21
                           [22] => 16506.34
                           [23] => 19076.06
                           [24] => 18037.5
                           [25] => 10865.33
                           [26] => 10051.63
                           [27] => 8132.51
                           [28] => 460.5
                           [29] => 788.07
                           [30] => 445.52
                       )
                   [used] => 279564.34
                   [limit] => 279565.34
                   [free] => 1
                   [limit_gb] => 273.01302734375
                   [used_gb] => 273.01
                   [free_gb] => 0.0009765625
                   [percent] => 99.999642301868
                   [percent_free] => 0.00035769813239028
               )
           [free] => 1
           [limit_gb] => 495.12
           [used_gb] => 495.12
           [free_gb] => 0
           [percent] => 100
           [percent_free] => 0
       )
   [month] => Array
       (
           [yr] => 2013
           [month] => 11
           [mth_txt] => Nov
           [days] => 30
           [prev] => 201310
           [next] => 201312
       )
   [band] => 
   [timenow] => 1403008712
   [time_taken] => 0.017

)