Search Tasks

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

NameMethodValueDescriptionRequired
actGETtasksThe action will return the tasksYes
actidGETIntThe tasks will returned on the basis of action IDNo
reslenGETIntNumber of records to be returned, default is 50No
pageGETIntPage number, each page show 50 recordsNo
vpsidGETIntThe tasks will returned on the basis of vpsidNo
usernameGETIntThe tasks will returned on the basis of usernameNo
actionGETIntThe tasks will returned on the basis of action, refer below tableNo
statusGETIntThe 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
orderGETIntThe tasks will returned on the basis of order (ASC/DESC)No

Action

ValuesName
addvsCreating VPS
addvs_restoreCreating VPS for Restore
rebuildvsRebuilding VPS
vpsbackupsBacking up VPS
restorevpsRestoring VPS
migrate2Migrating VPS
multimigrateprogMultiple Migrate
clone2Cloning VPS
multicloneprogMultiple Clone
deletevsDeleting VPS
createtemplateCreating Template
fstab_handleFS Tab Handle
editxcpvsEdit XCP VPS
resizevpsResizing VPS
multivirtEnabling Multivirt
getosDownloading OS
change_dnsnameserverChanging DNS Nameserver
changepasswordChanging VPS Password
install_cpInstall Control panel
hostnameChanging VPS Hostname
install_recipeInstall Recipe
bandwidth_unsuspendUnsuspend Bandwidth
suspend_callbackSuspend Callback
unsuspend_callbackUnsuspend Callback
editvps_callbackEdit VPS Callback
terminate_callbackTerminate VPS Callback
get_crtLets Encrypt Install Certificate
renew_crtLets Encrypt Renew Certificate
cron_crtLets Encrypt Renew Certificate Cron Task
haproxy_cronHAProxy Rebuild
vpsbackups_planVPS Backups
restorevps_planVPS Restore
addsshkeysAdding SSH Keys
installxentoolsInstalling Xenserver Tools
dbbackupsDatabase Backup
install_scriptInstalling 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"
}
Was this helpful to you?