[bwm-tools-devel] COMMIT - r91 - trunk/bwm_graph
Brought to you by:
nkukard
From: <sv...@li...> - 2006-03-08 08:30:14
|
Author: nkukard Date: 2006-03-08 08:29:30 +0000 (Wed, 08 Mar 2006) New Revision: 91 Modified: trunk/bwm_graph/Makefile.am trunk/bwm_graph/Makefile.in trunk/bwm_graph/graph.c Log: * Fixed log directory, it now corrosponds to the rest of BWM Tools * Better error handling while generating graphs & rrd data * Fixed bug preventing graphing from working Modified: trunk/bwm_graph/Makefile.am =================================================================== --- trunk/bwm_graph/Makefile.am 2006-03-08 06:19:36 UTC (rev 90) +++ trunk/bwm_graph/Makefile.am 2006-03-08 08:29:30 UTC (rev 91) @@ -27,7 +27,7 @@ RRDTOOL_LDADDS=@RRDTOOL_LDADDS@ RRDTOOL_VER=@RRDTOOL_VER@ -LOG_DIR=@localstatedir@/bwm_tools +LOG_DIR=/var/bwm_tools bin_PROGRAMS = bwm_graph bwm_graph_SOURCES = bwm_graph.c graph.c Modified: trunk/bwm_graph/Makefile.in =================================================================== --- trunk/bwm_graph/Makefile.in 2006-03-08 06:19:36 UTC (rev 90) +++ trunk/bwm_graph/Makefile.in 2006-03-08 08:29:30 UTC (rev 91) @@ -200,7 +200,7 @@ RRDTOOL_LIBS = @RRDTOOL_LIBS@ RRDTOOL_LDADDS = @RRDTOOL_LDADDS@ RRDTOOL_VER = @RRDTOOL_VER@ -LOG_DIR = @localstatedir@/bwm_tools +LOG_DIR = /var/bwm_tools bwm_graph_SOURCES = bwm_graph.c graph.c bwm_graph_DEPENDENCIES = $(RRDTOOL_LDADDS) bwm_graph_LDADD = $(top_builddir)/lib/libbwm.la $(RRDTOOL_LDADDS) Modified: trunk/bwm_graph/graph.c =================================================================== --- trunk/bwm_graph/graph.c 2006-03-08 06:19:36 UTC (rev 90) +++ trunk/bwm_graph/graph.c 2006-03-08 08:29:30 UTC (rev 91) @@ -260,14 +260,16 @@ fd = open(filename,O_RDONLY); if (fd < 0) { - fprintf(stderr,"Failed opening file %s: %s\n",filename,strerror(errno)); + printf(" ERROR!\n"); + fprintf(stderr,"ERROR: Failed opening file %s: %s\n",filename,strerror(errno)); return; } // Grab header opRes = read(fd,&fileHeader,sizeof(struct aLogFileHeader_t)); if (opRes != sizeof(struct aLogFileHeader_t)) { - fprintf(stderr,"Error reading header from file %s: %s\n",filename,strerror(errno)); + printf(" ERROR!\n"); + fprintf(stderr,"ERROR: Error reading header from file %s: %s\n",filename,strerror(errno)); close(fd); return; } @@ -281,7 +283,8 @@ opRes = lseek(fd,sizeof(struct aLogFileHeader_t) + (j * sizeof(struct aLogFileEntry_t)),SEEK_SET); if (opRes < 0) { - fprintf(stderr,"Error seeking end %s: %s\n",filename,strerror(errno)); + printf(" ERROR!\n"); + fprintf(stderr,"ERROR: Error seeking end %s: %s\n",filename,strerror(errno)); err = 1; break; } @@ -294,6 +297,7 @@ opRes = read(fd,fileEntry,sizeof(struct aLogFileEntry_t)); if (opRes < 0) { + printf(" ERROR!\n"); fprintf(stderr,"Error reading file entry %s: %s\n",filename,strerror(errno)); err = 1; break; @@ -316,10 +320,10 @@ } // Close file... close(fd); - printf("sorting..."); + printf(" sorting..."); // Sort our list of data... entryList = g_list_sort(entryList,sort_newest); - printf("writing RRD file %s...",rrd_filename); + printf(" generating RRD:%s...",rrd_filename); // Set "static" params snprintf(params[1],BUFFER_SIZE,"%s",rrd_filename); strcpy(params[2],"--template"); @@ -387,19 +391,21 @@ // Get the filename snprintf(filename,MAX_NAMELEN,"%s/%s.dat",LOG_DIR,aSource->flowRef); - printf(" Getting details for %s...",filename); + printf(" Processing %s...",filename); // Open fd = open(filename,O_RDONLY); if (fd < 0) { - fprintf(stderr,"Failed opening file %s: %s\n",filename,strerror(errno)); + printf(" ERROR!\n"); + fprintf(stderr,"ERROR: Failed to open %s: %s\n",filename,strerror(errno)); return; } // Grab header opRes = read(fd,&fileHeader,sizeof(struct aLogFileHeader_t)); if (opRes != sizeof(struct aLogFileHeader_t)) { - fprintf(stderr,"Error reading header from file %s: %s\n",filename,strerror(errno)); + printf(" ERROR!\n"); + fprintf(stderr,"ERROR: Failed to read from %s: %s\n",filename,strerror(errno)); close(fd); return; } @@ -408,7 +414,7 @@ close(fd); snprintf(filename,MAX_NAMELEN,"%s/%s.rrd",LOG_DIR,aSource->flowRef); - printf(" %s ...",filename); + printf(" RRD:%s...",filename); // Create params memset(params[5],'\0',BUFFER_SIZE); memset(params[6],'\0',BUFFER_SIZE); @@ -441,7 +447,7 @@ fprintf(stderr,"Failed to create RRD file %s: %s\n",filename,rrd_get_error()); return; } - printf("done\n"); + printf(" done\n"); i++; } @@ -621,10 +627,8 @@ } g_list_foreach(graphSources,processSourceOptions,NULL); - // Check if we must display our cute little line - if (hasOptions) - ADD_SINGLE_PARAM(params,numParams,"COMMENT:%s\\c","- * - * -"); - ADD_SINGLE_PARAM(params,numParams,"COMMENT:%s\\c","Graph generated by bwm_tools v"PACKAGE_VERSION" (http://bwm-tools.pr.linuxrulz.org)"); + ADD_SINGLE_PARAM(params,numParams,"COMMENT:%s\\c","- * - * -"); + ADD_SINGLE_PARAM(params,numParams,"COMMENT:%s\\c","Graph generated by BWM Tools"); // Call rrd tool optind = 0; opterr = 0; @@ -638,11 +642,12 @@ #endif if (result < 0) { - fprintf(stderr,"Failed to create RRD graph %s: %s\n",options->outputFile,rrd_get_error()); + printf(" ERROR!\n"); + fprintf(stderr,"ERROR: Failed to create RRD graph %s: %s\n",options->outputFile,rrd_get_error()); result = -1; } else - printf("done (%dx%d)\n",xsize,ysize); + printf(" done (%dx%d)\n",xsize,ysize); // Free memory for (i = 0; i < numParams; i++) |