Exemplo n.º 1
0
/* Flush logs (for example, at the end of a purge pass or after dumping stats) */
void FlushLogs(  )
{
    log_init_check(  );

    flush_log_descr( &log );
    flush_log_descr( &report );
    flush_log_descr( &alert );
}
Exemplo n.º 2
0
/* Flush logs (for example, at the end of a purge pass or after dumping
 * stats) */
void FlushLogs(void)
{
    log_init_check();

    flush_log_descr(&log);
    flush_log_descr(&report);
    flush_log_descr(&alert);
#ifdef HAVE_CHANGELOGS
    flush_log_descr(&chglogs);
#endif
}
Exemplo n.º 3
0
static void test_file_names(void)
{
    log_init_check();

    test_log_descr(log_config.log_file, &log);
    test_log_descr(log_config.report_file, &report);

    if (!EMPTY_STRING(log_config.alert_file))
        test_log_descr(log_config.alert_file, &alert);

#ifdef HAVE_CHANGELOGS
    if (!EMPTY_STRING(log_config.changelogs_file))
        test_log_descr(log_config.changelogs_file, &chglogs);
#endif
}
Exemplo n.º 4
0
void RaiseAlert(const char *title, const char *format, ...)
{
    va_list     args;
    char        mail[MAX_MAIL_LEN];
    char        title2[1024];
    int         written;
    time_t      now = time(NULL);
    struct tm   date;

    log_init_check();

    /* send alert mail, if an address was specified in config file */
    if (!EMPTY_STRING(log_config.alert_mail)) {
        localtime_r(&now, &date);
        written = snprintf(mail, MAX_MAIL_LEN,
                           "===== %s =====\n"
                           "Date: %.4d/%.2d/%.2d %.2d:%.2d:%.2d\n"
                           "Program: %s (pid %lu)\n"
                           "Host: %s\n"
                           "Filesystem: %s\n",
                           title, 1900 + date.tm_year, date.tm_mon + 1,
                           date.tm_mday, date.tm_hour, date.tm_min, date.tm_sec,
                           prog_name, (unsigned long)getpid(), machine_name,
                           global_config.fs_path);

        va_start(args, format);
        vsnprintf(mail + written, MAX_MAIL_LEN - written, format, args);
        va_end(args);

        snprintf(title2, 1024, "%s (%s on %s)", title, global_config.fs_path,
                 machine_name);
        SendMail(log_config.alert_mail, title2, mail);
    }

    if (!EMPTY_STRING(log_config.alert_file)) {
        display_line_log_(&alert, "ALERT", "%s", title);
        va_start(args, format);
        display_line_log(&alert, "ALERT", format, args);
        va_end(args);

        /* always flush alerts, because we don't want to lose events */
        flush_log_descr(&alert);
    }

}   /* DisplayAlert */
Exemplo n.º 5
0
static void test_file_names(  )
{
    log_init_check(  );

    /* if the lock is taken, return immediately
     * (another thread is doing the check)
     */
    if ( pthread_mutex_trylock( &mutex_reopen ) != 0 )
        return;

    test_log_descr( log_config.log_file, &log );
    test_log_descr( log_config.report_file, &report );

    if ( !EMPTY_STRING( log_config.alert_file ) )
        test_log_descr( log_config.alert_file, &alert );

    pthread_mutex_unlock( &mutex_reopen );

}