Virtualizor has logging enabled by default. For auditing the IP address usage you can use the IP Logs API.
These logs are related to the IP address that are added on the admin panel. Virtualizor logs the IP address if it is used while creating or editing the VPS alongwith the email of the enduser.
The IP Logs are stored indefinitely on the server and can be removed from the admin panel or by using the Delete IP Logs API
HTTP Request
https://hostname:4085/index.php?act=iplogs&vpsid=VPSID&ip=IP&page=PAGE&reslen=RESLEN
Parameters
Name | Method | Value | Description | Required |
---|---|---|---|---|
act | GET | iplogs | The action will return the ip logs | Yes |
ip | GET | text | The logs will be returned on the basis of the ip | No |
vpsid | GET | Int | The logs will be returned on the basis of the vps 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 |
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);
$page = 1;
$reslen = 20;
$post = array();
$post['vpsid'] = '74';
$post['ip'] = '';
$output = $admin->iplogs($page, $reslen, $post);
print_r(json_encode($output));
?>
Output
{
"title": "IP Logs",
"current_status": null,
"iplogs": [
{
"iplid": "191",
"ipid": "408",
"ip": "10.0.0.2",
"vpsid": "74",
"uid": "57",
"email": "samplemail@gmail.com",
"cloud_uid": "0",
"cloud_email": "0",
"time": "1536261694",
"date": "1536261694"
},
{
"iplid": "189",
"ipid": "408",
"ip": "10.0.0.2",
"vpsid": "74",
"uid": "57",
"email": "samplemail@gmail.com",
"cloud_uid": "0",
"cloud_email": "0",
"time": "1536157269",
"date": "1536157269"
}
],
"timenow": 1536687535,
"time_taken": "0.205"
}