Use the Hight Availability API to get the status of the HA cluster and Ha resource status. For more information, you can refer this Server Clustering guide.
HTTP Request
https://hostname:4085/index.php?act=ha
Parameters
Name | Method | Value | Description | Required |
---|---|---|---|---|
act | GET | ha | This action will retrieve the status of HA Cluster | Yes |
get_ha_stats | GET | Int | If you have multiple HA cluster, you will need to provide the server group ID for this option. | Yes |
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);
$output = $admin->ha();
print_r(json_encode($output));
?>
Output
{
"title":"High Availability",
"ha_cluster":{
"16":{
"cluster_name":"HA_Group_1",
"node_status":{
"ha2":1,
"ha3":1,
"ha4":1
},
"ha_resources":{
"resource_v1001_4csljb16ilhzegay":{
"status":"Started",
"node":"ha4",
"vps_name":"v1001"
}
}
}
},
"timenow":1554815727,
"time_taken":"1.267"
}