Exemple #1
0
int InitializeLogs(const char *program_name)
{
    struct utsname uts;
    char          *tmp;
    int            rc;

    /* get node name */
    if (uname(&uts) == -1)
        strcpy(machine_name, "???");
    else
        rh_strncpy(machine_name, uts.nodename, RBH_PATH_MAX);

    /* if the name is the full machine name (node.subnet.domain.ext),
     * only kief the brief name */
    if ((tmp = strchr(machine_name, '.')) != NULL)
        *tmp = '\0';

    if (program_name == NULL)
        strcpy(prog_name, "???");
    else
        rh_strncpy(prog_name, program_name, RBH_PATH_MAX);

    /* open log files */
    rc = init_log_descr(log_config.log_file, &log);
    if (rc)
        return rc;

    rc = init_log_descr(log_config.report_file, &report);
    if (rc)
        return rc;

    if (!EMPTY_STRING(log_config.alert_file)) {
        rc = init_log_descr(log_config.alert_file, &alert);
        if (rc)
            return rc;
    }
#ifdef HAVE_CHANGELOGS
    if (!EMPTY_STRING(log_config.changelogs_file)) {
        rc = init_log_descr(log_config.changelogs_file, &chglogs);
        if (rc)
            return rc;
    }
#endif

    /* Update log level for external components we get logs from (LLAPI...) */
    rbh_adjust_log_level_external();

    last_time_test = time(NULL);
    log_initialized = true;

    return 0;

}   /* InitializeLogs */
Exemple #2
0
/** initialize access to lustre */
int Lustre_Init( void )
{
#if HAVE_LLAPI_MSG_LEVEL
# if HAVE_LLAPI_LOG_CALLBACKS
    rbh_adjust_log_level_external();
    llapi_error_callback_set(display_llapi_msg);
    llapi_info_callback_set(display_llapi_msg);
# else
    llapi_msg_set_level(LLAPI_MSG_OFF);
# endif
#endif
    return 0;
}
Exemple #3
0
static int log_cfg_reload(log_config_t *conf)
{
    if (conf->debug_level != log_config.debug_level) {
        if (!log_config.force_debug_level) {
            DisplayLog(LVL_MAJOR, "LogConfig",
                       RBH_LOG_CONFIG_BLOCK "::debug_level modified: '%d'->'%d'",
                       log_config.debug_level, conf->debug_level);
            log_config.debug_level = conf->debug_level;
        } else {
            DisplayLog(LVL_EVENT, "LogConfig", "Log level is forced by command "
                       "line. Not taking configuration parameter "
                       RBH_LOG_CONFIG_BLOCK "::debug_level into account.");
        }
    }

    /* log files can be changed dynamically: this will just be considered as if
     * it was renamed */
    if (strcmp(conf->log_file, log_config.log_file)) {
        if (!log_config.force_log_file) {
            DisplayLog(LVL_MAJOR, "LogConfig",
                       RBH_LOG_CONFIG_BLOCK "::log_file modified: '%s'->'%s'",
                       log_config.log_file, conf->log_file);

            /* lock file name to avoid reading inconsistent filenames */
            pthread_rwlock_wrlock(&log.f_lock);
            strcpy(log_config.log_file, conf->log_file);
            pthread_rwlock_wrlock(&log.f_lock);
        } else {
            DisplayLog(LVL_EVENT, "LogConfig", "Log file is forced by command "
                       "line. Not taking configuration parameter "
                       RBH_LOG_CONFIG_BLOCK "::log_file into account.");
        }
    }

    if (strcmp(conf->report_file, log_config.report_file)) {
        DisplayLog(LVL_MAJOR, "LogConfig",
                   RBH_LOG_CONFIG_BLOCK "::report_file modified: '%s'->'%s'",
                   log_config.report_file, conf->report_file);

        /* lock file name to avoid reading inconsistent filenames */
        pthread_rwlock_wrlock(&report.f_lock);
        strcpy(log_config.report_file, conf->report_file);
        pthread_rwlock_unlock(&report.f_lock);
    }

    if (strcmp(conf->alert_file, log_config.alert_file)) {
        DisplayLog(LVL_MAJOR, "LogConfig",
                   RBH_LOG_CONFIG_BLOCK "::alert_file modified: '%s'->'%s'",
                   log_config.alert_file, conf->alert_file);

        /* lock file name to avoid reading inconsistent filenames */
        pthread_rwlock_wrlock(&alert.f_lock);
        strcpy(log_config.alert_file, conf->alert_file);
        pthread_rwlock_unlock(&alert.f_lock);
    }

    if (strcmp(conf->alert_mail, log_config.alert_mail))
        DisplayLog(LVL_MAJOR, "LogConfig",
                   RBH_LOG_CONFIG_BLOCK
                   "::alert_mail changed in config file, but cannot be modified dynamically");

#ifdef HAVE_CHANGELOGS
    if (strcmp(conf->changelogs_file, log_config.changelogs_file)) {
        DisplayLog(LVL_MAJOR, "LogConfig",
                   RBH_LOG_CONFIG_BLOCK
                   "::changelogs_file modified: '%s'->'%s'",
                   log_config.changelogs_file, conf->changelogs_file);

        /* lock file name to avoid reading inconsistent filenames */
        pthread_rwlock_wrlock(&chglogs.f_lock);
        strcpy(log_config.changelogs_file, conf->changelogs_file);
        pthread_rwlock_unlock(&chglogs.f_lock);
    }
#endif

    if (conf->stats_interval != log_config.stats_interval) {
        DisplayLog(LVL_MAJOR, "LogConfig",
                   RBH_LOG_CONFIG_BLOCK "::stats_interval modified: "
                   "'%" PRI_TT "'->'%" PRI_TT "'",
                   log_config.stats_interval, conf->stats_interval);
        log_config.stats_interval = conf->stats_interval;
    }

    if (conf->batch_alert_max != log_config.batch_alert_max) {
        DisplayLog(LVL_MAJOR, "LogConfig",
                   RBH_LOG_CONFIG_BLOCK
                   "::batch_alert_max modified: '%u'->'%u'",
                   log_config.batch_alert_max, conf->batch_alert_max);

        /* flush batched alerts first */
        P(alert_mutex);

        if (alert_batching)
            /* don't release mutex */
            FlushAlerts(false);

        log_config.batch_alert_max = conf->batch_alert_max;
        V(alert_mutex);
    }

    if (conf->log_process != log_config.log_process) {
        DisplayLog(LVL_MAJOR, "LogConfig",
                   RBH_LOG_CONFIG_BLOCK "::log_procname modified: '%s'->'%s'",
                   bool2str(log_config.log_process),
                   bool2str(conf->log_process));
        log_config.log_process = conf->log_process;
    }

    if (conf->log_host != log_config.log_host) {
        DisplayLog(LVL_MAJOR, "LogConfig",
                   RBH_LOG_CONFIG_BLOCK "::log_hostname modified: '%s'->'%s'",
                   bool2str(log_config.log_host), bool2str(conf->log_host));
        log_config.log_host = conf->log_host;
    }

    rbh_adjust_log_level_external();
    return 0;
}