Login Logs

Logging in Virtualizor is enabled by default. The time period for the retention of the Login logs can be set in the Master Settings of the Admin panel or using the master configurations API.

Use the Login Logs API to retrieve data about the login activities of all of your account’s users. The API response contains the list of the login activity details. The details provide information about the login activity such as IP address of the login location and time of login. To filter or limit the size of the list you can pass in one or more query parameters.

HTTP Request

https://hostname:4085/index.php?act=loginlogs&username=USERNAME&ip=IP&page=PAGE&reslen=RESLEN

Parameters

NameMethodValueDescriptionRequired
actGETloginlogsThe action will return the loginlogsYes
usernameGETtextThe logs returned on the basis of usernameNo
ipGETtextThe logs returned on the basis of IP addressNo
reslenGETIntNumber of records to be returned, default is 50No
pageGETIntPage number, each page show 50 recordsNo

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['username'] = 'root';
    $post['ip'] = '';

    $output = $admin->loginlogs($page, $reslen , $post);

    print_r(json_encode($output));

?>

Output

{
    "title": "Login Logs",
    "loginlogs": [
        {
            "username": "root",
            "vpsid": "0",
            "time": "1536668301",
            "status": "1",
            "ip": "192.168.1.188"
        },
        {
            "username": "root",
            "vpsid": "0",
            "time": "1536589554",
            "status": "1",
            "ip": "192.168.1.188"
        }
    ],
    "timenow": 1536684609,
    "time_taken": "0.210"
}
Was this helpful to you?