diff options
author | Olle Johansson <oej@edvina.net> | 2007-05-04 13:47:11 +0000 |
---|---|---|
committer | Olle Johansson <oej@edvina.net> | 2007-05-04 13:47:11 +0000 |
commit | 6da70edbcfe70609ff12bad5d1bb8b7d38fc4206 (patch) | |
tree | 822eafc1fc8c9164a74a620a3ca08c91d9d2cd74 /main/manager.c | |
parent | 51f99c526519cd6e7ac1efe4475c7280278fe777 (diff) |
Add "CoreStatus" - from the moremanager branch.
This can be extended with more information, ideas and patches are welcome, as usual :-)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@63031 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/manager.c')
-rw-r--r-- | main/manager.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/main/manager.c b/main/manager.c index f229fa5e7..6a03c8a3c 100644 --- a/main/manager.c +++ b/main/manager.c @@ -2204,6 +2204,42 @@ static int action_coresettings(struct mansession *s, const struct message *m) return 0; } +static char mandescr_corestatus[] = +"Description: Query for Core PBX status.\n" +"Variables: (Names marked with * are optional)\n" +" *ActionID: ActionID of this transaction\n"; + +/*! \brief Show PBX core status information */ +static int action_corestatus(struct mansession *s, const struct message *m) +{ + const char *actionid = astman_get_header(m, "ActionID"); + char idText[150]; + char startuptime[150]; + char reloadtime[150]; + struct tm tm; + + if (!ast_strlen_zero(actionid)) { + snprintf(idText, sizeof(idText), "ActionID: %s\r\n", actionid); + } + localtime_r(&ast_startuptime, &tm); + strftime(startuptime, sizeof(startuptime), "%H:%M:%S", &tm); + localtime_r(&ast_lastreloadtime, &tm); + strftime(reloadtime, sizeof(reloadtime), "%H:%M:%S", &tm); + + astman_append(s, "Response: Success\r\n" + "%s" + "CoreStartupTime: %s\r\n" + "CoreReloadTime: %s\r\n" + "CoreCurrentCalls: %d\r\n" + "", + idText, + startuptime, + reloadtime, + ast_active_channels() + ); + return 0; +} + /* * Done with the action handlers here, we start with the code in charge @@ -3172,6 +3208,7 @@ int init_manager(void) ast_manager_register2("UserEvent", EVENT_FLAG_USER, action_userevent, "Send an arbitrary event", mandescr_userevent); ast_manager_register2("WaitEvent", 0, action_waitevent, "Wait for an event to occur", mandescr_waitevent); ast_manager_register2("CoreSettings", EVENT_FLAG_SYSTEM, action_coresettings, "Show PBX core settings (version etc)", mandescr_coresettings); + ast_manager_register2("CoreStatus", EVENT_FLAG_SYSTEM, action_corestatus, "Show PBX core status variables", mandescr_corestatus); ast_cli_register_multiple(cli_manager, sizeof(cli_manager) / sizeof(struct ast_cli_entry)); ast_extension_state_add(NULL, NULL, manager_state_cb, NULL); |