mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 20:04:50 +00:00
Merge "core/manager: Add uptime field to FullyBooted"
This commit is contained in:
@@ -260,6 +260,12 @@ int daemon(int, int); /* defined in libresolv of all places */
|
||||
<parameter name="Status">
|
||||
<para>Informational message</para>
|
||||
</parameter>
|
||||
<parameter name="Uptime">
|
||||
<para>Seconds since start</para>
|
||||
</parameter>
|
||||
<parameter name="LastReload">
|
||||
<para>Seconds since last reload</para>
|
||||
</parameter>
|
||||
</syntax>
|
||||
</managerEventInstance>
|
||||
</managerEvent>
|
||||
@@ -1020,9 +1026,25 @@ static char *handle_clear_profile(struct ast_cli_entry *e, int cmd, struct ast_c
|
||||
static void publish_fully_booted(void)
|
||||
{
|
||||
RAII_VAR(struct ast_json *, json_object, NULL, ast_json_unref);
|
||||
int uptime = 0;
|
||||
int lastreloaded = 0;
|
||||
struct timeval tmp;
|
||||
struct timeval curtime = ast_tvnow();
|
||||
|
||||
json_object = ast_json_pack("{s: s}",
|
||||
"Status", "Fully Booted");
|
||||
if (ast_startuptime.tv_sec) {
|
||||
tmp = ast_tvsub(curtime, ast_startuptime);
|
||||
uptime = (int) tmp.tv_sec;
|
||||
}
|
||||
|
||||
if (ast_lastreloadtime.tv_sec) {
|
||||
tmp = ast_tvsub(curtime, ast_lastreloadtime);
|
||||
lastreloaded = (int) tmp.tv_sec;
|
||||
}
|
||||
|
||||
json_object = ast_json_pack("{s: s, s: i, s: i}",
|
||||
"Status", "Fully Booted",
|
||||
"Uptime", uptime,
|
||||
"LastReload", lastreloaded);
|
||||
ast_manager_publish_event("FullyBooted", EVENT_FLAG_SYSTEM, json_object);
|
||||
}
|
||||
|
||||
@@ -4221,6 +4243,9 @@ static void asterisk_daemon(int isroot, const char *runuser, const char *rungrou
|
||||
char *buf;
|
||||
int moduleresult; /*!< Result from the module load subsystem */
|
||||
|
||||
/* Set time as soon as possible */
|
||||
ast_lastreloadtime = ast_startuptime = ast_tvnow();
|
||||
|
||||
/* This needs to remain as high up in the initial start up as possible.
|
||||
* daemon causes a fork to occur, which has all sorts of unintended
|
||||
* consequences for things that interact with threads. This call *must*
|
||||
@@ -4689,7 +4714,6 @@ static void asterisk_daemon(int isroot, const char *runuser, const char *rungrou
|
||||
__ast_mm_init_phase_2();
|
||||
#endif /* defined(__AST_DEBUG_MALLOC) */
|
||||
|
||||
ast_lastreloadtime = ast_startuptime = ast_tvnow();
|
||||
ast_cli_register_multiple(cli_asterisk_shutdown, ARRAY_LEN(cli_asterisk_shutdown));
|
||||
ast_cli_register_multiple(cli_asterisk, ARRAY_LEN(cli_asterisk));
|
||||
ast_register_cleanup(main_atexit);
|
||||
|
@@ -4157,10 +4157,26 @@ static int action_login(struct mansession *s, const struct message *m)
|
||||
&& ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)) {
|
||||
struct ast_str *auth = ast_str_alloca(MAX_AUTH_PERM_STRING);
|
||||
const char *cat_str = authority_to_str(EVENT_FLAG_SYSTEM, &auth);
|
||||
long uptime = 0;
|
||||
long lastreloaded = 0;
|
||||
struct timeval tmp;
|
||||
struct timeval curtime = ast_tvnow();
|
||||
|
||||
if (ast_startuptime.tv_sec) {
|
||||
tmp = ast_tvsub(curtime, ast_startuptime);
|
||||
uptime = tmp.tv_sec;
|
||||
}
|
||||
|
||||
if (ast_lastreloadtime.tv_sec) {
|
||||
tmp = ast_tvsub(curtime, ast_lastreloadtime);
|
||||
lastreloaded = tmp.tv_sec;
|
||||
}
|
||||
|
||||
astman_append(s, "Event: FullyBooted\r\n"
|
||||
"Privilege: %s\r\n"
|
||||
"Status: Fully Booted\r\n\r\n", cat_str);
|
||||
"Uptime: %ld\r\n"
|
||||
"LastReload: %ld\r\n"
|
||||
"Status: Fully Booted\r\n\r\n", cat_str, uptime, lastreloaded);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user