Changeset 29

Show
Ignore:
Timestamp:
04/13/07 17:40:49 (16 years ago)
Author:
andreu
Message:

sampling information in rrd filename - optional template first step

Location:
trunk
Files:
10 modified

Legend:

Unmodified
Added
Removed
  • trunk/configure.in

    r28 r29  
    1010CFLAGS="-I/usr/local/include -g -ansi -Wno-long-long -Wall -D _SVID_SOURCE -DSIGSETJMP_IS_BROKEN -D _XOPEN_SOURCE -pedantic -pg" 
    1111 
     12CFLAGS_OPTIMIZE="-O2" 
    1213CFLAGS_CRIHAN="-DCRIHAN" 
    1314CFLAGS_IPV4AGG="-DIPV4AGG" 
    1415CFLAGS_DEBUG="-DDEBUG" 
     16CFLAGS_DEBUGAGG="-DDEBUGAGG" 
    1517                                 
    1618# Checks for programs. 
     
    2628AC_C_VOLATILE 
    2729AC_TYPE_SIZE_T 
     30 
     31AC_ARG_ENABLE(optimize,[  --enable-optimize gcc O2 option compilation default=no], 
     32optimize=$enableval,optimize=no) 
     33if test $optimize = yes ; then 
     34CFLAGS="$CFLAGS $CFLAGS_OPTIMIZE" 
     35fi 
    2836 
    2937AC_ARG_ENABLE(crihan,[  --enable-crihan allow files outputs for CRIHAN tools default=no], 
     
    4553fi 
    4654 
     55AC_ARG_ENABLE(debugagg,[  --enable-debugagg Debug Agg mode definition=no], 
     56debugagg=$enableval,debugagg=no) 
     57if test $debugagg = yes ; then 
     58CFLAGS="$CFLAGS $CFLAGS_DEBUGAGG" 
     59fi 
     60 
    4761AC_SUBST(CFLAGS) 
    4862 
  • trunk/src/dataFlowSet.c

    r28 r29  
    3939{ 
    4040  TplFlowSetPtr tmp; 
     41  TplOptionPtr tmpOpt; 
    4142  FieldPtr pftmp; 
    4243  FieldPtr secondPftmp; 
     
    103104  buffer2[0] = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr));(*myPtrs->offsetV9Ptr)++; 
    104105  data_length = *((unsigned short*)&buffer2); 
    105   if ((tmp=existTplId(myPtrs->currentRouterPtr, myPtrs->currentHeaderV9Ptr->sourceId,  
    106                       (*myPtrs->currentFlowsetIdPtr)))!=NULL) { 
     106  if ( (tmp=existTplId(myPtrs->currentRouterPtr, myPtrs->currentHeaderV9Ptr->sourceId,  
     107                      (*myPtrs->currentFlowsetIdPtr)))!=NULL ) { 
     108#ifdef DEBUG 
     109      fprintf(stderr,"{d"); 
     110#endif 
    107111    pftmp = tmp->lastField; 
    108112    for (; pftmp; pftmp = pftmp->prev) { 
     
    143147    while ( (((*myPtrs->offsetV9Ptr)-48-shift) <= data_length) && (overflow!=1) ) {  
    144148      /*  
    145        * progression in a flow Set  
     149       * progression in a data flow Set  
    146150       * notes: 
    147151       *   48=header ip + header netf 
     
    282286                    ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1; 
    283287                  } 
    284               }        
     288              } 
    285289#ifdef IPV4AGG 
    286290              if ((pftmp->fieldType==8)){ 
     
    805809        pftmp = pftmp->prev; 
    806810      } 
    807     } /* end of the while on one flow record */     
     811    } /* end of the while on one flow record */ 
     812#ifdef DEBUG 
     813    fprintf(stderr,"}"); 
     814#endif 
    808815  }else{ 
    809     /*  
    810      * template unknown, we skip this all the data  
    811      */ 
    812     (*myPtrs->offsetV9Ptr)+=(data_length-4); 
    813     (*myPtrs->currentFlowsetNumberPtr) = myPtrs->currentHeaderV9Ptr->count; 
     816      /*  
     817       * Optional template 
     818       */ 
    814819#ifdef DEBUG 
    815     fprintf(stderr, " U, r: %lu.%lu.%lu.%lu, sourceId: %lu, TID: %hu", 
    816             (myPtrs->pcktPtr->ipH->srcAdd>>24), 
    817             (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), 
    818             (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), 
    819             (myPtrs->pcktPtr->ipH->srcAdd<<24>>24), 
    820             myPtrs->currentHeaderV9Ptr->sourceId,  
    821             (*myPtrs->currentFlowsetIdPtr) 
    822             ); 
    823 #endif 
     820    fprintf(stderr,"<d"); 
     821#endif 
     822    if ((tmpOpt=existTplOptId(myPtrs->currentRouterPtr, myPtrs->currentHeaderV9Ptr->sourceId,  
     823                              (*myPtrs->currentFlowsetIdPtr)))!=NULL) {         
     824             
     825      for ( i=0; i<(tmpOpt->optionScopeLg/4); i++){ 
     826        /* FIXME : today we skip the scope fields, it's bad :( */  
     827        if (pftmp=tmpOpt->lastField) { 
     828          for (j=0; j<pftmp->fieldLength; j++) { 
     829            (*myPtrs->offsetV9Ptr)++;  
     830          } 
     831          pftmp = pftmp->prev; 
     832        } 
     833      } 
     834      while (pftmp != NULL) { 
     835        if (pftmp->fieldLength==1){  
     836          buffer1 = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     837        } 
     838        if (pftmp->fieldLength==2){  
     839          buffer2[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     840          buffer2[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     841        } 
     842        if (pftmp->fieldLength==4){  
     843          buffer4[3]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     844          buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     845          buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     846          buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     847          if (pftmp->fieldType==34){ 
     848            if (myPtrs->currentRouterPtr->sampled != *((unsigned long*)&buffer4) ) { 
     849              myPtrs->currentRouterPtr->sampled = *((unsigned long*)&buffer4); 
     850              for (i=0; i<nbPV4; i++) { 
     851                /* we update the PrefixV4 structure with the sampled information */ 
     852                if ( myPtrs->currentRouterPtr->IpAddress == myPtrs->routersID[V4PTab[i].routerNb]) { 
     853                  V4PTab[i].sampling = *((unsigned long*)&buffer4); 
     854                  myPtrs->secondV4Tab[i].sampling = *((unsigned long*)&buffer4);  
     855#ifdef DEBUGAGG 
     856                  fprintf(stderr," SV %lu ", *((unsigned long*)&buffer4)); 
     857#endif             
     858                } 
     859              } 
     860            } 
     861          } 
     862        }        
     863        pftmp = pftmp->prev; 
     864      } 
     865      if ( pftmp == NULL ) { 
     866        while ((*myPtrs->offsetV9Ptr)%4 != 0) { 
     867          (*myPtrs->offsetV9Ptr)++; 
     868        } 
     869      } else { 
     870        fprintf(stderr,"PB "); 
     871      } 
     872#ifdef DEBUG 
     873      fprintf(stderr,">"); 
     874#endif 
     875      /*       (*myPtrs->offsetV9Ptr)+=(data_length-4); */ 
     876      /*       (*myPtrs->currentFlowsetNumberPtr) = myPtrs->currentHeaderV9Ptr->count; */       
     877    } else { 
     878      /*  
     879       * template unknown, we skip this all the data  
     880       */ 
     881      (*myPtrs->offsetV9Ptr)+=(data_length-4); 
     882      (*myPtrs->currentFlowsetNumberPtr) = myPtrs->currentHeaderV9Ptr->count; 
     883#ifdef DEBUG 
     884      fprintf(stderr, " U, r: %lu.%lu.%lu.%lu, sourceId: %lu, TID: %hu", 
     885              (myPtrs->pcktPtr->ipH->srcAdd>>24), 
     886              (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), 
     887              (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), 
     888              (myPtrs->pcktPtr->ipH->srcAdd<<24>>24), 
     889              myPtrs->currentHeaderV9Ptr->sourceId,  
     890              (*myPtrs->currentFlowsetIdPtr) 
     891              ); 
     892#endif 
     893    } 
    824894  } 
    825895  while ( ((*myPtrs->offsetV9Ptr)-48-shift) < data_length ) { 
     
    839909  } 
    840910#ifdef DEBUG 
    841   if (crazyCounter != 0){ 
    842     fprintf(stderr," crazyCounter: %d ", crazyCounter); 
    843   } 
     911  if (crazyCounter != 0){ fprintf(stderr," crazyCounter: %d ", crazyCounter); } 
    844912#endif 
    845913  if (crazyCounter!=0) { syslog(LOG_INFO,"crazyCounter: %d ", crazyCounter);} 
  • trunk/src/dataFlowSet.h

    r28 r29  
    101101  unsigned long *mplsNbPtr; 
    102102  unsigned long *routersID; 
     103  struct PrefixV4 *currentV4Tab; 
     104  struct PrefixV4 *secondV4Tab; 
    103105}; 
    104106 
  • trunk/src/get_conf.c

    r28 r29  
    171171        *((unsigned long*)&buffer4[0]) +~(~0<<(32-n4)); 
    172172      pV4TabPtr[i].mask = n4; 
     173      pV4TabPtr[i].sampling = 0;       
    173174      pV4TabPtr[i].routerNb = n5; 
    174175      pV4TabPtr[i].flowNbIN = 0; 
  • trunk/src/get_conf.h

    r28 r29  
    3333  unsigned short mask;     /* prefix mask  */ 
    3434  unsigned short routerNb; /* router ID */ 
     35  unsigned long sampling; /* Sampling value */ 
    3536  unsigned long long flowNbIN;  /* WARNING !!! */ 
    3637  unsigned long long bytesNbIN; /* Here, IN means "to the prefix" */ 
  • trunk/src/renetcol.c

    r28 r29  
    134134 
    135135  initCache(); 
    136   fprintf(stderr, "renetcol: reading the routers list...\n"); 
    137136  routerNb = getRegisteredRouters(configFileName, &sortedRouterList[0],  
    138137                                  &indexedRouterList[0]); 
    139   fprintf(stderr, "renetcol: OK\n"); 
    140  
    141138  key = 8765; 
    142139  if ((shmid = shmget(key, SHMSIZE, IPC_CREAT | 0666)) < 0) { 
     
    149146  } 
    150147 
    151   fprintf(stderr, "renetcol: reading the IPv4 prefix...\n"); 
    152148  if ( (shmForAgg->v4PrefixNb = getPrefixV4(prefixV4FileName, &(shmForAgg->prefixV4Tab[0][0]))) < 1){ 
    153149    fprintf(stderr, "renetcol: Error \n"); 
    154150    exit(1); 
    155   } else { 
    156     fprintf(stderr, "renetcol: OK \n"); 
    157151  } 
    158152  if ( (shmForAgg->v4PrefixNb = getPrefixV4(prefixV4FileName, &(shmForAgg->prefixV4Tab[1][0]))) < 1){ 
    159153    fprintf(stderr, "renetcol:  Error \n"); 
    160154    exit(1); 
    161   } else { 
    162     fprintf(stderr, "renetcol: OK \n"); 
    163   } 
     155  } 
     156 
     157  shmForAgg->currentTable = 0; 
     158  shmForAgg->secondTable = 1; 
     159 
    164160  myPtrs.rulesListPtr = NULL; 
    165   fprintf(stderr, "renetcol: reading the rules...\n"); 
    166161  myPtrs.rulesListPtr = getLightRules(myPtrs.rulesListPtr, rulesFileName); 
    167   fprintf(stderr, "renetcol: OK \n"); 
    168162  tmp = myPtrs.rulesListPtr; 
    169163  for ( ; tmp->next; tmp=tmp->next) { 
     
    209203  myPtrs.mplsNbPtr =  &mplsNb; 
    210204  myPtrs.routersID = &indexedRouterList; 
     205  myPtrs.currentV4Tab = shmForAgg->prefixV4Tab[shmForAgg->currentTable]; 
     206  myPtrs.secondV4Tab = shmForAgg->prefixV4Tab[shmForAgg->secondTable];   
    211207  
    212208  if (myPtrs.pcktPtr==NULL) { 
     
    402398      if (shmForAgg->currentTable == 0) { 
    403399        shmForAgg->currentTable = 1; 
     400        shmForAgg->secondTable = 0; 
    404401      }else{ 
    405402        shmForAgg->currentTable = 0; 
     403        shmForAgg->secondTable = 1; 
    406404      } 
    407405      shmForAgg->readed = 1; 
     
    756754    if ((tmpOP = tmp->tplOptList) != NULL){ 
    757755      for (; tmpOP; tmpOP=tmpOP->next) { 
    758         fprintf(TPLFILE,"OpTId %hu (sourceId: %lu) >\n lg: %hu, opScopeLg: %hu, opLg: %hu\n",  
     756        fprintf(TPLFILE,"OpTId %hu (sourceId: %lu) last %d brackets are Scope >\n lg: %hu, opScopeLg: %hu, opLg: %hu\n",  
    759757                tmpOP->templateOptionId, 
    760758                tmpOP->sourceId, 
     759                tmpOP->optionScopeLg/4, 
    761760                tmpOP->length, 
    762761                tmpOP->optionScopeLg, 
  • trunk/src/renetcol.h

    r28 r29  
    9292struct SHMForAgg { 
    9393  unsigned short currentTable; 
     94  unsigned short secondTable; 
    9495  unsigned short readed; 
    9596  unsigned short v4PrefixNb; 
  • trunk/src/renetcolAgg.c

    r28 r29  
    4848  int rrd_create_ok_ct = 0; 
    4949  int rrd_ct = 0; 
     50  int isFirstUpdate = 1; 
    5051  key_t key; 
    5152  static char buf[2048]; 
    5253  static char name[2048]; 
    53   static char ipStr[20]; 
     54  static char ipStr[24]; 
    5455  static char createstr[2048]; 
    5556  char *opt[27]; 
     
    5859  FILE *fp; 
    5960  static time_t now, now2; 
     61  struct shmid_ds shminfo; 
    6062   
    6163  key = 8765; 
     
    6870    exit(1); 
    6971  } 
    70  
     72   
    7173  fprintf(stderr, "renetcolAgg: I become a deamon, next messages via syslogd. By.\n"); 
    7274  if (fork () != 0) 
     
    8587      } 
    8688      now = time((time_t *)NULL); 
    87       for (i=0; i<shmForAgg->v4PrefixNb; i++){ 
    88         /* HERE Put in RRD FILE */ 
    89         name[0] = '\0'; 
    90         createstr[0] = '\0'; 
    91         ipStr[0] = '\0'; 
    92         buf[0] = '\0'; 
    93         strcat(name, RRD_LOCATION); 
    94         sprintf(ipStr, "%lu_%lu_%lu_%lu_%hu",  
    95                 shmForAgg->prefixV4Tab[index][i].beginning>>24, 
    96                 shmForAgg->prefixV4Tab[index][i].beginning<<8>>24, 
    97                 shmForAgg->prefixV4Tab[index][i].beginning<<16>>24, 
    98                 shmForAgg->prefixV4Tab[index][i].beginning<<24>>24, 
    99                 shmForAgg->prefixV4Tab[index][i].mask 
    100                 );  
    101         strcat(name, ipStr); 
    102         /*      strcat(name, SAMPLING_HERE); */ 
    103         strcat(name, RRD_EXTENSION); 
    104         if ( (fp=fopen(name,"r")) == NULL ){ 
    105           opt[0]= (char *) malloc((strlen(RRD_PARAM_0) + 1) * sizeof(char)); 
    106           strcpy(opt[0], RRD_PARAM_0); 
    107           opt[1]= (char *) malloc((strlen(name) + 1) * sizeof(char)); 
    108           strcpy(opt[1], name); 
    109           opt[2]= (char *) malloc((strlen(RRD_PARAM_1) + 1) * sizeof(char)); 
    110           strcpy(opt[2], RRD_PARAM_1); 
    111           opt[3]= (char *) malloc((strlen(RRD_PARAM_2) + 1) * sizeof(char)); 
    112           strcpy(opt[3], RRD_PARAM_2); 
    113           opt[4]= (char *) malloc((strlen(RRD_PARAM_3) + 1) * sizeof(char)); 
    114           strcpy(opt[4], RRD_PARAM_3); 
    115           opt[5]= (char *) malloc((strlen(RRD_PARAM_4) + 1) * sizeof(char)); 
    116           strcpy(opt[5], RRD_PARAM_4); 
    117           opt[6]= (char *) malloc((strlen(RRD_PARAM_5) + 1) * sizeof(char)); 
    118           strcpy(opt[6], RRD_PARAM_5); 
    119           opt[7]= (char *) malloc((strlen(RRD_PARAM_6) + 1) * sizeof(char)); 
    120           strcpy(opt[7], RRD_PARAM_6); 
    121           opt[8]= (char *) malloc((strlen(RRD_PARAM_7) + 1) * sizeof(char)); 
    122           strcpy(opt[8], RRD_PARAM_7); 
    123           opt[9]= (char *) malloc((strlen(RRD_PARAM_8) + 1) * sizeof(char)); 
    124           strcpy(opt[9], RRD_PARAM_8); 
    125           opt[10]= (char *) malloc((strlen(RRD_PARAM_9) + 1) * sizeof(char)); 
    126           strcpy(opt[10], RRD_PARAM_9); 
    127           opt[12]= (char *) malloc((strlen(RRD_PARAM_10) + 1) * sizeof(char)); 
    128           strcpy(opt[11], RRD_PARAM_10); 
    129           opt[12]= (char *) malloc((strlen(RRD_PARAM_11) + 1) * sizeof(char)); 
    130           strcpy(opt[12], RRD_PARAM_11); 
    131           opt[13]= (char *) malloc((strlen(RRD_PARAM_12) + 1) * sizeof(char)); 
    132           strcpy(opt[13], RRD_PARAM_12); 
    133           opt[14]= (char *) malloc((strlen(RRD_PARAM_13) + 1) * sizeof(char)); 
    134           strcpy(opt[14], RRD_PARAM_13); 
    135           opt[15]= (char *) malloc((strlen(RRD_PARAM_14) + 1) * sizeof(char)); 
    136           strcpy(opt[15], RRD_PARAM_14); 
    137           opt[16]= (char *) malloc((strlen(RRD_PARAM_15) + 1) * sizeof(char)); 
    138           strcpy(opt[16], RRD_PARAM_15); 
    139           opt[17]= (char *) malloc((strlen(RRD_PARAM_16) + 1) * sizeof(char)); 
    140           strcpy(opt[17], RRD_PARAM_16); 
    141           opt[18]= (char *) malloc((strlen(RRD_PARAM_17) + 1) * sizeof(char)); 
    142           strcpy(opt[18], RRD_PARAM_17); 
    143           opt[19]= (char *) malloc((strlen(RRD_PARAM_18) + 1) * sizeof(char)); 
    144           strcpy(opt[19], RRD_PARAM_18); 
    145           opt[20]= (char *) malloc((strlen(RRD_PARAM_19) + 1) * sizeof(char)); 
    146           strcpy(opt[20], RRD_PARAM_19); 
    147           opt[21]= (char *) malloc((strlen(RRD_PARAM_20) + 1) * sizeof(char)); 
    148           strcpy(opt[21], RRD_PARAM_20); 
    149           opt[22]= (char *) malloc((strlen(RRD_PARAM_21) + 1) * sizeof(char)); 
    150           strcpy(opt[22], RRD_PARAM_21); 
    151           opt[23]= (char *) malloc((strlen(RRD_PARAM_22) + 1) * sizeof(char)); 
    152           strcpy(opt[23], RRD_PARAM_22); 
    153           opt[24]= (char *) malloc((strlen(RRD_PARAM_23) + 1) * sizeof(char)); 
    154           strcpy(opt[24], RRD_PARAM_23); 
    155           opt[25]= (char *) malloc((strlen(RRD_PARAM_24) + 1) * sizeof(char)); 
    156           strcpy(opt[25], RRD_PARAM_24); 
    157           opt[26]= (char *) malloc((strlen(RRD_PARAM_25) + 1) * sizeof(char)); 
    158           strcpy(opt[26], RRD_PARAM_25); 
    159           optind = opterr = 0; 
    160           rrd_clear_error(); 
    161           if ( rrd_create(27,opt) < 0) { 
    162             syslog(LOG_ERR, "RRD create file %s, error: %s\n", name, rrd_get_error()); 
    163             rrd_create_er_ct++; 
    164           } else { 
    165             rrd_create_ok_ct++; 
     89      if (isFirstUpdate == 0) { 
     90        for (i=0; i<shmForAgg->v4PrefixNb; i++){ 
     91          /* HERE Put in RRD FILE */ 
     92          for (j=0; j<strlen(name); j++) {name[j] = '\0';} 
     93          for (j=0; j<strlen(createstr); j++) {createstr[j] = '\0';} 
     94          for (j=0; j<strlen(ipStr); j++) {ipStr[j] = '\0';} 
     95          for (j=0; j<strlen(buf); j++) {buf[j] = '\0';} 
     96          strcat(name, RRD_LOCATION); 
     97          fprintf(stderr," SPL : %lu\n ",shmForAgg->prefixV4Tab[index][i].sampling); 
     98          sprintf(ipStr, "%lu_%lu_%lu_%lu_%hu_%lu",  
     99                  shmForAgg->prefixV4Tab[index][i].beginning>>24, 
     100                  shmForAgg->prefixV4Tab[index][i].beginning<<8>>24, 
     101                  shmForAgg->prefixV4Tab[index][i].beginning<<16>>24, 
     102                  shmForAgg->prefixV4Tab[index][i].beginning<<24>>24, 
     103                  shmForAgg->prefixV4Tab[index][i].mask, 
     104                  shmForAgg->prefixV4Tab[index][i].sampling 
     105                  );  
     106          strcat(name, ipStr); 
     107          strcat(name, RRD_EXTENSION); 
     108          if ( (fp=fopen(name,"r")) == NULL ){ 
     109#ifdef DEBUGAGG 
     110            fprintf(stderr, "Creation %s ... ", name);  
     111#endif 
     112            opt[0]= (char *) malloc((strlen(RRD_PARAM_0) + 1) * sizeof(char)); 
     113            strcpy(opt[0], RRD_PARAM_0); 
     114            opt[1]= (char *) malloc((strlen(name) + 1) * sizeof(char)); 
     115            strcpy(opt[1], name); 
     116            opt[2]= (char *) malloc((strlen(RRD_PARAM_1) + 1) * sizeof(char)); 
     117            strcpy(opt[2], RRD_PARAM_1); 
     118            opt[3]= (char *) malloc((strlen(RRD_PARAM_2) + 1) * sizeof(char)); 
     119            strcpy(opt[3], RRD_PARAM_2); 
     120            opt[4]= (char *) malloc((strlen(RRD_PARAM_3) + 1) * sizeof(char)); 
     121            strcpy(opt[4], RRD_PARAM_3); 
     122            opt[5]= (char *) malloc((strlen(RRD_PARAM_4) + 1) * sizeof(char)); 
     123            strcpy(opt[5], RRD_PARAM_4); 
     124            opt[6]= (char *) malloc((strlen(RRD_PARAM_5) + 1) * sizeof(char)); 
     125            strcpy(opt[6], RRD_PARAM_5); 
     126            opt[7]= (char *) malloc((strlen(RRD_PARAM_6) + 1) * sizeof(char)); 
     127            strcpy(opt[7], RRD_PARAM_6); 
     128            opt[8]= (char *) malloc((strlen(RRD_PARAM_7) + 1) * sizeof(char)); 
     129            strcpy(opt[8], RRD_PARAM_7); 
     130            opt[9]= (char *) malloc((strlen(RRD_PARAM_8) + 1) * sizeof(char)); 
     131            strcpy(opt[9], RRD_PARAM_8); 
     132            opt[10]= (char *) malloc((strlen(RRD_PARAM_9) + 1) * sizeof(char)); 
     133            strcpy(opt[10], RRD_PARAM_9); 
     134            opt[11]= (char *) malloc((strlen(RRD_PARAM_10) + 1) * sizeof(char)); 
     135            strcpy(opt[11], RRD_PARAM_10); 
     136            opt[12]= (char *) malloc((strlen(RRD_PARAM_11) + 1) * sizeof(char)); 
     137            strcpy(opt[12], RRD_PARAM_11); 
     138            opt[13]= (char *) malloc((strlen(RRD_PARAM_12) + 1) * sizeof(char)); 
     139            strcpy(opt[13], RRD_PARAM_12); 
     140            opt[14]= (char *) malloc((strlen(RRD_PARAM_13) + 1) * sizeof(char)); 
     141            strcpy(opt[14], RRD_PARAM_13); 
     142            opt[15]= (char *) malloc((strlen(RRD_PARAM_14) + 1) * sizeof(char)); 
     143            strcpy(opt[15], RRD_PARAM_14); 
     144            opt[16]= (char *) malloc((strlen(RRD_PARAM_15) + 1) * sizeof(char)); 
     145            strcpy(opt[16], RRD_PARAM_15); 
     146            opt[17]= (char *) malloc((strlen(RRD_PARAM_16) + 1) * sizeof(char)); 
     147            strcpy(opt[17], RRD_PARAM_16); 
     148            opt[18]= (char *) malloc((strlen(RRD_PARAM_17) + 1) * sizeof(char)); 
     149            strcpy(opt[18], RRD_PARAM_17); 
     150            opt[19]= (char *) malloc((strlen(RRD_PARAM_18) + 1) * sizeof(char)); 
     151            strcpy(opt[19], RRD_PARAM_18); 
     152            opt[20]= (char *) malloc((strlen(RRD_PARAM_19) + 1) * sizeof(char)); 
     153            strcpy(opt[20], RRD_PARAM_19); 
     154            opt[21]= (char *) malloc((strlen(RRD_PARAM_20) + 1) * sizeof(char)); 
     155            strcpy(opt[21], RRD_PARAM_20); 
     156            opt[22]= (char *) malloc((strlen(RRD_PARAM_21) + 1) * sizeof(char)); 
     157            strcpy(opt[22], RRD_PARAM_21); 
     158            opt[23]= (char *) malloc((strlen(RRD_PARAM_22) + 1) * sizeof(char)); 
     159            strcpy(opt[23], RRD_PARAM_22); 
     160            opt[24]= (char *) malloc((strlen(RRD_PARAM_23) + 1) * sizeof(char)); 
     161            strcpy(opt[24], RRD_PARAM_23); 
     162            opt[25]= (char *) malloc((strlen(RRD_PARAM_24) + 1) * sizeof(char)); 
     163            strcpy(opt[25], RRD_PARAM_24); 
     164            opt[26]= (char *) malloc((strlen(RRD_PARAM_25) + 1) * sizeof(char)); 
     165            strcpy(opt[26], RRD_PARAM_25); 
     166            optind = opterr = 0; 
     167            rrd_clear_error(); 
     168            if ( rrd_create(27,opt) < 0) { 
     169              syslog(LOG_ERR, "RRD create file %s, error: %s\n", name, rrd_get_error()); 
     170              rrd_create_er_ct++; 
     171            } else { 
     172              rrd_create_ok_ct++; 
     173            } 
     174            for ( j=0; j<27; j++) { 
     175              free(opt[j]); 
     176              opt[j] = NULL; 
     177            } 
     178#ifdef DEBUGAGG 
     179            fprintf(stderr, "end creation \n", name);  
     180#endif 
     181          }else{  
     182            fclose(fp); 
     183#ifdef DEBUGAGG 
     184            fprintf(stderr, "Update %s \n", name);  
     185#endif 
     186            rrd_already_created_ct++; 
     187            snprintf(buf,  
     188                     2048,  
     189                     "%lu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu",   
     190                     now-300,  /* or ctime(&now) with %s */ 
     191                     shmForAgg->prefixV4Tab[index][i].flowNbIN,  /* 1 */ 
     192                     shmForAgg->prefixV4Tab[index][i].flowNbOUT, 
     193                     shmForAgg->prefixV4Tab[index][i].bytesNbIN, 
     194                     shmForAgg->prefixV4Tab[index][i].bytesNbOUT, 
     195                     shmForAgg->prefixV4Tab[index][i].pktsNbIN,  /* 5 */ 
     196                     shmForAgg->prefixV4Tab[index][i].pktsNbOUT, 
     197                     shmForAgg->prefixV4Tab[index][i].firstCoSIN, 
     198                     shmForAgg->prefixV4Tab[index][i].firstCoSOUT, 
     199                     shmForAgg->prefixV4Tab[index][i].secondCoSIN, 
     200                     shmForAgg->prefixV4Tab[index][i].secondCoSOUT, 
     201                     shmForAgg->prefixV4Tab[index][i].thirdCoSIN, 
     202                     shmForAgg->prefixV4Tab[index][i].thirdCoSOUT, 
     203                     shmForAgg->prefixV4Tab[index][i].fourthCoSIN, 
     204                     shmForAgg->prefixV4Tab[index][i].fourthCoSOUT 
     205                     ); 
     206            optUpdate[0]= (char *) malloc((strlen(RRD_UPDATE_0) + 1) * sizeof(char)); 
     207            strcpy(optUpdate[0], RRD_UPDATE_0); 
     208            optUpdate[1]= (char *) malloc((strlen(name) + 1) * sizeof(char)); 
     209            strcpy(optUpdate[1], name); 
     210            optUpdate[2]= (char *) malloc((strlen(buf) + 1) * sizeof(char)); 
     211            strcpy(optUpdate[2], buf); 
     212            optind = opterr = 0;  
     213            rrd_clear_error(); 
     214            if ( rrd_update(3, optUpdate) < 0 ) {  
     215              syslog(LOG_ERR, "RRD update file %s, error: %s\n", name, rrd_get_error()); 
     216              rrd_update_er_ct++; 
     217            } else { 
     218              rrd_update_ok_ct++; 
     219            } 
     220            for ( j=0; j<3; j++) { 
     221              free(optUpdate[j]); 
     222              optUpdate[j] = NULL; 
     223            } 
    166224          } 
    167           for ( j=0; j<27; j++) { 
    168             free(opt[j]); 
    169             opt[j] = NULL; 
    170           } 
    171         }else{  
    172           fclose(fp); 
    173           rrd_already_created_ct++; 
    174           snprintf(buf,  
    175                    2048,  
    176                    "%lu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu",   
    177                    now-300,  /* or ctime(&now) with %s */ 
    178                    shmForAgg->prefixV4Tab[index][i].flowNbIN,  /* 1 */ 
    179                    shmForAgg->prefixV4Tab[index][i].flowNbOUT, 
    180                    shmForAgg->prefixV4Tab[index][i].bytesNbIN, 
    181                    shmForAgg->prefixV4Tab[index][i].bytesNbOUT, 
    182                    shmForAgg->prefixV4Tab[index][i].pktsNbIN,  /* 5 */ 
    183                    shmForAgg->prefixV4Tab[index][i].pktsNbOUT, 
    184                    shmForAgg->prefixV4Tab[index][i].firstCoSIN, 
    185                    shmForAgg->prefixV4Tab[index][i].firstCoSOUT, 
    186                    shmForAgg->prefixV4Tab[index][i].secondCoSIN, 
    187                    shmForAgg->prefixV4Tab[index][i].secondCoSOUT, 
    188                    shmForAgg->prefixV4Tab[index][i].thirdCoSIN, 
    189                    shmForAgg->prefixV4Tab[index][i].thirdCoSOUT, 
    190                    shmForAgg->prefixV4Tab[index][i].fourthCoSIN, 
    191                    shmForAgg->prefixV4Tab[index][i].fourthCoSOUT 
    192                    ); 
    193           optUpdate[0]= (char *) malloc((strlen(RRD_UPDATE_0) + 1) * sizeof(char)); 
    194           strcpy(optUpdate[0], RRD_UPDATE_0); 
    195           optUpdate[1]= (char *) malloc((strlen(name) + 1) * sizeof(char)); 
    196           strcpy(optUpdate[1], name); 
    197           optUpdate[2]= (char *) malloc((strlen(buf) + 1) * sizeof(char)); 
    198           strcpy(optUpdate[2], buf); 
    199           optind = opterr = 0;  
    200           rrd_clear_error(); 
    201           if ( rrd_update(3, optUpdate) < 0 ) {  
    202             syslog(LOG_ERR, "RRD update file %s, error: %s\n", name, rrd_get_error()); 
    203             rrd_update_er_ct++; 
    204           } else { 
    205             rrd_update_ok_ct++; 
    206           } 
    207           for ( j=0; j<3; j++) { 
    208             free(optUpdate[j]); 
    209             optUpdate[j] = NULL; 
    210           } 
    211         } 
    212         /* Reinit the shared table */ 
    213         shmForAgg->prefixV4Tab[index][i].flowNbIN = 0; 
    214         shmForAgg->prefixV4Tab[index][i].bytesNbIN = 0; 
    215         shmForAgg->prefixV4Tab[index][i].pktsNbIN = 0; 
    216         shmForAgg->prefixV4Tab[index][i].flowNbOUT = 0; 
    217         shmForAgg->prefixV4Tab[index][i].bytesNbOUT = 0; 
    218         shmForAgg->prefixV4Tab[index][i].pktsNbOUT = 0; 
    219         shmForAgg->prefixV4Tab[index][i].firstCoSIN = 0; 
    220         shmForAgg->prefixV4Tab[index][i].secondCoSIN = 0; 
    221         shmForAgg->prefixV4Tab[index][i].thirdCoSIN = 0; 
    222         shmForAgg->prefixV4Tab[index][i].fourthCoSIN = 0; 
    223         shmForAgg->prefixV4Tab[index][i].firstCoSOUT = 0; 
    224         shmForAgg->prefixV4Tab[index][i].secondCoSOUT = 0; 
    225         shmForAgg->prefixV4Tab[index][i].thirdCoSOUT = 0; 
    226         shmForAgg->prefixV4Tab[index][i].fourthCoSOUT = 0; 
    227       } 
    228       now2 = time((time_t *)NULL); 
    229 #ifdef DEBUG 
    230       fprintf(stderr, "IPv4 subnet managment (rrd update) : \n %d sec, %d files updated, %d errors, total %d\n %d rrd file already created, %d errors in creation, %d new rrd file creations", 
    231               now2-now, 
    232               rrd_update_ok_ct, 
    233               rrd_update_er_ct, 
    234               rrd_update_ok_ct+rrd_update_er_ct, 
    235               rrd_already_created_ct, 
    236               rrd_create_er_ct, 
    237               rrd_create_ok_ct); 
    238 #endif 
    239       rrd_update_ok_ct = 0; 
    240       rrd_update_er_ct = 0; 
    241       rrd_already_created_ct = 0; 
    242       rrd_create_er_ct = 0; 
    243       rrd_create_ok_ct = 0; 
    244       rrd_clear_error(); 
    245     } 
    246     sleep(5); 
     225          /* Reinit the shared table */ 
     226          shmForAgg->prefixV4Tab[index][i].flowNbIN = 0; 
     227          shmForAgg->prefixV4Tab[index][i].bytesNbIN = 0; 
     228          shmForAgg->prefixV4Tab[index][i].pktsNbIN = 0; 
     229          shmForAgg->prefixV4Tab[index][i].flowNbOUT = 0; 
     230          shmForAgg->prefixV4Tab[index][i].bytesNbOUT = 0; 
     231          shmForAgg->prefixV4Tab[index][i].pktsNbOUT = 0; 
     232          shmForAgg->prefixV4Tab[index][i].firstCoSIN = 0; 
     233          shmForAgg->prefixV4Tab[index][i].secondCoSIN = 0; 
     234          shmForAgg->prefixV4Tab[index][i].thirdCoSIN = 0; 
     235          shmForAgg->prefixV4Tab[index][i].fourthCoSIN = 0; 
     236          shmForAgg->prefixV4Tab[index][i].firstCoSOUT = 0; 
     237          shmForAgg->prefixV4Tab[index][i].secondCoSOUT = 0; 
     238          shmForAgg->prefixV4Tab[index][i].thirdCoSOUT = 0; 
     239          shmForAgg->prefixV4Tab[index][i].fourthCoSOUT = 0;  
     240        }       
     241        now2 = time((time_t *)NULL); 
     242/* #ifdef DEBUGAGG */ 
     243        fprintf(stderr, "IPv4 subnet managment (rrd update) : \n %d sec, %d files updated, %d errors, total %d\n %d rrd file already created, %d errors in creation, %d new rrd file creations", 
     244                now2-now, 
     245                rrd_update_ok_ct, 
     246                rrd_update_er_ct, 
     247                rrd_update_ok_ct+rrd_update_er_ct, 
     248                rrd_already_created_ct, 
     249                rrd_create_er_ct, 
     250                rrd_create_ok_ct); 
     251/* #endif */ 
     252        rrd_update_ok_ct = 0; 
     253        rrd_update_er_ct = 0; 
     254        rrd_already_created_ct = 0; 
     255        rrd_create_er_ct = 0; 
     256        rrd_create_ok_ct = 0; 
     257        rrd_clear_error(); 
     258      } else { 
     259        isFirstUpdate = 0; 
     260      }   
     261    }  
     262    sleep(10); 
    247263  } while (1); 
    248  
    249264  exit(0); 
    250265} 
  • trunk/src/renetcolAgg.h

    r28 r29  
    7878struct SHMForAgg { 
    7979  unsigned short currentTable; 
     80  unsigned short secondTable; 
    8081  unsigned short readed; 
    8182  unsigned short v4PrefixNb; 
  • trunk/src/template.c

    r28 r29  
    8686  do { 
    8787#ifdef DEBUG     
    88     fprintf (stderr, "<\n"); 
    89     fprintf (stderr, "length %d \n", length);   
     88    fprintf (stderr, "{"); 
    9089#endif 
    9190    badFieldNumber = 0; 
     
    281280  } while ( (cpt) < (length-2) ); /*length-2*/ 
    282281#ifdef DEBUG 
    283   fprintf (stderr, "length returned %d, cpt=%d\n", length, cpt);   
    284   fprintf (stderr, ">\n"); 
     282  fprintf (stderr, "}"); 
    285283#endif 
    286284  return length; 
     
    315313  do { 
    316314#ifdef DEBUG     
    317     fprintf (stderr, "<o\n"); 
     315    fprintf (stderr, "<"); 
    318316#endif 
    319317    badFieldNumber = 0; 
     
    464462/*   show_all_tplFlSet(); */ 
    465463#ifdef DEBUG 
    466   fprintf (stderr, "length returned %d, cpt=%d\n", length, cpt);   
    467   fprintf (stderr, ">\n"); 
     464  fprintf (stderr, ">"); 
    468465#endif 
    469466  return length;