Greetings,
How's this? (patch against pl14)
- Chris
diff -uN src.orig/act.wizard.c src/act.wizard.c
--- src.orig/act.wizard.c Mon Jun 8 22:43:33 1998
+++ src/act.wizard.c Mon Jun 8 23:37:17 1998
@@ -57,6 +57,7 @@
void reset_zone(int zone);
void roll_real_abils(struct char_data *ch);
int parse_class(char arg);
+void show_memory(struct char_data *ch);
/* local functions */
int perform_set(struct char_data *ch, struct char_data *vict, int mode,
char *val_arg);
@@ -1926,6 +1927,7 @@
{ "godrooms", LVL_GOD },
{ "shops", LVL_IMMORT },
{ "houses", LVL_GOD },
+ { "memory", LVL_IMPL },
{ "\n", 0 }
};
@@ -2062,6 +2064,9 @@
break;
case 9:
hcontrol_list_houses(ch);
+ break;
+ case 10:
+ show_memory(ch);
break;
default:
send_to_char("Sorry, I don't understand that.\r\n", ch);
diff -uN src.orig/comm.c src/comm.c
--- src.orig/comm.c Mon Jun 8 22:43:33 1998
+++ src/comm.c Mon Jun 8 23:41:06 1998
@@ -140,6 +140,7 @@
#if defined(POSIX)
sigfunc *my_signal(int signo, sigfunc * func);
#endif
+void show_memory(struct char_data *ch);
/* extern fcnts */
void reboot_wizlists(void);
@@ -2246,3 +2247,82 @@
strlen(buf), strlen(buf1), strlen(buf2), strlen(arg));
#endif
}
+
+/*
+ * The following are the show_memory() functions for the various
+ * platforms. Must be defined in comm.c as only comm.c includes
+ * the system headers that are needed for the functionality.
+ */
+
+#ifdef __linux__
+
+void show_memory(struct char_data *ch)
+{
+ int i;
+ char *c_ptr1, *c_ptr2;
+
+ /* Reading the info from /proc/self/status */
+ i = open("/proc/self/status", O_RDONLY);
+ buf1[read(i, buf1, MAX_STRING_LENGTH)] = '\0';
+ close(i);
+
+ /* Writing Memory usage into buf */
+ sprintf(buf, "Memory Usage:\r\n");
+
+ /* Writing VmSize into buf */
+ c_ptr1 = strstr(buf1, "VmSize");
+ c_ptr2 = strchr(c_ptr1, '\n');
+ strncat(buf, c_ptr1, c_ptr2 - c_ptr1);
+ strcat(buf, "\r\n");
+
+ /* Writing VmRSS into buf */
+ c_ptr1 = strstr(c_ptr2, "VmRSS");
+ c_ptr2 = strchr(c_ptr1, '\n');
+ strncat(buf, c_ptr1, c_ptr2 - c_ptr1);
+ strcat(buf, "\r\n");
+
+ /* Size of Data */
+ c_ptr1 = strstr(c_ptr2, "VmData");
+ c_ptr2 = strchr(c_ptr1, '\n');
+ strncat(buf, c_ptr1, c_ptr2 - c_ptr1);
+ strcat(buf, "\r\n");
+
+ /* Size of Stack */
+ c_ptr1 = strstr(c_ptr2, "VmStk");
+ c_ptr2 = strchr(c_ptr1, '\n');
+ strncat(buf, c_ptr1, c_ptr2 - c_ptr1);
+ strcat(buf, "\r\n");
+
+ /* send all to the player */
+ send_to_char(buf, ch);
+ return;
+}
+
+#elif defined RUSAGE_SELF /* if not linux, unix with getrusage() ? */
+
+void show_memory(struct char_data *ch)
+{
+ struct rusage ru;
+
+ getrusage(RUSAGE_SELF, &ru);
+ sprintf(buf, "Memory Usage:\r\n"
+ "Maximum resident set size: %ld\r\n"
+ "Integral shared memory size: %ld\r\n"
+ "Integral unshared data size: %ld\r\n"
+ "Integral unshared stack size: %ld\r\n",
+ ru.ru_maxrss, ru.ru_ixrss, ru.ru_idrss, ru.ru_isrss);
+ send_to_char(buf, ch);
+ return;
+}
+
+#else
+
+void show_memory(struct char_data *ch)
+{
+ send_to_char("Sorry, not implemented for this OS.\r\n", ch);
+ return;
+}
+
+#endif
+/* please add other versions of show memory here. */
+
--
/----------------------------------------------------------------------------\
| Christian Loth | Meet me as the >Shadowdancer< in the |
| chris@rom.mud.de | REALM OF MAGIC |
| http://rom.mud.de/~chris | telnet rom.mud.de 4000 |
| | http://rom.mud.de/ |
| "The road goes ever on and on!" - Bilbo Baggins |
\----------------------------------------------------------------------------/
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST