]> arthur.barton.de Git - netdata.git/commitdiff
disk statistics got proper names; isolated a performance issue with strftime() which...
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Tue, 27 Oct 2015 00:34:26 +0000 (02:34 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Tue, 27 Oct 2015 00:34:26 +0000 (02:34 +0200)
15 files changed:
netdata.start
src/Makefile
src/common.c
src/common.h
src/daemon.c
src/main.c
src/plugin_checks.c
src/plugin_idlejitter.c
src/plugin_nfacct.c
src/plugin_proc.c
src/plugin_tc.c
src/plugins_d.c
src/proc_diskstats.c
src/web_client.c
src/web_server.c

index 1bb3bc304b585a34305b6c28d2b0ea50a44fea4c..b8fa2f9e0f92273524656ad2372c5229336fd914 100755 (executable)
@@ -105,6 +105,10 @@ echo >&2
 # -----------------------------------------------------------------------------
 # run netdata
 
+# avoid extended stat(/etc/localtime)
+# http://stackoverflow.com/questions/4554271/how-to-avoid-excessive-stat-etc-localtime-calls-in-strftime-on-linux
+export TZ=":/etc/localtime"
+
 echo >&2 "Starting netdata..."
 `pwd`/netdata "${@}"
 
index 8c5bbba3278912704c5f3a80df9fbdd34c606992..65cb401d36a9c589089e51aaf95488c4c9948032 100755 (executable)
@@ -37,6 +37,7 @@ COMMON_FLAGS += debug=1
 CFLAGS = -Wall -Wextra -O -ggdb -DBIN_DIR='$(BIN_DIR)' -DCONFIG_DIR='$(CONFIG_DIR)' -DLOG_DIR='$(LOG_DIR)' -DPLUGINS_DIR='$(PLUGINS_DIR)' -fno-omit-frame-pointer
 # CFLAGS := -Wall -Wextra -O -g -DBIN_DIR='$(BIN_DIR)' -DCONFIG_DIR='$(CONFIG_DIR)' -DLOG_DIR='$(LOG_DIR)' -DPLUGINS_DIR='$(PLUGINS_DIR)' -fsanitize=thread -fno-omit-frame-pointer -fPIE
 # libs += -pie -ltsan
+libs += -rdynamic
 else
 CFLAGS := -Wall -Wextra -O3 -DBIN_DIR='$(BIN_DIR)' -DCONFIG_DIR='$(CONFIG_DIR)' -DLOG_DIR='$(LOG_DIR)' -DPLUGINS_DIR='$(PLUGINS_DIR)' -fomit-frame-pointer
 endif
index 825c102235ac16829e4f8cc3e1a354dba60d8da8..4af46b30b0e91f462067fdd49bc3e8d1da737d13 100755 (executable)
@@ -1,6 +1,6 @@
 // enable O_NOATIME
 #define _GNU_SOURCE
-
+#include <sys/syscall.h>
 #include <string.h>
 #include <ctype.h>
 #include <errno.h>
@@ -187,3 +187,9 @@ void get_HZ(void)
 
        hz = (unsigned int) ticks;
 }
+
+pid_t gettid(void)
+{
+       return syscall(SYS_gettid);
+}
+
index 6be1b530ab62d45302c3024025bf952af04ad259..71ef6f691dc43361e0eb92739b706ed8399dd63a 100755 (executable)
@@ -1,4 +1,6 @@
 #include <inttypes.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #ifndef NETDATA_COMMON_H
 #define NETDATA_COMMON_H 1
@@ -34,4 +36,6 @@ extern char *global_host_prefix;
 extern unsigned int hz;
 extern void get_HZ(void);
 
+extern pid_t gettid(void);
+
 #endif /* NETDATA_COMMON_H */
index 787fbc18e938b97a4e16b29a6383ae1343208f11..83e00bb30fe5c21a1037987912c83aa6bf9b22b1 100755 (executable)
@@ -10,6 +10,7 @@
 #include <pthread.h>
 #include <sys/wait.h>
 #include <sys/stat.h>
+#include <execinfo.h>
 
 #include "config.h"
 #include "log.h"
 #include "main.h"
 #include "daemon.h"
 
+#define BACKTRACE_SIZE 4096
+
+void print_backtrace()
+{
+       void *buffer[BACKTRACE_SIZE];
+       int nptrs;
+
+       nptrs = backtrace(buffer, BACKTRACE_SIZE);
+       fprintf(stderr, "\n\nSTACK TRACE (%d addresses):\n\n", nptrs);
+       backtrace_symbols_fd(buffer, nptrs, STDERR_FILENO);
+       fprintf(stderr, "\n\n");
+}
+
 void sig_handler(int signo)
 {
        switch(signo) {
+               case SIGILL:
+               case SIGABRT:
+               case SIGFPE:
+               case SIGSEGV:
+               case SIGBUS:
+               case SIGSYS:
+               case SIGTRAP:
+               case SIGXCPU:
+               case SIGXFSZ:
+                       info("Death signaled exit (signal %d). Errno: %d (%s)", signo, errno, strerror(errno));
+                       print_backtrace();
+                       signal(signo, SIG_DFL);
+                       break;
+
+               case SIGKILL:
                case SIGTERM:
                case SIGQUIT:
                case SIGINT:
                case SIGHUP:
-               case SIGFPE:
-               case SIGSEGV:
+               case SIGUSR1:
+               case SIGUSR2:
                        info("Signaled exit (signal %d). Errno: %d (%s)", signo, errno, strerror(errno));
-                       signal(SIGCHLD, SIG_IGN);
+                       print_backtrace();
                        signal(SIGPIPE, SIG_IGN);
                        signal(SIGTERM, SIG_IGN);
                        signal(SIGQUIT, SIG_IGN);
index 3446b2a16cfa0d23ede970ded42d118ce9d107da..6a341917d936c17c5d359663b7c26fbabd133144 100755 (executable)
@@ -8,6 +8,8 @@
 #include <errno.h>
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <sys/time.h>
+#include <sys/resource.h>
 
 #include "common.h"
 #include "log.h"
@@ -244,6 +246,12 @@ int main(int argc, char **argv)
                debug_flags = strtoull(flags, NULL, 0);
                debug(D_OPTIONS, "Debug flags set to '0x%8llx'.", debug_flags);
 
+               if(debug_flags != 0) {
+                       struct rlimit rl = { RLIM_INFINITY, RLIM_INFINITY };
+                       if(setrlimit(RLIMIT_CORE, &rl) != 0)
+                               info("Cannot request unlimited core dumps for debugging... Proceeding anyway...");
+               }
+
                // --------------------------------------------------------------------
 
                global_host_prefix = config_get("global", "host access prefix", "");
index 6e987e4e3fd648e2f968917e8004f33839a80908..cf02241760276fe9985793397be7d7d9e2fdf007 100755 (executable)
@@ -14,6 +14,8 @@ void *checks_main(void *ptr)
 {
        if(ptr) { ; }
 
+       info("CHECKS thread created with task id %d", gettid());
+
        if(pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL) != 0)
                error("Cannot set pthread cancel type to DEFERRED.");
 
index f18ebb310388fc50a09a79091e1b677097d41e58..bc336fcdb30e4fa7468344114ef6cc0facac5e49 100755 (executable)
@@ -17,6 +17,8 @@ void *cpuidlejitter_main(void *ptr)
 {
        if(ptr) { ; }
 
+       info("CPU Idle Jitter thread created with task id %d", gettid());
+
        if(pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL) != 0)
                error("Cannot set pthread cancel type to DEFERRED.");
 
index ba368f2dc9ee044aeadab7f0ff5b18b6751bda17..f4c191bd5fa3c9113570cb30f9c75439da616d3e 100644 (file)
@@ -76,6 +76,8 @@ static int nfacct_callback(const struct nlmsghdr *nlh, void *data) {
 void *nfacct_main(void *ptr) {
        if(ptr) { ; }
 
+       info("NFACCT thread created with task id %d", gettid());
+
        if(pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL) != 0)
                error("nfacct.plugin: Cannot set pthread cancel type to DEFERRED.");
 
index f1169a26515af0b84e5f865dbcab9a823ca9b21f..8691d2d039f5a3d1e24e8ad5d5b4aad37bf4de01 100755 (executable)
@@ -15,6 +15,8 @@ void *proc_main(void *ptr)
 {
        if(ptr) { ; }
 
+       info("PROC Plugin thread created with task id %d", gettid());
+
        if(pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL) != 0)
                error("Cannot set pthread cancel type to DEFERRED.");
 
index c4fc08ae7040e36382406f6ce116b8c508b5d047..3edcc200951d4a45cbc5196165a8948ec831a173 100755 (executable)
@@ -1,7 +1,7 @@
-#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/types.h>
 
 #include "avl.h"
 #include "log.h"
@@ -437,6 +437,8 @@ void *tc_main(void *ptr)
 {
        if(ptr) { ; }
 
+       info("TC thread created with task id %d", gettid());
+
        if(pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL) != 0)
                error("Cannot set pthread cancel type to DEFERRED.");
 
index a8baf6c73936848b6ad428469920351ef070f115..05d59eb4147bd13b9b2d432e0b472c7a63c8b75c 100755 (executable)
@@ -392,6 +392,8 @@ void *pluginsd_main(void *ptr)
 {
        if(ptr) { ; }
 
+       info("PLUGINS.D thread created with task id %d", gettid());
+
        if(pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL) != 0)
                error("Cannot set pthread cancel type to DEFERRED.");
 
index 5d8cc273c25d001c9788c722cd7da219ae9e952a..21e405324a2d15d1445aab673c6f89e6292f2c3f 100755 (executable)
@@ -19,17 +19,17 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
        static procfile *ff = NULL;
        static char path_to_get_hw_sector_size[FILENAME_MAX + 1] = "";
        static int enable_new_disks = -1;
-       static int do_io = -1, do_ops = -1, do_merged_ops = -1, do_iotime = -1, do_cur_ops = -1, do_util = -1, do_qsize = -1;
+       static int do_io = -1, do_ops = -1, do_mops = -1, do_iotime = -1, do_qops = -1, do_util = -1, do_backlog = -1;
 
        if(enable_new_disks == -1)      enable_new_disks = config_get_boolean("plugin:proc:/proc/diskstats", "enable new disks detected at runtime", 1);
 
-       if(do_io == -1)                 do_io                   = config_get_boolean("plugin:proc:/proc/diskstats", "bandwidth for all disks", 1);
-       if(do_ops == -1)                do_ops                  = config_get_boolean("plugin:proc:/proc/diskstats", "operations for all disks", 1);
-       if(do_merged_ops == -1) do_merged_ops   = config_get_boolean("plugin:proc:/proc/diskstats", "merged operations for all disks", 1);
-       if(do_iotime == -1)             do_iotime               = config_get_boolean("plugin:proc:/proc/diskstats", "i/o time for all disks", 1);
-       if(do_cur_ops == -1)    do_cur_ops              = config_get_boolean("plugin:proc:/proc/diskstats", "current operations for all disks", 1);
-       if(do_util == -1)               do_util                 = config_get_boolean("plugin:proc:/proc/diskstats", "utilization percentage for all disks", 1);
-       if(do_qsize == -1)              do_qsize                = config_get_boolean("plugin:proc:/proc/diskstats", "queue size for all disks", 1);
+       if(do_io == -1)         do_io           = config_get_boolean("plugin:proc:/proc/diskstats", "bandwidth for all disks", 1);
+       if(do_ops == -1)        do_ops          = config_get_boolean("plugin:proc:/proc/diskstats", "operations for all disks", 1);
+       if(do_mops == -1)       do_mops         = config_get_boolean("plugin:proc:/proc/diskstats", "merged operations for all disks", 1);
+       if(do_iotime == -1)     do_iotime       = config_get_boolean("plugin:proc:/proc/diskstats", "i/o time for all disks", 1);
+       if(do_qops == -1)       do_qops         = config_get_boolean("plugin:proc:/proc/diskstats", "queued operations for all disks", 1);
+       if(do_util == -1)       do_util         = config_get_boolean("plugin:proc:/proc/diskstats", "utilization percentage for all disks", 1);
+       if(do_backlog == -1)do_backlog  = config_get_boolean("plugin:proc:/proc/diskstats", "backlog for all disks", 1);
 
        if(!ff) {
                char filename[FILENAME_MAX + 1];
@@ -53,13 +53,13 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
        for(l = 0; l < lines ;l++) {
                char *disk;
                unsigned long long      major = 0, minor = 0,
-                                                       reads = 0,  reads_merged = 0,  readsectors = 0,  readms = 0,
-                                                       writes = 0, writes_merged = 0, writesectors = 0, writems = 0,
-                                                       currentios = 0, iosms = 0, wiosms = 0;
+                                                       reads = 0,  mreads = 0,  readsectors = 0,  readms = 0,
+                                                       writes = 0, mwrites = 0, writesectors = 0, writems = 0,
+                                                       queued_ios = 0, busy_ms = 0, backlog_ms = 0;
 
                unsigned long long      last_reads = 0,  last_readsectors = 0,  last_readms = 0,
                                                        last_writes = 0, last_writesectors = 0, last_writems = 0,
-                                                       last_iosms = 0;
+                                                       last_busy_ms = 0;
 
                words = procfile_linewords(ff, l);
                if(words < 14) continue;
@@ -77,8 +77,8 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
                // Reads and writes which are adjacent to each other may be merged for
            // efficiency.  Thus two 4K reads may become one 8K read before it is
            // ultimately handed to the disk, and so it will be counted (and queued)
-               reads_merged    = strtoull(procfile_lineword(ff, l, 4), NULL, 10);      // rd_merges_or_rd_sec
-               writes_merged   = strtoull(procfile_lineword(ff, l, 8), NULL, 10);      // wr_merges
+               mreads                  = strtoull(procfile_lineword(ff, l, 4), NULL, 10);      // rd_merges_or_rd_sec
+               mwrites                 = strtoull(procfile_lineword(ff, l, 8), NULL, 10);      // wr_merges
 
                // # of sectors read # of sectors written
                // This is the total number of sectors read or written successfully.
@@ -94,19 +94,19 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
                // # of I/Os currently in progress
                // The only field that should go to zero. Incremented as requests are
                // given to appropriate struct request_queue and decremented as they finish.
-               currentios              = strtoull(procfile_lineword(ff, l, 11), NULL, 10);     // ios_pgr
+               queued_ios              = strtoull(procfile_lineword(ff, l, 11), NULL, 10);     // ios_pgr
 
                // # of milliseconds spent doing I/Os
-               // This field increases so long as field currentios is nonzero.
-               iosms                   = strtoull(procfile_lineword(ff, l, 12), NULL, 10);     // tot_ticks
+               // This field increases so long as field queued_ios is nonzero.
+               busy_ms                 = strtoull(procfile_lineword(ff, l, 12), NULL, 10);     // tot_ticks
 
                // weighted # of milliseconds spent doing I/Os
                // This field is incremented at each I/O start, I/O completion, I/O
                // merge, or read of these stats by the number of I/Os in progress
-               // (field currentios) times the number of milliseconds spent doing I/O since the
+               // (field queued_ios) times the number of milliseconds spent doing I/O since the
                // last update of this field.  This can provide an easy measure of both
                // I/O completion time and the backlog that may be accumulating.
-               wiosms                  = strtoull(procfile_lineword(ff, l, 13), NULL, 10);     // rq_ticks
+               backlog_ms              = strtoull(procfile_lineword(ff, l, 13), NULL, 10);     // rq_ticks
 
                int def_enabled = 0;
 
@@ -270,7 +270,7 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
                                }
                                else error("Cannot read sector size for device %s from %s. Assuming 512.", disk, ssfilename);
 
-                               st = rrdset_create(RRD_TYPE_DISK, disk, NULL, disk, "Disk I/O", "kilobytes/s", 2000, update_every, RRDSET_TYPE_AREA);
+                               st = rrdset_create(RRD_TYPE_DISK, disk, NULL, disk, "Disk I/O Bandwidth", "kilobytes/s", 2000, update_every, RRDSET_TYPE_AREA);
 
                                rrddim_add(st, "reads", NULL, sector_size, 1024 * update_every, RRDDIM_INCREMENTAL);
                                rrddim_add(st, "writes", NULL, sector_size * -1, 1024 * update_every, RRDDIM_INCREMENTAL);
@@ -287,7 +287,7 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
                if(do_ops) {
                        st = rrdset_find_bytype("disk_ops", disk);
                        if(!st) {
-                               st = rrdset_create("disk_ops", disk, NULL, disk, "Disk Operations", "operations/s", 2001, update_every, RRDSET_TYPE_LINE);
+                               st = rrdset_create("disk_ops", disk, NULL, disk, "Disk Completed I/O Operations", "operations/s", 2001, update_every, RRDSET_TYPE_LINE);
                                st->isdetail = 1;
 
                                rrddim_add(st, "reads", NULL, 1, 1 * update_every, RRDDIM_INCREMENTAL);
@@ -302,58 +302,58 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
 
                // --------------------------------------------------------------------
 
-               if(do_util) {
-                       st = rrdset_find_bytype("disk_util", disk);
+               if(do_qops) {
+                       st = rrdset_find_bytype("disk_qops", disk);
                        if(!st) {
-                               st = rrdset_create("disk_util", disk, NULL, disk, "Disk Utilization", "%", 2002, update_every, RRDSET_TYPE_AREA);
+                               st = rrdset_create("disk_qops", disk, NULL, disk, "Disk Queued I/O Operations", "operations", 2002, update_every, RRDSET_TYPE_LINE);
                                st->isdetail = 1;
 
-                               rrddim_add(st, "utilization", NULL, 1, 10 * update_every, RRDDIM_INCREMENTAL);
+                               rrddim_add(st, "operations", NULL, 1, 1, RRDDIM_ABSOLUTE);
                        }
                        else rrdset_next_usec(st, dt);
 
-                       last_iosms = rrddim_set(st, "utilization", iosms);
+                       rrddim_set(st, "operations", queued_ios);
                        rrdset_done(st);
                }
 
                // --------------------------------------------------------------------
 
-               if(do_qsize) {
-                       st = rrdset_find_bytype("disk_qsize", disk);
+               if(do_backlog) {
+                       st = rrdset_find_bytype("disk_backlog", disk);
                        if(!st) {
-                               st = rrdset_create("disk_qsize", disk, NULL, disk, "Disk Average Queue Size", "queue size", 2003, update_every, RRDSET_TYPE_AREA);
+                               st = rrdset_create("disk_backlog", disk, NULL, disk, "Disk Backlog", "backlog (ms)", 2003, update_every, RRDSET_TYPE_AREA);
                                st->isdetail = 1;
 
-                               rrddim_add(st, "queue_size", NULL, 1, 1000 * update_every, RRDDIM_INCREMENTAL);
+                               rrddim_add(st, "backlog", NULL, 1, 1000 * update_every, RRDDIM_INCREMENTAL);
                        }
                        else rrdset_next_usec(st, dt);
 
-                       rrddim_set(st, "queue_size", wiosms);
+                       rrddim_set(st, "backlog", backlog_ms);
                        rrdset_done(st);
                }
 
                // --------------------------------------------------------------------
 
-               if(do_cur_ops) {
-                       st = rrdset_find_bytype("disk_cur_ops", disk);
+               if(do_util) {
+                       st = rrdset_find_bytype("disk_util", disk);
                        if(!st) {
-                               st = rrdset_create("disk_cur_ops", disk, NULL, disk, "Current Disk I/O operations", "operations", 2004, update_every, RRDSET_TYPE_LINE);
+                               st = rrdset_create("disk_util", disk, NULL, disk, "Disk Utilization Time", "% of time working", 2004, update_every, RRDSET_TYPE_AREA);
                                st->isdetail = 1;
 
-                               rrddim_add(st, "operations", NULL, 1, 1, RRDDIM_ABSOLUTE);
+                               rrddim_add(st, "utilization", NULL, 1, 10 * update_every, RRDDIM_INCREMENTAL);
                        }
                        else rrdset_next_usec(st, dt);
 
-                       rrddim_set(st, "operations", currentios);
+                       last_busy_ms = rrddim_set(st, "utilization", busy_ms);
                        rrdset_done(st);
                }
 
                // --------------------------------------------------------------------
 
-               if(do_merged_ops) {
-                       st = rrdset_find_bytype("disk_merged_ops", disk);
+               if(do_mops) {
+                       st = rrdset_find_bytype("disk_mops", disk);
                        if(!st) {
-                               st = rrdset_create("disk_merged_ops", disk, NULL, disk, "Disk Merged Operations", "operations/s", 2021, update_every, RRDSET_TYPE_LINE);
+                               st = rrdset_create("disk_mops", disk, NULL, disk, "Disk Merged Operations", "merged operations/s", 2021, update_every, RRDSET_TYPE_LINE);
                                st->isdetail = 1;
 
                                rrddim_add(st, "reads", NULL, 1, 1 * update_every, RRDDIM_INCREMENTAL);
@@ -361,8 +361,8 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
                        }
                        else rrdset_next_usec(st, dt);
 
-                       rrddim_set(st, "reads", reads_merged);
-                       rrddim_set(st, "writes", writes_merged);
+                       rrddim_set(st, "reads", mreads);
+                       rrddim_set(st, "writes", mwrites);
                        rrdset_done(st);
                }
 
@@ -371,7 +371,7 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
                if(do_iotime) {
                        st = rrdset_find_bytype("disk_iotime", disk);
                        if(!st) {
-                               st = rrdset_create("disk_iotime", disk, NULL, disk, "Disk I/O Time", "milliseconds/s", 2022, update_every, RRDSET_TYPE_LINE);
+                               st = rrdset_create("disk_iotime", disk, NULL, disk, "Disk Total I/O Time", "milliseconds/s", 2022, update_every, RRDSET_TYPE_LINE);
                                st->isdetail = 1;
 
                                rrddim_add(st, "reads", NULL, 1, 1 * update_every, RRDDIM_INCREMENTAL);
@@ -392,7 +392,7 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
                        if(do_iotime && do_ops) {
                                st = rrdset_find_bytype("disk_await", disk);
                                if(!st) {
-                                       st = rrdset_create("disk_await", disk, NULL, disk, "Average Wait Time", "ms per operation", 2005, update_every, RRDSET_TYPE_AREA);
+                                       st = rrdset_create("disk_await", disk, NULL, disk, "Average Completed I/O Operation Time", "ms per operation", 2005, update_every, RRDSET_TYPE_AREA);
                                        st->isdetail = 1;
 
                                        rrddim_add(st, "reads", NULL, 1, 1, RRDDIM_ABSOLUTE);
@@ -408,7 +408,7 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
                        if(do_io && do_ops) {
                                st = rrdset_find_bytype("disk_avgsz", disk);
                                if(!st) {
-                                       st = rrdset_create("disk_avgsz", disk, NULL, disk, "Average Operation Size", "kilobytes", 2006, update_every, RRDSET_TYPE_AREA);
+                                       st = rrdset_create("disk_avgsz", disk, NULL, disk, "Average Completed I/O Operation Bandwidth", "kilobytes per operation", 2006, update_every, RRDSET_TYPE_AREA);
                                        st->isdetail = 1;
 
                                        rrddim_add(st, "reads", NULL, sector_size, 1024, RRDDIM_ABSOLUTE);
@@ -427,23 +427,14 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
                                        st = rrdset_create("disk_svctm", disk, NULL, disk, "Average Service Time", "ms per operation", 2007, update_every, RRDSET_TYPE_AREA);
                                        st->isdetail = 1;
 
-                                       rrddim_add(st, "svctm", NULL, -1, 1, RRDDIM_ABSOLUTE);
+                                       rrddim_add(st, "svctm", NULL, 1, 1, RRDDIM_ABSOLUTE);
                                }
                                else rrdset_next_usec(st, dt);
 
-                               rrddim_set(st, "svctm", ((reads - last_reads) + (writes - last_writes)) ? (iosms - last_iosms) / ((reads - last_reads) + (writes - last_writes)) : 0);
+                               rrddim_set(st, "svctm", ((reads - last_reads) + (writes - last_writes)) ? (busy_ms - last_busy_ms) / ((reads - last_reads) + (writes - last_writes)) : 0);
                                rrdset_done(st);
                        }
                }
-
-               // TODO
-               // the differential (readms + writems) / (reads + writes) = average wait time
-               // the differential (readms ) / (reads ) = the average wait time for reads
-               // the differential (writems) / (writes) = the average wait time for writes
-
-               // similarly for bytes to find the average read and write size
-
-               // svctm = % of utilization per request (reads + writes)
        }
        
        return 0;
index 560791753b8392552dbb92a1995f4744241f7fd4..1fd41a1ea1cc739c1d611af550ebed6e53acbf6f 100755 (executable)
@@ -1208,6 +1208,8 @@ void *web_client_main(void *ptr)
        fd_set ifds, ofds, efds;
        int fdmax = 0;
 
+       log_access("%llu: %s port %s connected on thread task id %d", w->id, w->client_ip, w->client_port, gettid());
+
        for(;;) {
                FD_ZERO (&ifds);
                FD_ZERO (&ofds);
@@ -1286,6 +1288,7 @@ void *web_client_main(void *ptr)
                }
        }
 
+       log_access("%llu: %s port %s disconnected from thread task id %d", w->id, w->client_ip, w->client_port, gettid());
        debug(D_WEB_CLIENT, "%llu: done...", w->id);
 
        web_client_reset(w);
index 0b8b6e86918bdaaf957b60f1698b188ea95294ed..f633ca754c9dd33066f80c0cb1091b53613bb5b8 100755 (executable)
@@ -136,6 +136,9 @@ int create_listen_socket6(int port, int listen_backlog)
 void *socket_listen_main(void *ptr)
 {
        if(ptr) { ; }
+
+       info("WEB SERVER thread created with task id %d", gettid());
+
        struct web_client *w;
        struct timeval tv;
        int retval;
@@ -193,8 +196,6 @@ void *socket_listen_main(void *ptr)
                                        error("%llu: Cannot request detach of newly created web client thread.", w->id);
                                        w->obsolete = 1;
                                }
-
-                               log_access("%llu: %s port %s connected", w->id, w->client_ip, w->client_port);
                        }
                        else debug(D_WEB_CLIENT, "LISTENER: select() didn't do anything.");
 
@@ -206,7 +207,6 @@ void *socket_listen_main(void *ptr)
                // cleanup unused clients
                for(w = web_clients; w ; w = w?w->next:NULL) {
                        if(w->obsolete) {
-                               log_access("%llu: %s port %s disconnected", w->id, w->client_ip, w->client_port);
                                debug(D_WEB_CLIENT, "%llu: Removing client.", w->id);
                                // pthread_join(w->thread,  NULL);
                                w = web_client_free(w);