summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins2 <jenkins2@gerrit.asterisk.org>2017-12-13 12:25:11 -0600
committerGerrit Code Review <gerrit2@gerrit.digium.api>2017-12-13 12:25:11 -0600
commitc1972ebbab8ff672a927ee567cb1bd3a819ec271 (patch)
tree0ab6138d37dce76bb7d4dfb698540c35fff2e486
parent8986fcfa7a91f940ff813e150b072154aec349e6 (diff)
parentc6e137ee1627d3250d8b9112dd411adcdb8b1bdc (diff)
Merge "CLI: Fix 'core show sysinfo' function ordering." into 15
-rw-r--r--main/asterisk.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/main/asterisk.c b/main/asterisk.c
index 187a8ad6b..006a1b03a 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -733,6 +733,27 @@ static char *handle_show_sysinfo(struct ast_cli_entry *e, int cmd, struct ast_cl
int totalswap = 0;
#if defined(HAVE_SYSINFO)
struct sysinfo sys_info;
+#elif defined(HAVE_SYSCTL)
+ static int pageshift;
+ struct vmtotal vmtotal;
+ struct timeval boottime;
+ time_t now;
+ int mib[2], pagesize, usedswap = 0;
+ size_t len;
+#endif
+
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "core show sysinfo";
+ e->usage =
+ "Usage: core show sysinfo\n"
+ " List current system information.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+#if defined(HAVE_SYSINFO)
sysinfo(&sys_info);
uptime = sys_info.uptime / 3600;
physmem = sys_info.totalram * sys_info.mem_unit;
@@ -741,12 +762,6 @@ static char *handle_show_sysinfo(struct ast_cli_entry *e, int cmd, struct ast_cl
freeswap = (sys_info.freeswap * sys_info.mem_unit) / 1024;
nprocs = sys_info.procs;
#elif defined(HAVE_SYSCTL)
- static int pageshift;
- struct vmtotal vmtotal;
- struct timeval boottime;
- time_t now;
- int mib[2], pagesize, usedswap = 0;
- size_t len;
/* calculate the uptime by looking at boottime */
time(&now);
mib[0] = CTL_KERN;
@@ -794,17 +809,6 @@ static char *handle_show_sysinfo(struct ast_cli_entry *e, int cmd, struct ast_cl
#endif
#endif
- switch (cmd) {
- case CLI_INIT:
- e->command = "core show sysinfo";
- e->usage =
- "Usage: core show sysinfo\n"
- " List current system information.\n";
- return NULL;
- case CLI_GENERATE:
- return NULL;
- }
-
ast_cli(a->fd, "\nSystem Statistics\n");
ast_cli(a->fd, "-----------------\n");
ast_cli(a->fd, " System Uptime: %ld hours\n", uptime);