Common subdirectories: motion-20060112-051001/debian and motion-20060112-051001-StatisticsDataPatch/debian diff -u motion-20060112-051001/motion.c motion-20060112-051001-StatisticsDataPatch/motion.c --- motion-20060112-051001/motion.c 2006-01-11 22:10:02.000000000 -0600 +++ motion-20060112-051001-StatisticsDataPatch/motion.c 2006-01-12 22:02:42.000000000 -0600 @@ -21,6 +21,7 @@ #include "event.h" #include "picture.h" #include "rotate.h" +#include /** * tls_key_threadnr @@ -100,6 +101,9 @@ cnt->pipe=-1; cnt->mpipe=-1; + cnt->total_diffs=0; + cnt->total_frames=0; + // /* Here are the pointers required to be set */ // #ifdef HAVE_MYSQL // cnt->database=NULL; @@ -409,6 +413,8 @@ /* Store thread number in TLS. */ pthread_setspecific(tls_key_threadnr, (void *)((unsigned long)cnt->threadnr)); + + syscall(SYS_getpid, cnt->pid); cnt->diffs = 0; cnt->currenttime_tm = mymalloc(sizeof(struct tm)); @@ -1230,6 +1236,15 @@ motion_log(-1, 0, "%s", msg); } + + /***** MOTION LOOP - STATISTICS SECTION *****/ + + /* Tally diffs for statistics. */ + cnt->total_diffs+=cnt->diffs; + + /* Tally update count of total frames viewed. */ + cnt->total_frames++; + /***** MOTION LOOP - SNAPSHOT FEATURE SECTION *****/ diff -u motion-20060112-051001/motion.h motion-20060112-051001-StatisticsDataPatch/motion.h --- motion-20060112-051001/motion.h 2006-01-11 22:10:02.000000000 -0600 +++ motion-20060112-051001-StatisticsDataPatch/motion.h 2006-01-12 22:00:23.000000000 -0600 @@ -292,6 +292,11 @@ int pause; int missing_frame_counter; /* counts failed attempts to fetch picture frame from camera */ + unsigned long total_diffs; /* for statistics, how many pixels different so far? */ + unsigned long total_frames; /* for statistics, how many frames seen so far? */ + + unsigned int pid; /* for statistics, our pid. */ + #ifdef __freebsd__ int tuner_dev; #endif diff -u motion-20060112-051001/webhttpd.c motion-20060112-051001-StatisticsDataPatch/webhttpd.c --- motion-20060112-051001/webhttpd.c 2006-01-11 22:10:02.000000000 -0600 +++ motion-20060112-051001-StatisticsDataPatch/webhttpd.c 2006-01-12 23:08:01.000000000 -0600 @@ -1640,6 +1640,8 @@ sprintf(res,"Thread %d
\n", y, y); send_template(client_socket, res); } + sprintf(res,"Statistics\n"); + send_template(client_socket, res); send_template_end_client(client_socket); } else { send_template_ini_client_raw(client_socket); @@ -1649,6 +1651,33 @@ sprintf(res, "%d\n", y); send_template_raw(client_socket, res); } + sprintf(res,"Statistics\n"); + send_template_raw(client_socket, res); + } + } + else if (! (strcmp (url, "/statistics/")) ) { + int y=0; + if (cnt[0]->conf.control_html_output) { + send_template_ini_client(client_socket,ini_template); + for (y=0; yAll "); + } else { + sprintf(res,"Thread %d ", y, y); + } + send_template(client_socket, res); + sprintf(res,"Frames=%lu Diff=%d Threshold=%d Total=%lu Events=%d Pid=%u
\n", cnt[y]->total_frames, cnt[y]->diffs, cnt[y]->threshold, cnt[y]->total_diffs, cnt[y]->event_nr-1, cnt[y]->pid); + send_template(client_socket, res); + } + sprintf(res,"<- back\n"); + send_template(client_socket, res); + send_template_end_client(client_socket); + } else { + send_template_ini_client_raw(client_socket); + for (y=0; ytotal_frames, cnt[y]->diffs, cnt[y]->threshold, cnt[y]->total_diffs, cnt[y]->event_nr-1, cnt[y]->pid); + send_template_raw(client_socket, res); + } } } else {