Module haproxy.stats

Stats socket client.

Functions

parse_info (data[, sep=':']) Parse HAProxy info output to a table.
parse_stats (csv[, sep=']) Convert HAProxy stats CSV output to a table.

Tables

stats_types HAProxy stats types.

Class Client

Client.new (address[, stats[, stats]]) Create a new HAProxy client.
Client.tcp () Create a new TCP Socket instance.
Client:disable_server (backend, server) Place backend/server in maintenace.
Client:enable_server (backend, server) Place backend/server in traffic.
Client:execute (command) Execute an HAProxy stats command.
Client:get_backend (id_or_name) Show a specific backend.
Client:get_backends () List all backends.
Client:get_frontend (id_or_name) Retrieve a specific frontend.
Client:get_frontends () List all frontends.
Client:get_server (backend, id_or_name) Retrieve a specific server.
Client:get_servers (backend) Retrieve all servers belonging to a backend.
Client:get_state (backend, server) Retrieve a server's current state.
Client:get_weight (backend, server) Retrieve the current and initial server weights.
Client:info () Returns table of parsed HAProxy instance information.
Client:set_weight (backend, server, weight) Set a server's weight.
Client:stats () Returns table of parsed stats results.


Functions

parse_info (data[, sep=':'])
Parse HAProxy info output to a table. The JSON representation of this table would be a sorted hash.

Parameters:

  • data string key-value data
  • sep string key-value separator (default ':')

Returns:

    table parsed data
parse_stats (csv[, sep='])
Convert HAProxy stats CSV output to a table. The JSON representation of this table would be an array of hashes.

Parameters:

Returns:

    table parsed data

Tables

stats_types
HAProxy stats types. These are integer codes used by the stats interface (specifically show stat) to represent the source of each datum.

Fields:

  • FRONTEND frontend
  • BACKEND backend
  • SERVER server
  • SOCKET socket

See also:

Class Client

HAProxy stats socket client
Client.new (address[, stats[, stats]])
Create a new HAProxy client.

Parameters:

  • address string stats interface address
  • stats int connection timeout in seconds (optional)
  • stats int connection timeout in seconds (optional)
Client.tcp ()
Create a new TCP Socket instance. If running inside HAProxy, use the LuaSocket-compatible Socket class. Otherwise, use LuaSocket.

Returns:

    Socket

See also:

Client:disable_server (backend, server)
Place backend/server in maintenace.

Parameters:

Client:enable_server (backend, server)
Place backend/server in traffic.

Parameters:

Client:execute (command)
Execute an HAProxy stats command. Used by higher-level methods such as Client:stats.

Parameters:

  • command string command to execute

Returns:

    string string response
Client:get_backend (id_or_name)
Show a specific backend.

Parameters:

  • id_or_name backend ID or name

Returns:

    table
Client:get_backends ()
List all backends.

Returns:

    table
Client:get_frontend (id_or_name)
Retrieve a specific frontend.

Parameters:

  • id_or_name frontend ID or name

Returns:

    table
Client:get_frontends ()
List all frontends.

Returns:

    table
Client:get_server (backend, id_or_name)
Retrieve a specific server.

Parameters:

  • backend string backend name
  • id_or_name integer server ID or string name

Returns:

    table
Client:get_servers (backend)
Retrieve all servers belonging to a backend.

Parameters:

Returns:

    table
Client:get_state (backend, server)
Retrieve a server's current state.

Parameters:

Returns:

    table
Client:get_weight (backend, server)
Retrieve the current and initial server weights.

Parameters:

Returns:

    table
Client:info ()
Returns table of parsed HAProxy instance information.

Returns:

    table parsed HAProxy instance info

See also:

Client:set_weight (backend, server, weight)
Set a server's weight.

Parameters:

  • backend string
  • server string
  • weight integer weight (1) or string percentage (100%)
Client:stats ()
Returns table of parsed stats results.

Returns:

    table parsed stats results

See also:

generated by LDoc 1.4.3 Last updated 2016-06-26 17:50:20