]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] stats: report number of tasks (active and running)
authorWilly Tarreau <w@1wt.eu>
Sat, 21 Mar 2009 17:33:52 +0000 (18:33 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 21 Mar 2009 17:33:52 +0000 (18:33 +0100)
It may be useful for statistics purposes to report the number of
tasks.

include/proto/task.h
src/dumpstats.c
src/task.c

index 54418b64edd80025eb7236b86613ff7abda065ae..19aab61679e375bbc5f17eefd5387719459bd4ca 100644 (file)
@@ -80,6 +80,8 @@
 /* a few exported variables */
 extern unsigned int nb_tasks;     /* total number of tasks */
 extern unsigned int run_queue;    /* run queue size */
+extern unsigned int run_queue_cur;
+extern unsigned int nb_tasks_cur;
 extern unsigned int niced_tasks;  /* number of niced tasks in the run queue */
 extern struct pool_head *pool2_task;
 extern struct eb32_node *last_timer;   /* optimization: last queued timer */
index 990e51f8945f113b746e1822fffb1664375dee0d..fd38f95ddfdd16ab13bdc0ffbb07e5b0d83ebe7c 100644 (file)
@@ -235,6 +235,8 @@ int stats_dump_raw(struct session *s, struct buffer *rep, struct uri_auth *uri)
                                     "CurrConns: %d\n"
                                     "PipesUsed: %d\n"
                                     "PipesFree: %d\n"
+                                    "Tasks: %d\n"
+                                    "Run_queue: %d\n"
                                     "",
                                     global.nbproc,
                                     relative_pid,
@@ -244,7 +246,8 @@ int stats_dump_raw(struct session *s, struct buffer *rep, struct uri_auth *uri)
                                     global.rlimit_memmax,
                                     global.rlimit_nofile,
                                     global.maxsock, global.maxconn, global.maxpipes,
-                                    actconn, pipes_used, pipes_free
+                                    actconn, pipes_used, pipes_free,
+                                    nb_tasks_cur, run_queue_cur
                                     );
                        if (buffer_write_chunk(rep, &msg) >= 0)
                                return 0;
@@ -468,6 +471,7 @@ int stats_dump_http(struct session *s, struct buffer *rep, struct uri_auth *uri)
                             "<b>system limits :</b> memmax = %s%s ; ulimit-n = %d<br>\n"
                             "<b>maxsock = </b> %d ; <b>maxconn = </b> %d ; <b>maxpipes = </b> %d<br>\n"
                             "current conns = %d ; current pipes = %d/%d<br>\n"
+                            "Running tasks : %d/%d<br>\n"
                             "</td><td align=\"center\" nowrap>\n"
                             "<table class=\"lgd\"><tr>\n"
                             "<td class=\"active3\">&nbsp;</td><td class=\"noborder\">active UP </td>"
@@ -496,7 +500,8 @@ int stats_dump_http(struct session *s, struct buffer *rep, struct uri_auth *uri)
                             global.rlimit_memmax ? " MB" : "",
                             global.rlimit_nofile,
                             global.maxsock, global.maxconn, global.maxpipes,
-                            actconn, pipes_used, pipes_used+pipes_free
+                            actconn, pipes_used, pipes_used+pipes_free,
+                            run_queue_cur, nb_tasks_cur
                             );
 
                        if (s->data_ctx.stats.flags & STAT_HIDE_DOWN)
index 8374c127490235578a16f643561638760342bbf8..95a00faed264b309a2e22c534d92c1d47b31a1fa 100644 (file)
@@ -27,6 +27,8 @@ struct pool_head *pool2_task;
 
 unsigned int nb_tasks = 0;
 unsigned int run_queue = 0;
+unsigned int run_queue_cur = 0;    /* copy of the run queue size */
+unsigned int nb_tasks_cur = 0;     /* copy of the tasks count */
 unsigned int niced_tasks = 0;      /* number of niced tasks in the run queue */
 struct eb32_node *last_timer = NULL;  /* optimization: last queued timer */
 
@@ -181,6 +183,8 @@ void process_runnable_tasks(int *next)
        unsigned int max_processed;
        int expire;
 
+       run_queue_cur = run_queue; /* keep a copy for reporting */
+       nb_tasks_cur = nb_tasks;
        max_processed = run_queue;
        if (max_processed > 200)
                max_processed = 200;