check_memory

Taiji Otsuki taiji at kta.att.ne.jp
Wed Apr 28 04:33:48 CEST 2004


Hi all,

This might be a kind of bug for check_memory plugin.
When the memory is over 2GB and used most of them, this check_memory
might not shift 10( <<10 ) in check_memory/sysinfo.c propely.
I'm not sure but this plugin have developed before in the era kernel
didn't suit over 2GB memory, so OS might not calculate ....


Here is meminfo for ex.
------------------------------------------------------------------
$ cat /proc/meminfo
        total:    used:    free:  shared: buffers:  cached:
Mem:  3889307648 3402760192 486547456 1283411968 643502080 1319305216
Swap: 2154938368  4419584 2150518784
MemTotal:      3798152 kB
MemFree:        475144 kB
MemShared:     1253332 kB
Buffers:        628420 kB
Cached:        1284072 kB
SwapCached:       4312 kB
Active:        2148464 kB
Inact_dirty:    891972 kB
Inact_clean:    129700 kB
Inact_target:   949476 kB
HighTotal:     2949056 kB
HighFree:       472252 kB
LowTotal:       849096 kB
LowFree:          2892 kB
SwapTotal:     2104432 kB
SwapFree:      2100116 kB
BigPagesFree:        0 kB
------------------------------------------------------------------

when I run check_memory, result in like below
--
$ ./check_memory 20 10
Status: OK - 225% memory free.
--


So put the debug in check_memory.c between the line 66 and 69 like

--- check_memory/check_memory.c
+++ check_memory/check_memory.c.debug

-- 66,69 --
++ 66,78 ++
--------------------------------------
	memfree+=(mem[meminfo_main][meminfo_cached]+mem[meminfo_swap][meminfo_buffers])>>10;
+/*debug*/
+        fprintf(stdout, "  MainTotal: %i\n",mem[meminfo_main][meminfo_total] );
+        fprintf(stdout, "  SwapTotal: %i\n",+mem[meminfo_swap][meminfo_total]);
+        fprintf(stdout, "  MainFree : %i\n",mem[meminfo_main][meminfo_free] );
+        fprintf(stdout, "  SwapFree : %i\n",mem[meminfo_swap][meminfo_free] );
+        fprintf(stdout, "  MainCache: %i\n",mem[meminfo_main][meminfo_cached]);
+        fprintf(stdout, "  MainBuff :%i\n",mem[meminfo_swap][meminfo_buffers]);
+        fprintf(stdout, "total:  %i\n", memtotal );
+        fprintf(stdout, "free:  %i\n", memfree );
	pfree = (memfree * 100) / memtotal;
------------------------------------------------

result is 
$ ./check_memory 20 10
  MainTotal: -405659648
  SwapTotal: -2140028928
  MainFree : 482521088
  SwapFree : -2144448512
  MainCache: 1318895616
  MainBuff :0
total:  1708280
free:  3859312
Status: OK - 225% memory free.
--------------------------------------

First, MainTotal,SwapTotal, SwapFree and MainBuff looks also 
wrong for unskilled eyes. 

as for MainBuff, line 66: should be not [meminfo_swap] but [meminfo_main] ?,


--- check_memory/check_memory.c.debug             
+++ check_memory/check_memory.c.debug_withMemBuff 
---------------------
@@@ 66,1 @@@
- memfree +=(mem[meminfo_main][meminfo_cached]+mem[meminfo_swap][meminfo_buffers]) 
+ memfree +=(mem[meminfo_main][meminfo_cached]+mem[meminfo_main][meminfo_buffers]) 
--------------------


And in check_memory/sysinfo.c, I just get rid of "<<=10" 
in each line, 

--- check_memory/sysinfo.c  
+++ check_memory/sysinfo.c.without10shift 
-----------------------------------------
@@@ 221,1 @@@
-	row[meminfo_main][meminfo_total]<<=10;
+	row[meminfo_main][meminfo_total];
@@@ 227,1 @@@
-	row[meminfo_main][meminfo_free]<<=10;
+	row[meminfo_main][meminfo_free];
@@@ 233,1 @@@
-	row[meminfo_main][meminfo_shared]<<=10;
+	row[meminfo_main][meminfo_shared];
@@@ 239,1 @@@
-	row[meminfo_main][meminfo_buffers]<<=10;
+	row[meminfo_main][meminfo_buffers];
@@@ 245,1 @@@
-	row[meminfo_main][meminfo_cached]<<=10;
+	row[meminfo_main][meminfo_cached];
@@@ 251,1 @@@
-	row[meminfo_swap][meminfo_total]<<=10;
+	row[meminfo_swap][meminfo_total];
@@@ 254,1 @@@
-	row[meminfo_swap][meminfo_free]<<=10;
+	row[meminfo_swap][meminfo_free];
@@@ -266,2  +266,4@@@ for debug
+ /*debug*/
+ fprintf(stdout, "  _MainTotal: %i\n",row[meminfo_main][meminfo_total]);
    return row;					/* NULL return ==> error */
}
-------------------------

It looks work, result is 
$ ./check_memory 20 10
  _MainTotal: 3798152
  MainTotal: 3798152
  SwapTotal: 2104432
  MainFree : 471804
  SwapFree : 2100116
  MainCache: 1288004
  MainBuff :628468
total:  5764
free:  4382
Status: OK - 76% memory free.
-------------------------------------------------------

Anobody has solution?


taiji



-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list