Tasks are activities performed on the server by Virtualizor. These include the tasks that have been executed on the server, currently running, not yet started etc. You can monitor operations like creation of VPS, rebuilding of the VPS, backing up of VPS, restoration of VPS, installation of recipes, installation of control panel etc. for complete list of actions, please refer below table. The search tasks API allows you monitor a particular tasks by using the task's actid, action, status, vpsid, order or username. The API response will contain lists of "tasks" that are listed according to the actid, which is filtered as per the passed parameters.
HTTP Request
https://hostname:4085/index.php?act=tasks&actid=ACTID&vpsid=VPSID&username=USERNAME&action=0&status=STATUS&order=ORDER&page=PAGE&reslen=RESLEN
Parameters
Name | Method | Value | Description | Required |
---|---|---|---|---|
act | GET | tasks | The action will return the tasks | Yes |
actid | GET | Int | The tasks will returned on the basis of action ID | No |
reslen | GET | Int | Number of records to be returned, default is 50 | No |
page | GET | Int | Page number, each page show 50 records | No |
vpsid | GET | Int | The tasks will returned on the basis of vpsid | No |
username | GET | Int | The tasks will returned on the basis of username | No |
action | GET | Int | The tasks will returned on the basis of action, refer below table | No |
status | GET | Int | The tasks will returned on the basis of status, values can be (1 for In progress, 2 for completed, 3 for Updated, -1 for errored) | No |
order | GET | Int | The tasks will returned on the basis of order (ASC/DESC) | No |
Action
Values | Name |
---|---|
addvs | Creating VPS |
addvs_restore | Creating VPS for Restore |
rebuildvs | Rebuilding VPS |
vpsbackups | Backing up VPS |
restorevps | Restoring VPS |
migrate2 | Migrating VPS |
multimigrateprog | Multiple Migrate |
clone2 | Cloning VPS |
multicloneprog | Multiple Clone |
deletevs | Deleting VPS |
createtemplate | Creating Template |
fstab_handle | FS Tab Handle |
editxcpvs | Edit XCP VPS |
resizevps | Resizing VPS |
multivirt | Enabling Multivirt |
getos | Downloading OS |
change_dnsnameserver | Changing DNS Nameserver |
changepassword | Changing VPS Password |
install_cp | Install Control panel |
hostname | Changing VPS Hostname |
install_recipe | Install Recipe |
bandwidth_unsuspend | Unsuspend Bandwidth |
suspend_callback | Suspend Callback |
unsuspend_callback | Unsuspend Callback |
editvps_callback | Edit VPS Callback |
terminate_callback | Terminate VPS Callback |
get_crt | Lets Encrypt Install Certificate |
renew_crt | Lets Encrypt Renew Certificate |
cron_crt | Lets Encrypt Renew Certificate Cron Task |
haproxy_cron | HAProxy Rebuild |
vpsbackups_plan | VPS Backups |
restorevps_plan | VPS Restore |
addsshkeys | Adding SSH Keys |
installxentools | Installing Xenserver Tools |
dbbackups | Database Backup |
install_script | Installing Apps |
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);
$post = array();
$page = 1;
$reslen = 20;
$post['actid'] = 484; //You can use any variable to search.
$post['action'] = 0; //The current output is based on "actid"
$post['status'] = '';
$post['vpsid'] = '';
$post['username'] = '';
$post['order'] = '';
$output = $admin->tasks($page, $reslen,$post);
print_r(json_encode($output));
?>
Output
{
"title": "Tasks List",
"tasks": {
"484": {
"actid": "484",
"slaveactid": "0",
"uid": "0",
"vpsid": "0",
"serid": 0,
"action": "getos",
"data": "a:1:{s:2:\"os\";a:1:{i:0;a:5:{s:4:\"osid\";i:100008;s:10:\"inprogress\";i:0;s:4:\"done\";i:1;s:6:\"failed\";i:0;s:7:\"err_msg\";s:19:\"Download successful\";}}}",
"time": "1536081131",
"status_txt": "Task Completed",
"status": "1",
"progress": "100",
"started": "September 4, 2018, 5:12 pm",
"updated": "September 4, 2018, 5:13 pm",
"ended": "September 4, 2018, 5:13 pm",
"proc_id": "0",
"ip": "192.168.1.188",
"internal": "0",
"email": "root",
"os": [
{
"osid": 100008,
"inprogress": 0,
"done": 1,
"failed": 0,
"err_msg": "Download successful"
}
],
"server_name": "localhost",
"action_txt": "Downloading OS"
}
},
"logs_data": null,
"l_common_logs": "The logs shown are the last operation performed for this task by virtualizor",
"timenow": 1536151384,
"time_taken": "0.255"
}