]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: hlua_fcn: add Proxy.get_srv_act() and Proxy.get_srv_bck()
authorAurelien DARRAGON <adarragon@haproxy.com>
Mon, 3 Apr 2023 09:00:18 +0000 (11:00 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 5 May 2023 14:28:32 +0000 (16:28 +0200)
Proxy.get_srv_act: number of active servers that are eligible for LB
Proxy.get_srv_bck: number of backup servers that are eligible for LB

doc/lua-api/index.rst
src/hlua_fcn.c

index 42c7fa65e96e93826dcca6591ca1f4c9994801cb..f75c6b3af742f2d4cfbed1f589ab12c8b44f48cf 100644 (file)
@@ -1097,6 +1097,24 @@ Proxy class
    proxy.
   :returns: a string "tcp", "http", "health" or "unknown"
 
+.. js:function:: Proxy.get_srv_act(px)
+
+  Returns the number of current active servers for the current proxy that are
+  eligible for LB.
+
+  :param class_proxy px: A :ref:`proxy_class` which indicates the manipulated
+   proxy.
+  :returns: an integer
+
+.. js:function:: Proxy.get_srv_bck(px)
+
+  Returns the number backup servers for the current proxy that are eligible
+  for LB.
+
+  :param class_proxy px: A :ref:`proxy_class` which indicates the manipulated
+   proxy.
+  :returns: an integer
+
 .. js:function:: Proxy.get_stats(px)
 
   Returns a table containing the proxy statistics. The statistics returned are
index 3540cbdbb0b14a33fa4df28f925bfb6a5a5f6a11..2d86f20137047970cd340808718a5c5ffe3ff39e 100644 (file)
@@ -1808,6 +1808,24 @@ int hlua_proxy_shut_bcksess(lua_State *L)
        return 0;
 }
 
+int hlua_proxy_get_srv_act(lua_State *L)
+{
+       struct proxy *px;
+
+       px = hlua_check_proxy(L, 1);
+       lua_pushinteger(L, px->srv_act);
+       return 1;
+}
+
+int hlua_proxy_get_srv_bck(lua_State *L)
+{
+       struct proxy *px;
+
+       px = hlua_check_proxy(L, 1);
+       lua_pushinteger(L, px->srv_bck);
+       return 1;
+}
+
 int hlua_fcn_new_proxy(lua_State *L, struct proxy *px)
 {
        struct listener *lst;
@@ -1832,6 +1850,8 @@ int hlua_fcn_new_proxy(lua_State *L, struct proxy *px)
        hlua_class_function(L, "shut_bcksess", hlua_proxy_shut_bcksess);
        hlua_class_function(L, "get_cap", hlua_proxy_get_cap);
        hlua_class_function(L, "get_mode", hlua_proxy_get_mode);
+       hlua_class_function(L, "get_srv_act", hlua_proxy_get_srv_act);
+       hlua_class_function(L, "get_srv_bck", hlua_proxy_get_srv_bck);
        hlua_class_function(L, "get_stats", hlua_proxy_get_stats);
 
        /* Browse and register servers. */