Get Virtualizor

Server Monitoring


Use the Server Monitoring API to get the various advance details such as RAM, CPU, Disk etc. of the server by simply passing a server ID. This API response is based on three different parameters which will be explained below.


HTTP Request

https://hostname:4085/index.php?act=performance&changeserid=SERVERID


Parameters

Name          Type           ValueDescription  Required            
actGETperformance
The action specified to perform the operation and return data of the serverYes
serveridGETServer IDProvide server id of which you want the information.Yes
your_preferenceGETtextThere are 3 options available as described below, default, network_stats and live_stats.No

  • default:  When no parameters are passed ,  no live data are present in API response. All static information such as Disks info, Ram specifications and CPU specification are fetched.
$output['disks']; // All disks present on the node
$output['ram_specs']; // Ram Specification
$output['cpu_specs']; // CPU Specification 
$output['disks_df']; // Each Disk partition sizes
$output['disks_inodes']; // Each Disks inodes


  • live_stats:  When this parameter is passed you get the live data of the server in API response. This response consist of live data such as node's cpu usage, ram usage, disks smart health, top cpu and ram consuming processes, active running virtualizor's scripts and disk's IO.
$output['perfomance']['cpu']; // Cpu usage
$output['perfomance']['ram']; // Ram usage
$output['binaries_not_found']; // Missing binaries
$output['filter_ps_cpu']; // list top 10 process consuming cpu
$output['filter_ps_ram']; // list top 10 process consuming RAM
$output['crons']; // List of running scripts and their process ID
$output['get_disk_io']; // List each disk's partition IO 


  • network_stats: With this parameter, the API response will fetch details such as Interfaces present on the nodes and their up/down speed.
$output['interface_speed']; // interfaces and their up/down speed. (JSON encoded)

Sample Code

<?php

    require_once('/usr/local/virtualizor/sdk/admin.php');

    $key =  'your_api_key';
    $pass = 'your_api_pass';
    $ip = 'your_server_ip';

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

    $serverid = 3;
    $your_preference = 'live_stats'; 
$output = $admin->performance($serverid,$your_preference); print_r(json_encode($output)); ?>

Output

{
	"title": "Server Monitoring",
	"perfomance": {
		"cpu_model": " Intel(R) Xeon(R) CPU E3-1220 v6 @ 3.00GHz",
		"cpu": 6.8200000000000003,
		"ram": 55.060000000000002
	},
	"hypervisor": "",
	"disks": [
	],
	"disk_health": [
	],
	"not_supported": 0,
	"binaries_not_found": [
		"\/sbin\/gdisk"
	],
	"binary_count": 1,
	"filter_ps_cpu": {
		"1": [
			"27370     1 \/usr\/libexec\/qemu-kvm -name 11.2 16.7",
			"27370",
			"1",
			"\/usr\/libexec\/qemu-kvm -name",
			"11.2",
			"16.7"
		],
		"2": [
			"17885     1 \/usr\/libexec\/qemu-kvm -name 27.9  3.7",
			"17885",
			"1",
			"\/usr\/libexec\/qemu-kvm -name",
			"27.9",
			"3.7"
		],
		"3": [
			"1792  1400 \/usr\/local\/emps\/bin\/mysqld   0.5  1.8",
			"1792",
			"1400",
			"\/usr\/local\/emps\/bin\/mysqld  ",
			"0.5",
			"1.8"
		],
		"4": [
			"15215     1 \/usr\/libexec\/qemu-kvm -name  1.4  1.2",
			"15215",
			"1",
			"\/usr\/libexec\/qemu-kvm -name ",
			"1.4",
			"1.2"
		],
		"5": [
			"14431     1 \/usr\/libexec\/qemu-kvm -name  0.2  0.4",
			"14431",
			"1",
			"\/usr\/libexec\/qemu-kvm -name ",
			"0.2",
			"0.4"
		],
		"6": [
			"17903     2 [vhost-17885]                0.0  0.3",
			"17903",
			"2",
			"[vhost-17885]               ",
			"0.0",
			"0.3"
		],
		"7": [
			"3090     1 \/usr\/libexec\/qemu-kvm -name  1.4  0.2",
			"3090",
			"1",
			"\/usr\/libexec\/qemu-kvm -name ",
			"1.4",
			"0.2"
		],
		"8": [
			"13277  1375 php-fpm: pool index          0.1  0.2",
			"13277",
			"1375",
			"php-fpm: pool index         ",
			"0.1",
			"0.2"
		],
		"9": [
			"29876  1388 nginx: worker process        0.0  0.2",
			"29876",
			"1388",
			"nginx: worker process       ",
			"0.0",
			"0.2"
		],
		"10": [
			"1650     1 \/usr\/libexec\/qemu-kvm -name  1.6  0.1",
			"1650",
			"1",
			"\/usr\/libexec\/qemu-kvm -name ",
			"1.6",
			"0.1"
		]
	},
	"filter_ps_ram": {
		"1": [
			"1     0 \/sbin\/init                   0.0  0.0",
			"1",
			"0",
			"\/sbin\/init                  ",
			"0.0",
			"0.0"
		],
		"2": [
			"2     0 [kthreadd]                   0.0  0.0",
			"2",
			"0",
			"[kthreadd]                  ",
			"0.0",
			"0.0"
		],
		"3": [
			"3     2 [migration\/0]                0.0  0.0",
			"3",
			"2",
			"[migration\/0]               ",
			"0.0",
			"0.0"
		],
		"4": [
			"4     2 [ksoftirqd\/0]                0.0  0.0",
			"4",
			"2",
			"[ksoftirqd\/0]               ",
			"0.0",
			"0.0"
		],
		"5": [
			"5     2 [stopper\/0]                  0.0  0.0",
			"5",
			"2",
			"[stopper\/0]                 ",
			"0.0",
			"0.0"
		],
		"6": [
			"6     2 [watchdog\/0]                 0.0  0.0",
			"6",
			"2",
			"[watchdog\/0]                ",
			"0.0",
			"0.0"
		],
		"7": [
			"7     2 [migration\/1]                0.0  0.0",
			"7",
			"2",
			"[migration\/1]               ",
			"0.0",
			"0.0"
		],
		"8": [
			"8     2 [stopper\/1]                  0.0  0.0",
			"8",
			"2",
			"[stopper\/1]                 ",
			"0.0",
			"0.0"
		],
		"9": [
			"9     2 [ksoftirqd\/1]                0.0  0.0",
			"9",
			"2",
			"[ksoftirqd\/1]               ",
			"0.0",
			"0.0"
		],
		"10": [
			"10     2 [watchdog\/1]                 0.0  0.0",
			"10",
			"2",
			"[watchdog\/1]                ",
			"0.0",
			"0.0"
		]
	},
	"crons": {
		"cron.php": {
			"active": [
			],
			"pid": [
			]
		},
		"cronm.php": {
			"active": [
			],
			"pid": [
			]
		},
		"cronh.php": {
			"active": [
			],
			"pid": [
			]
		},
		"billing_unsuspend.php": {
			"active": [
			],
			"pid": [
			]
		},
		"billing.php": {
			"active": [
			],
			"pid": [
			]
		},
		"restorevps_plan.php": {
			"active": [
			],
			"pid": [
			]
		},
		"sync_config.php": {
			"active": [
			],
			"pid": [
			]
		},
		"createtemplate.php": {
			"active": [
			],
			"pid": [
			]
		},
		"databasebackups.php": {
			"active": [
			],
			"pid": [
			]
		},
		"db_restore.php": {
			"active": [
			],
			"pid": [
			]
		},
		"download_iso.php": {
			"active": [
			],
			"pid": [
			]
		},
		"sync_media.php": {
			"active": [
			],
			"pid": [
			]
		},
		"sync_backup_plans.php": {
			"active": [
			],
			"pid": [
			]
		},
		"backupnow_plan.php": {
			"active": [
			],
			"pid": [
			]
		},
		"vpsbackups_plan.php": {
			"active": [
			],
			"pid": [
			]
		},
		"migrate2_master.php": {
			"active": [
			],
			"pid": [
			]
		},
		"migrate2.php": {
			"active": [
			],
			"pid": [
			]
		},
		"calculate_bandwidth.php": {
			"active": [
			],
			"pid": [
			]
		},
		"deletevs.php": {
			"active": [
			],
			"pid": [
			]
		},
		"rebuild.php": {
			"active": [
			],
			"pid": [
			]
		},
		"powercron.php": {
			"active": [
			],
			"pid": [
			]
		},
		"send_mail.php": {
			"active": [
			],
			"pid": [
			]
		},
		"addvs.php": {
			"active": [
			],
			"pid": [
			]
		}
	},
	"get_disk_io": {
		"1": [
			"sda",
			" 6.38",
			" 0.07",
			" 0.11",
			"1286823",
			"2184056"
		],
		"2": [
			"sda1",
			"0.00",
			" 0.00",
			" 0.00",
			"129"
		],
		"3": [
			"sda2",
			"5.65",
			" 0.07",
			" 0.11",
			"1286493",
			"2184056"
		]
	},
	"interface_speed": null,
	"ram_specs": null,
	"cpu_specs": null,
	"disks_df": null,
	"disks_inodes": null,
	"month": null,
	"timenow": 1645002977,
	"time_taken": "1.066"
}
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list