[MEMORY]

From: Nate (nate@imagegfx.com)
Date: 06/07/99


Recently I have been on a 'quest' to find what would work properly to
display
server memory usages, and the likes. I have explored every possiblity
from
mstats, to now, the procs directory.

I have yet to test this, but I would ask if this seems fezable to do and
work correctly.

FILE *StatusFile;
struct stat s;
/* Misc values for free memory, used memory, size of  kcore, etc */

/* Getting the size of kcore should give us the total amount of RAM
installed on
    our server */
if (stat("/proc/kcore", &s) < 0) {
  log("Cannot Stat /proc/kcore");
  send_to_char("kcore unabled to be opened or not present.\r\n", ch);
  return;
}

sysmem = s.st_size;

/* check meminfo for total used stuff on server, etc. if you like
if ((meminfo = fopen("/proc/meminfo", "r")) == NULL) {
  log("/proc/meminfo seems to be not present or unreadable.");
  send_to_char("meminfo unable to be opened or not present,
continuing.\r\n", ch);
}else {
  /* scan thru /proc/meminfo here, getting such things as shared memory,
buffers, cached,
      swap info, (total and free) */
}

/* get our specific processes information */
sprintf(filename, "/proc/%d/status", pid_of_mud);
if ((StatusFile = fopen(filename, "r")) == NULL ) {
  log("%s cannot be found or read.", filename);
  send_to_char("Unabled to get memory information on MUD.\r\n");
  return;
}

/* make parser that scans status file, and reports only information that
is valueable, like
    VmRSS, VmSize, VmData, VmStk, VmExe, Proc Name, Current State, PPid
(if present),
    Uid/Gid information */

Tym


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST