- 28 Dec 2021
- 3 Minutes to read
-
Print
-
DarkLight
Snapt Aria Load Balancer API Documentation
- Updated on 28 Dec 2021
- 3 Minutes to read
-
Print
-
DarkLight
Please ensure you have read the beginners guide in order to understand the commands below.
All commands are sent to the snaptHA module. Below is an example URL string for the Snapt Aria Load Balancer:
http://localhost:8080/api/xxx-xxx-xxx-xxx/SNPxxxxxxxxx/snaptHA
Common Commands
The most common Load Balancer commands are available below. You can call system.listMethods to see a detailed list of all the available methods.
Stats
Statistics and runtime information can be fetched with the snaptHA.socketGet command. You may pass “info”, “stat” or “sess” to the method as seen below in Python:
print(str(proxy.snaptHA.socketGet("info")));
{
'SslFrontendSessionReuse_pct': '0',
'Uptime': '0d 3h24m48s',
'Release_date': '2014/06/24',
'Run_queue': '1',
'Maxpipes': '0',
'CumConns': '285',
'Uptime_sec': '12288',
'MaxSessRate': '0',
'SslBackendKeyRate': '0',
'SessRate': '0',
'MaxSslRate': '0',
'SslCacheMisses': '0',
'MaxConnRate': '0',
'SslFrontendKeyRate': '0',
'Maxconn': '4096',
'CumReq': '285',
'Idle_pct': '100',
'SslBackendMaxKeyRate': '0',
...
}
Adding and Deleting Groups, Frontends and Backends
You may add a group, frontend or backend by submitting it’s configuration with the addGroup, addFrontend or addBackend methods. The specific raw config of the group can be discovered by setting up your group in the virtual Load Balancer UI and going to the Backups -> Export section. There you will see the raw config to send. Below is an example of an HTTP group being added:
groupData = [1,2,3];
groupData[0] = 'listen myGroup 0.0.0.0:80';
groupData[1] = 'mode http';
groupData[2] = 'maxconn 2000';
proxy.snaptHA.addGroup(groupData);
This creates a group named myGroup, listening on 0.0.0.0 port 80 in http mode with 2000 maximum connections. We then need to add servers to this group or backend:
group = 'myGroup'; # group or backend name
server = 'www0'; # server name
type = 'listen'; # listen (group) or backend
details = 'www0 10.10.0.50:80 check fall 3 rise 5 inter 2000 weight 10'; # server line
print(str(proxy.snaptHA.addServer(group, server, type, details)));
You may also edit servers or groups by sending a deleteGroup, deleteBackend, deleteFrontend, deleteServer and then an add again.
Applying Changes
To restart you can issue the snaptHA.reconfigure call. You can check if it needs a restart by sending the snaptHA.needRestart call.
Additional Commands
You can see all the available commands by sending a system.listMethods() call to the snaptHA API –
['system.listMethods', 'system.methodHelp', 'system.methodSignature', 'system.multicall', 'snaptHA.setPaths', 'snaptHA.getIniFile', 'snaptHA.writeINI', 'snaptHA.replaceInConfig', 'snaptHA.loadConfig', 'snaptHA.saveConfig', 'snaptHA.addServer', 'snaptHA.deleteServer', 'snaptHA.addGroup', 'snaptHA.addFrontend', 'snaptHA.addBackend', 'snaptHA.delGroup', 'snaptHA.editGroup', 'snaptHA.editFrontend', 'snaptHA.editBackend', 'snaptHA.getConfig', 'snaptHA.isRunning', 'snaptHA.checkConfig', 'snaptHA.serverCount', 'snaptHA.needRestart', 'snaptHA.clearRestart', 'snaptHA.makeErrorPages', 'snaptHA.removeOptionFromAll', 'snaptHA.writeSysctls', 'snaptHA.socketGet', 'snaptHA.getCiphers', 'snaptHA.soft_stop', 'snaptHA.soft_start', 'snaptHA.sslSupport', 'snaptHA.compressionSupport', 'snaptHA.reconfigure', 'snaptHA.start', 'snaptHA.takeBackup', 'snaptHA.getBackup', 'snaptHA.restoreBackup', 'snaptHA.previewBackup', 'snaptHA.removeBackup', 'snaptHA.getBackups', 'snaptHA.mtimeSort', 'snaptHA.configDump', 'snaptHA.getUniqueIps', 'snaptHA.suspendAllIP', 'snaptHA.resumeAllIP', 'snaptHA.format']
Command List
system.listMethods
Get a list of the methods available.
**system.methodHelp **
Get help on a specific method, it’s usage etc.
snaptHA.addServer
Add a server to a group or backend. This requires $group, $serverName, $type, $serverString:
- $group – the name of the group of the backend to add the server to
- $serverName – the name of the server, must match in $serverString
- $type – listen for groups, or backend for backends
- $serverString – the server string. Examples of this can be received by adding servers in the UI and doing a config export. The default format is: www0 10.10.0.50:80 check fall 3 rise 5 inter 2000 weight 10
snaptHA.deleteServer
Delete a server from a group or backend. This requires $group, $serverName, $type – see addServer for definitions.
snaptHA.addGroup, snaptHA.addFrontend, snaptHA.addBackend
These commands add groups, frontends, and backends. You can see a full example in the top of this document, under “Adding and Deleting Groups, Frontends and Backends”
snaptHA.editGroup, snaptHA.editFrontend, snaptHA.editBackend
These commands alter an existing group by doing a delete and add. They require the $groupName and then $group as in the addGroup, frontend, and backend adds.
snaptHA.isRunning
Check if the virtual Load Balancer is currently running.
snaptHA.checkConfig
Check the current config for errors. This can be done before a reload/stop/start.
snaptHA.serverCount
Check your license usage (server number) for licenses with restricted amounts.
snaptHA.needRestart
Marker of whether you need to restart the Load Balancer to apply recent changes.
snaptHA.socketGet
Get various statistics from the stats socket. This is detailed at the start of the document in “Stats”
snaptHA.soft_stop, snaptHA.soft_start
Pause and resume a server inside a group. This requires $group and $serverName for both backends and groups.
snaptHA.reconfigure
Do a live reload of the config
snaptHA.stop
Stop the virtual Load Balancer from running
snaptHA.start
Start the Load Balancer if it is not running
snaptHA.configDump
Get a dump of the full Load Balancer config file. This can be replaced onto another server using the snaptHA.saveConfig method.
Please also refer to the developers section of this site for further documentation.