Index: configure.ac
===================================================================
--- configure.ac	(revision 139271)
+++ configure.ac	(working copy)
@@ -313,7 +313,7 @@
 AC_FUNC_STRTOD
 AC_FUNC_UTIME_NULL
 AC_FUNC_VPRINTF
-AC_CHECK_FUNCS([asprintf atexit bzero dup2 endpwent ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtol strtoq unsetenv utime vasprintf])
+AC_CHECK_FUNCS([asprintf atexit bzero dup2 endpwent ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtol strtoq sysctl unsetenv utime vasprintf])
 
 AC_CHECK_FUNCS([glob])
 
Index: main/asterisk.c
===================================================================
--- main/asterisk.c	(revision 139271)
+++ main/asterisk.c	(working copy)
@@ -72,6 +72,10 @@
 #include <sys/stat.h>
 #if defined(HAVE_SYSINFO)
 #include <sys/sysinfo.h>
+#else
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <sys/swap.h>
 #endif
 #include <regex.h>
 
@@ -506,6 +510,103 @@
 	ast_cli(a->fd, "  Number of Processes:       %d \n\n", sys_info.procs);
 	return CLI_SUCCESS;
 }
+#else
+/*
+ * swapmode is rewritten by Tobias Weingartner <weingart@openbsd.org>
+ * to be based on the new swapctl(2) system call.
+ */
+	static int
+swapmode(int *used, int *total)
+{
+	struct swapent *swdev;
+	int nswap, rnswap, i;
+
+	nswap = swapctl(SWAP_NSWAP, 0, 0);
+	if (nswap == 0)
+		return 0;
+
+	swdev = calloc(nswap, sizeof(*swdev));
+	if (swdev == NULL)
+		return 0;
+
+	rnswap = swapctl(SWAP_STATS, swdev, nswap);
+	if (rnswap == -1) {
+		free(swdev);
+		return 0;
+	}
+
+	/* if rnswap != nswap, then what? */
+
+	/* Total things up */
+	*total = *used = 0;
+	for (i = 0; i < nswap; i++) {
+		if (swdev[i].se_flags & SWF_ENABLE) {
+			*used += (swdev[i].se_inuse / (1024 / DEV_BSIZE));
+			*total += (swdev[i].se_nblks / (1024 / DEV_BSIZE));
+		}
+	}
+	free(swdev);
+	return 1;
+}
+
+static char *handle_show_sysinfo(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	static int vmtotal_mib[] = {CTL_VM, VM_METER};
+	static int pageshift;
+	struct vmtotal vmtotal;
+	int mib[2], nprocs, pagesize, swapused, swaptotal;
+	int64_t physmem;
+	size_t len;
+
+	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;
+	}
+
+	pagesize = getpagesize();
+	pageshift = 0;
+	while (pagesize > 1) {
+		pageshift++;
+		pagesize >>= 1;
+	}
+
+	/* we only need the amount of log(2)1024 for our conversion */
+	pageshift -= 10;
+
+	/* grab vm totals */
+	len = sizeof(vmtotal);
+	sysctl(vmtotal_mib, 2, &vmtotal, &len, NULL, 0);
+	/* generate swap usage and totals */
+	swapmode(&swapused, &swaptotal); 
+	/* grab total physical memory  */
+	mib[0] = CTL_HW;
+	mib[1] = HW_PHYSMEM64;
+	len = sizeof(physmem);
+	sysctl(mib, 2, &physmem, &len, NULL, 0);
+	/* grab number of processes */
+	mib[0] = CTL_KERN;
+	mib[1] = KERN_NPROCS;
+	len = sizeof(nprocs);
+	sysctl(mib, 2, &nprocs, &len, NULL, 0);
+
+
+	ast_cli(a->fd, "\nSystem Statistics\n");
+	ast_cli(a->fd, "-----------------\n");
+	ast_cli(a->fd, "  Total Physical memory:     %d KiB\n", (int)(physmem/1024));
+	ast_cli(a->fd, "  Total active memory:       %d KiB\n", (vmtotal.t_arm << pageshift));
+	ast_cli(a->fd, "  Total used memory:         %d KiB\n", (vmtotal.t_rm << pageshift));
+	ast_cli(a->fd, "  Free memory:               %d KiB\n", (vmtotal.t_free << pageshift));
+	ast_cli(a->fd, "  Total Swap Space:          %d KiB\n", swaptotal);
+	ast_cli(a->fd, "  Free Swap Space:           %d KiB\n\n", (swaptotal-swapused));
+	ast_cli(a->fd, "  Number of Processes:       %d \n\n", nprocs);
+	return CLI_SUCCESS;
+}
 #endif
 
 struct profile_entry {
@@ -1890,9 +1991,7 @@
 #if !defined(LOW_MEMORY)
 	AST_CLI_DEFINE(handle_show_version_files, "List versions of files used to build Asterisk"),
 	AST_CLI_DEFINE(handle_show_threads, "Show running threads"),
-#if defined(HAVE_SYSINFO)
 	AST_CLI_DEFINE(handle_show_sysinfo, "Show System Information"),
-#endif
 	AST_CLI_DEFINE(handle_show_profile, "Display profiling info"),
 	AST_CLI_DEFINE(handle_show_settings, "Show some core settings"),
 	AST_CLI_DEFINE(handle_clear_profile, "Clear profiling info"),
