Balancer API Documentation

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 Balancer:

 

Common Commands

The most common 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:

 

 

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 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:

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:

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 –


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 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 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 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 Balancer from running

 

snaptHA.start

Start the Balancer if it is not running

 

snaptHA.configDump

Get a dump of the full Balancer config file. This can be replaced onto another server using the snaptHA.saveConfig method.