monit-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: monit and grsecurity


From: Martin Pala
Subject: Re: monit and grsecurity
Date: Mon, 08 Sep 2003 20:45:35 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030827 Debian/1.4-3

It seems good - thanks :)

What does the other developers think about it? I'm +1 to add it to 4.0 (this is sort of bugfix => it will not break code freeze stage much).

Martin

Arkadiusz Miskiewicz wrote:

On Monday 08 of September 2003 18:15, Arkadiusz Miskiewicz wrote:
I suggest adding /proc/meminfo parsing (from ie. procps) to check how many
ram we have instead of stating /proc/kcore before 4.0 release (which I'm
willing to test btw).
Here is patch:

diff -urN monit-4.0.org/process/sysdep_LINUX.c monit-4.0/process/sysdep_LINUX.c
--- monit-4.0.org/process/sysdep_LINUX.c        2003-09-08 19:20:44.000000000 
+0200
+++ monit-4.0/process/sysdep_LINUX.c    2003-09-08 19:20:23.000000000 +0200
@@ -84,24 +84,37 @@
 *  @file
 */

-#define PAGE_TO_KBYTE_SHIFT PAGE_SHIFT-10
+#define FREEMEM         "MemFree:"
+#define FREESWAP        "SwapFree:"

int init_process_info_sysdep(void) {

-  struct stat buf;
- + int memfd;
+  char buf[1024], *ptr1, *ptr2;

-  /* I hope this is okay hack to get the total memsize. (-: */
+  if ((memfd = open("/proc/meminfo", O_RDONLY)) == -1) {
+      return FALSE;
+  }

-  if ( stat("/proc/kcore", &buf) != 0 ) {
+  /* read the file */
+  if (read(mem, buf, sizeof(buf)) < 0) {
+      close(memfd);
+      return FALSE;
+  }

-    return FALSE;
+  close(memfd);
+ + ptr1 = strstr(buf, FREEMEM);
+  ptr2 = strstr(buf, FREESWAP);

+  if (!ptr1 || !ptr2) {
+      return FALSE;
  }

-  num_cpus= sysconf(_SC_NPROCESSORS_CONF);
+  /* we only care about integer values */
+ mem_kbyte_max = atoi(ptr1+strlen(FREEMEM)) /* + atoi(ptr2+strlen(FREESWAP)) */ ;

-  mem_kbyte_max = buf.st_size>>10;
+  num_cpus= sysconf(_SC_NPROCESSORS_CONF);

  return TRUE;


Thanks!







reply via email to

[Prev in Thread] Current Thread [Next in Thread]