int HistoricalInterface::loadData() {
  time_t actual_epoch, adjust_to_epoch;
  int ret_state = CONST_HISTORICAL_OK;
  NetworkInterface * iface = ntop->getInterfaceById(interface_id);

  if((iface != NULL) && (from_epoch != 0) && (to_epoch != 0)) {
    u_int8_t iface_dump_id;

    iface_dump_id = iface->get_id();
    actual_epoch = from_epoch;
    adjust_to_epoch = to_epoch - 300; // Adjust to epoch each file contains 5 minute of data
    while (actual_epoch <= adjust_to_epoch && isRunning()) {
      char path[MAX_PATH];
      char db_path[MAX_PATH];
  
      memset(path, 0, sizeof(path));
      memset(db_path, 0, sizeof(db_path));

      strftime(path, sizeof(path), "%Y/%m/%d/%H/%M", localtime(&actual_epoch));
      snprintf(db_path, sizeof(db_path), "%s/%u/flows/%s.sqlite",
                    ntop->get_working_dir(), iface_dump_id , path);

     loadData(db_path);

      num_historicals++;
      actual_epoch += 300; // 5 minute steps
    }
  }

  on_load = false;

  return ret_state;
}
Exemple #2
0
int Ntop::getInterfaceIdByName(char *name) {
   /* This method accepts both interface names or Ids */
  u_int if_id = atoi(name);
  char str[8];

  snprintf(str, sizeof(str), "%u", if_id);
  if(strcmp(name, str) == 0) {
    /* name is a number */
    NetworkInterface *iface = getInterfaceById(if_id);
    
    if(iface != NULL)
      return(iface->get_id());
    else
      return(-1);
  }

  for(int i=0; i<num_defined_interfaces; i++) {
    if(strcmp(iface[i]->get_name(), name) == 0) {
      return(iface[i]->get_id());
    }
  }

  return(-1);
}