diff --git a/doc/lua-api/index.rst b/doc/lua-api/index.rst index cbbab5f7e..fa16519b6 100644 --- a/doc/lua-api/index.rst +++ b/doc/lua-api/index.rst @@ -270,6 +270,19 @@ Core class :param string filename: the filename that reference the map entries. :param string key: the key which will be deleted. +.. js:function:: core.get_info() + + **context**: body, init, task, action, sample-fetch, converter + + Returns HAProxy core informations. We can found information like the uptime, + the pid, memory pool usage, tasks number, ... + + These information are also returned by the management sockat via the command + "show info". See the management socket documentation fpor more information + about the content of these variables. + + :returns: an array of values. + .. js:function:: core.now() **context**: body, init, task, action diff --git a/src/hlua_fcn.c b/src/hlua_fcn.c index 69d6ee652..f577be4a3 100644 --- a/src/hlua_fcn.c +++ b/src/hlua_fcn.c @@ -28,6 +28,10 @@ /* Contains the class reference of the concat object. */ static int class_concat_ref; +#define STATS_LEN (INF_TOTAL_FIELDS) + +static struct field stats[STATS_LEN]; + /* This function gets a struct field and convert it in Lua * variable. The variable is pushed at the top of the stak. */ @@ -293,6 +297,21 @@ static int hlua_asctime_date(lua_State *L) return hlua_parse_date(L, parse_asctime_date); } +static int hlua_get_info(lua_State *L) +{ + int i; + + stats_fill_info(stats, STATS_LEN); + + lua_newtable(L); + for (i=0; i