Greetings,
As getrusage doesn't work for linux when it comes to determining
the processes memory usage, another solution had to be found. This
patch introduces a 'show memory' for linux. Would anyone mind testing
it? It's against bpl14. George/Jeremey/etc, if you like it, would you
include it in bpl15?
- Chris
--- act.wizard.orig Wed Jul 8 20:11:18 1998
+++ act.wizard.c Wed Jul 8 20:50:35 1998
@@ -8,6 +8,11 @@
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
************************************************************************ */
+/* Show memory needs a system header not included by sysdep.h */
+#ifdef __linux__
+# include <fcntl.h>
+#endif
+
#include "conf.h"
#include "sysdep.h"
@@ -1911,6 +1916,9 @@
struct char_data *vict;
struct obj_data *obj;
char field[MAX_INPUT_LENGTH], value[MAX_INPUT_LENGTH], birth[80];
+#ifdef __linux__
+ char *c_ptr1, *c_ptr2;
+#endif
struct show_struct {
const char *cmd;
@@ -1926,6 +1934,9 @@
{ "godrooms", LVL_GOD },
{ "shops", LVL_IMMORT },
{ "houses", LVL_GOD },
+#ifdef __linux__
+ { "memory", LVL_IMPL },
+#endif
{ "\n", 0 }
};
@@ -2063,6 +2074,31 @@
case 9:
hcontrol_list_houses(ch);
break;
+#ifdef __linux__
+ case 10:
+ i = open("/proc/self/status", O_RDONLY);
+ buf1[read(i, buf1, MAX_STRING_LENGTH)] = '\0';
+ close(i);
+ sprintf(buf, "Memory Usage:\r\n");
+ c_ptr1 = strstr(buf1, "VmSize");
+ c_ptr2 = strchr(c_ptr1, '\n');
+ strncat(buf, c_ptr1, c_ptr2 - c_ptr1);
+ strcat(buf, "\r\n");
+ c_ptr1 = strstr(c_ptr2, "VmRSS");
+ c_ptr2 = strchr(c_ptr1, '\n');
+ strncat(buf, c_ptr1, c_ptr2 - c_ptr1);
+ strcat(buf, "\r\n");
+ c_ptr1 = strstr(c_ptr2, "VmData");
+ c_ptr2 = strchr(c_ptr1, '\n');
+ strncat(buf, c_ptr1, c_ptr2 - c_ptr1);
+ strcat(buf, "\r\n");
+ 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_to_char(buf, ch);
+ break;
+#endif
default:
send_to_char("Sorry, I don't understand that.\r\n", ch);
break;
--
/----------------------------------------------------------------------------\
| 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