Changeset 6701

Show
Ignore:
Timestamp:
10/03/08 10:53:39 (2 months ago)
Author:
rbertholon
Message:

fixed some mess and modif the censtorage start/stop script

Location:
trunk/centstorage
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • trunk/centstorage/centstorage

    r6604 r6701  
    8484 
    8585prefix=/usr/local/centreon 
    86 Bin=/usr/local/centreon/bin/centstorage 
    87 centstorageLogDir=/usr/local/centreon/log 
     86Bin=${prefix}/bin/centstorage 
     87 
     88# log directory 
     89centstorageLogDir=${prefix}/log 
     90centstorageDemLog=${centstorageLogDir}/centstorage.log 
     91 
     92# running (pid file) 
    8893centstorageRunDir=/var/run/centreon 
    89 #centstorageVarDir=${prefix}/var/ 
    9094centstorageRunFile=${centstorageRunDir}/centstorage.pid 
    91 centstorageDemLog=${centstorageLogDir}/centstorage.log 
     95 
     96#lock file 
    9297centstorageLockDir=/var/lock 
    9398centstorageLockFile=centstorage.lock 
     
    97102if [ ! -f $centstorageBin ]; then 
    98103    echo "Executable file $centstorageBin not found.  Exiting." 
    99     exit 1 
    100 fi 
    101  
    102 # Check that centstorage.cfg exists. 
    103 if [ ! -f $centstorageCfgFile ]; then 
    104     echo "Configuration file $centstorageCfgFile not found.  Exiting." 
    105104    exit 1 
    106105fi 
     
    119118            echo "Removing centstorage pid file" 
    120119        else 
     120            echo "$centstorageRunFile already running" 
    121121            exit 1 
    122122        fi 
  • trunk/centstorage/includes/Conf.h

    r6655 r6701  
    7070#define DEFAULT_LOG_LEVEL       0 
    7171 
     72#define DEFAULT_PID_FILE        "/var/run/centreon/centstorage.pid" 
     73 
    7274#define XPATH_LOG_FILE(root)    "/"root"/logging/logFile/text()" 
    7375#define XPATH_LOG_LEVEL(root)   "/"root"/logging/level/text()" 
     
    9294#define XPATH_DB_CONF_USER(root) "/"root"/DataBases/confDB/user/text()" 
    9395#define XPATH_DB_CONF_PASS(root) "/"root"/DataBases/confDB/pass/text()" 
     96 
     97#define XPATH_PID_FILE(root) "/"root"/PidFile/text()" 
    9498 
    9599/* this structure contains all the value needed to connect a client to a 
     
    158162  /* informations about configuration file */ 
    159163  char                  *confFile; 
     164  char                  *pidFile; 
     165  short                 defPidFile; 
    160166  int                   timeout; 
    161167  unsigned short        unit; 
  • trunk/centstorage/modules/recup_perf_datas/insertValInMySQLDataBase.c

    r6694 r6701  
    148148    } 
    149149 
    150   if (!strncmp( "meta_", svce, 5)) 
    151     { 
    152       index_id = insertMetaIndexDataMySQL(svce, &mysql, &rped_conf_db_connection, 
     150  if (!strncmp( "meta_", svce, 5) || !strncmp( "qos_", svce, 4)) 
     151    { 
     152      index_id = insertMetaIndexDataMySQL(svce, &mysql, (MYSQL **)&rped_conf_db_connection, 
    153153                                          log, confModule->timeRetry); 
    154154      if (!index_id) 
  • trunk/centstorage/modules/recup_perf_datas/interval.c

    r6694 r6701  
    8686              return selectInterval(type, request, log, timeRetry); 
    8787            } 
    88           else if (!strncmp("osl_", queryresult[3], 4)) 
     88          else if (!strncmp("qos_", queryresult[3], 4)) 
    8989            { 
    9090              /* second possibility : service_description begins with "osl_" */ 
  • trunk/centstorage/modules/rrd/interval.c

    r6694 r6701  
    8888                                    *conf_db_connection, MOD_NAME); 
    8989            } 
    90           else if (!strncmp("osl_", queryresult[3], 4)) 
     90          else if (!strncmp("qos_", queryresult[3], 4)) 
    9191            { 
    92               /* second possibility : service_description begins with "osl_" */ 
     92              /* second possibility : service_description begins with "qos_" */ 
    9393 
    9494              int       oslId = atoi(queryresult[3] + 4); 
  • trunk/centstorage/modules/rrd/interval.h

    r6625 r6701  
    3535#define SELECT_CHECK_INTER_META "SELECT normal_check_interval FROM meta_service WHERE meta_id=" 
    3636#define ERROR_SELECT_INTERVAL "Cannot select interval" 
    37 #define SELECT_CHECK_INTER_OSL "SELECT normal_check_interval FROM osl WHERE osl_id=" 
     37#define SELECT_CHECK_INTER_OSL "SELECT normal_check_interval FROM qos WHERE qos_id=" 
    3838#define MYSQL_RESULT "mysql_result(MYSQL *) failed" 
    3939 
  • trunk/centstorage/src/Conf.c

    r6625 r6701  
    240240    free(tmp); 
    241241 
     242  tmp = getParam(XPATH_PID_FILE(ROOT_ELEMENT), xmlConfContext, doc); 
     243  conf->pidFile = (tmp ? tmp : DEFAULT_PID_FILE); 
     244  conf->defPidFile = (tmp ? FALSE : TRUE); 
     245 
    242246  loadBaseConf(xmlConfContext, doc); 
    243247  loadBasePerf(xmlConfContext, doc); 
  • trunk/centstorage/src/centstorage.c

    r6625 r6701  
    6161    logger("Exit CentStorage"); 
    6262  exit(EXIT_FAILURE); 
     63} 
     64 
     65void    initVal(void) 
     66{ 
     67  conf = x_malloc(sizeof(*conf)); 
     68  conf->confFile = DEFAULT_CONF_FILE; 
     69  conf->timeout = 0; 
     70  conf->logs = x_malloc(sizeof(logging_t)); 
     71  conf->logs->log_file = NULL; 
     72  conf->logs->log = 0; 
     73  conf->logs->defLogFile = 1; 
     74  conf->logs->logFileOpened = 0; 
    6375} 
    6476 
     
    162174int             main(int argc, char **argv) 
    163175{ 
    164   int           retVal; 
    165176  char          *logging; 
    166177  FILE          *PID; 
     
    169180  mtrace(); 
    170181 
    171   PID = fopen("./centstorage.pid", "w"); 
    172   fprintf(PID, "%d", getpid()); 
    173   fclose(PID); 
    174  
    175182  /* printing welcome message */ 
    176183  printf("%s\n\n", WELCOME_MESSAGE); 
    177184 
    178185  /* values initialisation */ 
    179   conf = x_malloc(sizeof(*conf)); 
    180   conf->confFile = DEFAULT_CONF_FILE; 
    181  
    182   conf->timeout = 0; 
    183  
    184   conf->logs = x_malloc(sizeof(logging_t)); 
    185   conf->logs->log_file = NULL; 
    186   conf->logs->log = 0; 
    187   conf->logs->defLogFile = 1; 
    188   conf->logs->logFileOpened = 0; 
     186  initVal(); 
    189187 
    190188  /* checking arguments */ 
     
    193191 
    194192  /* loading configuration */ 
    195   retVal = loadConf(conf->confFile); 
    196   if (retVal == -1) 
     193  if (loadConf(conf->confFile) == -1) 
    197194    loadDefaultConfiguration(); 
     195 
     196  PID = fopen(conf->pidFile, "w"); 
     197  if (!PID) 
     198    return -1; 
     199  fprintf(PID, "%d", getpid()); 
     200  fclose(PID); 
     201  if (!conf->defPidFile) 
     202    free(conf->pidFile); 
    198203 
    199204  /* opening logging file */ 
     
    210215        { 
    211216          conf->logs->logFileOpened = 1; 
    212           if (logger(CENTSTORAGE_START) == -1) 
    213             fprintf(stderr, "%s.\n", ERROR_INFOS_LOGS); 
     217          if (conf->logs->log) 
     218            logger(CENTSTORAGE_START); 
    214219        } 
    215220    } 
     
    230235    free(conf->logs->log_file); 
    231236 
     237  unlink(conf->pidFile); 
    232238  free(conf->logs); 
    233239  free(conf);