mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
add optional timestamps to manager events (issue #5535, simplified)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7750 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -20,6 +20,10 @@ enabled = no
|
||||
port = 5038
|
||||
bindaddr = 0.0.0.0
|
||||
;displayconnects = yes
|
||||
;
|
||||
; Add a Unix epoch timestamp to events (not action responses)
|
||||
;
|
||||
;timestampevents = yes
|
||||
|
||||
;[mark]
|
||||
;secret = mysecret
|
||||
|
19
manager.c
19
manager.c
@@ -84,6 +84,7 @@ static int enabled = 0;
|
||||
static int portno = DEFAULT_MANAGER_PORT;
|
||||
static int asock = -1;
|
||||
static int displayconnects = 1;
|
||||
static int timestampevents = 0;
|
||||
|
||||
static pthread_t t;
|
||||
AST_MUTEX_DEFINE_STATIC(sessionlock);
|
||||
@@ -1521,8 +1522,15 @@ int manager_event(int category, char *event, char *fmt, ...)
|
||||
continue;
|
||||
|
||||
if (ast_strlen_zero(tmp)) {
|
||||
struct timeval now;
|
||||
|
||||
ast_build_string(&tmp_next, &tmp_left, "Event: %s\r\nPrivilege: %s\r\n",
|
||||
event, authority_to_str(category, auth, sizeof(auth)));
|
||||
if (timestampevents) {
|
||||
now = ast_tvnow();
|
||||
ast_build_string(&tmp_next, &tmp_left, "Timestamp: %ld.%06lu\r\n",
|
||||
now.tv_sec, now.tv_usec);
|
||||
}
|
||||
va_start(ap, fmt);
|
||||
ast_build_string_va(&tmp_next, &tmp_left, fmt, ap);
|
||||
va_end(ap);
|
||||
@@ -1704,11 +1712,12 @@ int init_manager(void)
|
||||
}
|
||||
ast_log(LOG_NOTICE, "Use of portno in manager.conf deprecated. Please use 'port=%s' instead.\n", val);
|
||||
}
|
||||
/* Parsing the displayconnects */
|
||||
if ((val = ast_variable_retrieve(cfg, "general", "displayconnects"))) {
|
||||
displayconnects = ast_true(val);;
|
||||
}
|
||||
|
||||
|
||||
if ((val = ast_variable_retrieve(cfg, "general", "displayconnects")))
|
||||
displayconnects = ast_true(val);
|
||||
|
||||
if ((val = ast_variable_retrieve(cfg, "general", "timestampevents")))
|
||||
timestampevents = ast_true(val);
|
||||
|
||||
ba.sin_family = AF_INET;
|
||||
ba.sin_port = htons(portno);
|
||||
|
Reference in New Issue
Block a user