2015-02-16 23:46:58 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
* Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
|
2015-02-17 23:44:58 +03:00
|
|
|
* Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
|
2015-02-16 23:46:58 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "orte_config.h"
|
|
|
|
#include "orte/constants.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
#include <sys/time.h>
|
|
|
|
#endif /* HAVE_SYS_TIME_H */
|
|
|
|
#ifdef HAVE_SYSLOG_H
|
|
|
|
#include <syslog.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STDARG_H
|
|
|
|
#include <stdarg.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "opal/util/show_help.h"
|
|
|
|
|
|
|
|
#include "orte/util/error_strings.h"
|
|
|
|
#include "orte/util/name_fns.h"
|
|
|
|
|
|
|
|
#include "orte/mca/notifier/base/base.h"
|
|
|
|
#include "notifier_syslog.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* Static API's */
|
|
|
|
static int init(void);
|
|
|
|
static void finalize(void);
|
2015-02-17 23:44:58 +03:00
|
|
|
static void mylog(orte_notifier_request_t *req);
|
|
|
|
static void myreport(orte_notifier_request_t *req);
|
2015-02-16 23:46:58 +03:00
|
|
|
|
|
|
|
/* Module def */
|
|
|
|
orte_notifier_base_module_t orte_notifier_syslog_module = {
|
|
|
|
init,
|
|
|
|
finalize,
|
|
|
|
mylog,
|
2015-02-17 23:44:58 +03:00
|
|
|
myreport
|
2015-02-16 23:46:58 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static int init(void)
|
|
|
|
{
|
|
|
|
int opts;
|
|
|
|
|
|
|
|
opts = LOG_CONS | LOG_PID;
|
2015-02-17 23:44:58 +03:00
|
|
|
openlog("OpenRTE Error Report:", opts, LOG_USER);
|
2015-02-16 23:46:58 +03:00
|
|
|
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void finalize(void)
|
|
|
|
{
|
|
|
|
closelog();
|
|
|
|
}
|
|
|
|
|
2015-02-17 23:44:58 +03:00
|
|
|
static void mylog(orte_notifier_request_t *req)
|
2015-02-16 23:46:58 +03:00
|
|
|
{
|
2015-02-17 23:44:58 +03:00
|
|
|
char tod[48];
|
|
|
|
|
2015-02-16 23:46:58 +03:00
|
|
|
opal_output_verbose(5, orte_notifier_base_framework.framework_output,
|
|
|
|
"notifier:syslog:mylog function called with severity %d errcode %d and messg %s",
|
2015-02-17 23:44:58 +03:00
|
|
|
(int)req->severity, req->errcode, req->msg);
|
2015-02-16 23:46:58 +03:00
|
|
|
/* If there was a message, output it */
|
2015-02-17 23:44:58 +03:00
|
|
|
(void)ctime_r(&req->t, tod);
|
|
|
|
/* trim the newline */
|
|
|
|
tod[strlen(tod)] = '\0';
|
|
|
|
|
|
|
|
syslog(req->severity, "[%s]%s JOBID %s REPORTS ERROR %s: %s", tod,
|
|
|
|
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
|
|
|
ORTE_JOBID_PRINT(req->jdata->jobid),
|
|
|
|
orte_job_state_to_str(req->state),
|
|
|
|
(NULL == req->msg) ? "<N/A>" : req->msg);
|
2015-02-16 23:46:58 +03:00
|
|
|
}
|
2015-02-17 23:44:58 +03:00
|
|
|
|
|
|
|
static void myreport(orte_notifier_request_t *req)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|