Changeset: f2e4cc083c5d for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f2e4cc083c5d Modified Files: clients/mapiclient/eventparser.c clients/mapiclient/stethoscope.c monetdb5/mal/mal_profiler.c Branch: default Log Message:
Merged heads. diffs (127 lines): diff --git a/clients/mapiclient/eventparser.c b/clients/mapiclient/eventparser.c --- a/clients/mapiclient/eventparser.c +++ b/clients/mapiclient/eventparser.c @@ -20,6 +20,7 @@ char *malvalues[MAXMALARGS]; int malsize; int debug=0; char *currentquery=0; +int eventcounter = 0; #ifndef HAVE_STRPTIME extern char *strptime(const char *, const char *, struct tm *); @@ -182,6 +183,7 @@ keyvalueparser(char *txt, EventRecord *e resetEventRecord(ev); memset(malvariables, 0, sizeof(malvariables)); memset(malvalues, 0, sizeof(malvalues)); + ev->eventnr= eventcounter++; return 0; } if( *c == '}'){ @@ -202,7 +204,6 @@ keyvalueparser(char *txt, EventRecord *e *c = 0; } else val =c; - if( strstr(key,"event")) { ev->eventnr= atol(val); return 0;} if( strstr(key,"clk")){ ev->clk = atol(val); return 0; diff --git a/clients/mapiclient/stethoscope.c b/clients/mapiclient/stethoscope.c --- a/clients/mapiclient/stethoscope.c +++ b/clients/mapiclient/stethoscope.c @@ -70,7 +70,7 @@ static stream *conn = NULL; static char hostname[128]; static char *filename = NULL; -static int beat = 50; +static int beat = 0; static int json = 0; static Mapi dbh; static MapiHdl hdl = NULL; diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c --- a/monetdb5/mal/mal_profiler.c +++ b/monetdb5/mal/mal_profiler.c @@ -63,30 +63,16 @@ static struct{ // The heart beat events should be sent to all outstanding channels. static void logjsonInternal(char *logbuffer) { - char buf[BUFSIZ], *s; - size_t len, lenhdr; + size_t len; - s = strchr(logbuffer,(int) ':'); - if( s == NULL){ - return; - } len = strlen(logbuffer); MT_lock_set(&mal_profileLock); - snprintf(buf,BUFSIZ,"%d",eventcounter); - strncpy(s+1, buf,strlen(buf)); - if (eventstream) { // upon request the log record is sent over the profile stream - if( eventcounter == 0){ - snprintf(buf,BUFSIZ,"%s\n",monet_characteristics); - lenhdr = strlen(buf); - (void) mnstr_write(eventstream, buf, 1, lenhdr); - } (void) mnstr_write(eventstream, logbuffer, 1, len); (void) mnstr_flush(eventstream); } - eventcounter++; MT_lock_unset(&mal_profileLock); } @@ -131,7 +117,7 @@ renderProfilerEvent(MalBlkPtr mb, MalStk /* make profile event tuple */ lognew(); - logadd("{%s\"event\": ,%s",prettify,prettify); // fill in later with the event counter + logadd("{%s",prettify); // fill in later with the event counter #ifdef HAVE_CTIME_R3 tbuf = ctime_r(&clk, ctm, sizeof(ctm)); @@ -355,7 +341,7 @@ getCPULoad(char cpuload[BUFSIZ]){ // identify core processing len += snprintf(cpuload, BUFSIZ, "[ "); for ( cpu = 0; cpuload && cpu < 255 && corestat[cpu].user; cpu++) { - len +=snprintf(cpuload + len, BUFSIZ - len, " %.2f ",corestat[cpu].load); + len +=snprintf(cpuload + len, BUFSIZ - len, "%c %.2f", (cpu?',':' '), corestat[cpu].load); } (void) snprintf(cpuload + len, BUFSIZ - len, "]"); return 0; @@ -382,7 +368,7 @@ profilerHeartbeatEvent(char *alter) clk = clock.tv_sec; lognew(); - logadd("{\n\"event\": ,%s",prettify); // fill in later with the event counter + logadd("{%s",prettify); // fill in later with the event counter #ifdef HAVE_CTIME_R3 tbuf = ctime_r(&clk, ctm, sizeof(ctm)); #else @@ -393,7 +379,8 @@ profilerHeartbeatEvent(char *alter) #endif #endif tbuf[19]=0; - logadd("\"time\":\"%s.%06ld\",%s",tbuf+11, (long)clock.tv_usec, prettify); + logadd("\"user\":\"heartbeat\",%s", prettify); + logadd("\"ctime\":\"%s.%06ld\",%s",tbuf+11, (long)clock.tv_usec, prettify); logadd("\"rss\":"SZFMT ",%s", MT_getrss()/1024/1024, prettify); #ifdef HAVE_SYS_RESOURCE_H getrusage(RUSAGE_SELF, &infoUsage); @@ -456,6 +443,7 @@ openProfilerStream(stream *fd, int mode) if (myname == 0){ myname = putName("profiler", 8); eventcounter = 0; + logjsonInternal(monet_characteristics); } if( eventstream) closeProfilerStream(); @@ -504,6 +492,7 @@ startProfiler(void) malProfileMode = 1; sqlProfiling = TRUE; MT_lock_unset(&mal_profileLock); + logjsonInternal(monet_characteristics); return MAL_SUCCEED; } _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list