From d2873698ed3560ebc32d551e062ea1eb68214bf9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Arkadiusz=20Mi=C5=9Bkiewicz?= Date: Mon, 8 Sep 2003 17:28:05 +0000 Subject: [PATCH] - use /proc/meminfo instead of /proc/kcore Changed files: monit-meminfo-vs-kcore.patch -> 1.1 monit.spec -> 1.11 --- monit-meminfo-vs-kcore.patch | 49 ++++++++++++++++++++++++++++++++++++ monit.spec | 4 ++- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 monit-meminfo-vs-kcore.patch diff --git a/monit-meminfo-vs-kcore.patch b/monit-meminfo-vs-kcore.patch new file mode 100644 index 0000000..a08d668 --- /dev/null +++ b/monit-meminfo-vs-kcore.patch @@ -0,0 +1,49 @@ +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(memfd, 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; + diff --git a/monit.spec b/monit.spec index d487f72..7a85a23 100644 --- a/monit.spec +++ b/monit.spec @@ -3,13 +3,14 @@ Summary: Process monitor and restart utility Summary(pl): Narzêdzie do monitorowania procesów i ich restartowania Name: monit Version: 4.0 -Release: 0.%{snap}.1 +Release: 0.%{snap}.2 Group: Applications/Console License: GPL # http://www.tildeslash.com/monit/dist/ Source0: %{name}-%{version}-%{snap}.tar.gz # Source0-md5: 94efc952513af389f7a9e562692ccefc Source1: %{name}.init +Patch0: %{name}-meminfo-vs-kcore.patch URL: http://www.tildeslash.com/monit/ BuildRequires: bison BuildRequires: flex @@ -31,6 +32,7 @@ przestaje odpowiada %prep %setup -q +%patch0 -p1 %build ./make_man -- 2.44.0