Use the Kill Processes API to kill a specific process or multiple processes on the server. The API call will execute kill -9 PID
on the server to kill the process using the process ID. This process ID can obtained by the List Processes API. After killing the process, the currently running processes are returned by the API. You kill processes on both master as well as slave server.
HTTP Request
https://hostname:4085/index.php?act=processes
Parameters
Name | Method | Value | Description | Required |
---|---|---|---|---|
act | GET | processes | The action will list all the processes running the system | Yes |
action | POST | text | This specifies what action to be performed on the selected process | Yes |
sel_proc | POST | array | This specifies if one or more process needs to be killed | Yes |
changeserid | GET | Int | The server ID whose processes need to be killed, default is zero | No |
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['sel_proc'] = array(44,54,1239);
$post['action'] = 'kill';
$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": "516",
"TT": "?",
"STAT": "Ss",
"TIME": "00:05:57",
"COMMAND": "init [3]"
}, {
"PID": "2",
"USER": "root",
"%CPU": "0.0",
"%MEM": "0.0",
"RSS": "0",
"TT": "?",
"STAT": "S",
"TIME": "00:00:01",
"COMMAND": "[kthreadd]"
}, {
"PID": "3",
"USER": "root",
"%CPU": "0.4",
"%MEM": "0.0",
"RSS": "0",
"TT": "?",
"STAT": "S",
"TIME": "05:17:42",
"COMMAND": "[ksoftirqd\/0]"
}],
"timenow": 1482578623,
"time_taken": "1.155"
}