List Processes

Use the List Processes API to list all the processes running on the server, by passing the server ID. This is the output of the ps ax -eo pid,user,pcpu,pmem,rss,tty,stat,time,command command which is executed on the server when the API call is made.

HTTP Request

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

Parameters

NameMethodValueDescriptionRequired
actGETprocessesReturns the list of processes running on the serverYes
changeseridGETIntThe server ID whose processes need to be fetched, default is zeroNo

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();
    $post['changeserid'] = 3;

    $output = $admin->processes($post);

    print_r(json_encode($output));

?>

Output

{
    "title": "List of Processes",
    "processes": [{
        "PID": "1",
        "USER": "root",
        "%CPU": "0.0",
        "%MEM": "0.0",
        "RSS": "1100",
        "TT": "?",
        "STAT": "Ss",
        "TIME": "00:00:01",
        "COMMAND": "\/sbin\/init"
    }, {
        "PID": "2",
        "USER": "root",
        "%CPU": "0.0",
        "%MEM": "0.0",
        "RSS": "0",
        "TT": "?",
        "STAT": "S",
        "TIME": "00:00:00",
        "COMMAND": "[kthreadd]"
    }, {
        "PID": "3",
        "USER": "root",
        "%CPU": "0.0",
        "%MEM": "0.0",
        "RSS": "0",
        "TT": "?",
        "STAT": "S",
        "TIME": "00:01:39",
        "COMMAND": "[migration\/0]"
    }],
    "timenow": "1471413592",
    "time_taken": "0.158"
}
Was this helpful to you?