Hi,
I configure check memory service in RHEL and oracle linux by check_linux_stats.pl. According to my observation, I find the memory used % is not accuracy. Below is the data that I capture from our servers. Kindly correct me if I mistake understand the concept.
1. Red Hat Linux
Kernel Vesion: Linux cmnndns01 2.6.32-431.17.1.el6.x86_64 #1 SMP Fri Apr 11 17:27:00 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux
[root@cmnndns01 etc]# /usr/local/nagios/libexec/check_linux_stats.pl -M -w 90 -c 95
MEMORY OK : Mem used: 11.38%, Swap used: 0.00% |MemUsed=11.38%;90;95 SwapUsed=0.00%;; MemCached=10.78% SwapCached=0.00% Active=14.29%
From check_linux_stats.pl result, memory used is 11.38%
[root@cmnndns01 etc]# free -m
total used free shared buffers cached
Mem: 7870 1739 6130 0 409 848
-/+ buffers/cache: 482 7387
Swap: 8191 0 8191
Result from "free -m", 1739/7870 x 100% = 22%
07:00:01 AM kbmemfree kbmemused %memused kbbuffers kbcached kbcommit %commit
10:00:01 AM 6277964 1780976 22.10 419076 868072 480724 2.92
10:10:01 AM 6277872 1781068 22.10 419076 868080 482300 2.93
10:20:01 AM 6278252 1780688 22.10 419076 868100 431320 2.62
10:30:01 AM 6279136 1779804 22.08 419076 868104 430880 2.62
10:40:01 AM 6277896 1781044 22.10 419076 868116 481728 2.93
Result from sar -r, %memused = 22%
2. Oracle Linux
Linux lcsridb14 3.8.13-16.2.1.el6uek.x86_64 #1 SMP Thu Nov 7 17:01:44 PST 2013 x86_64 x86_64 x86_64 GNU/Linux
[root@lcsridb14 ~]# /usr/local/nagios/libexec/check_linux_stats.pl -M -w 90 -c 95
MEMORY OK : Mem used: 17.80%, Swap used: 0.00% |MemUsed=17.80%;90;95 SwapUsed=0.00%;; MemCached=81.36% SwapCached=0.00% Active=36.45%
From check_linux_stats.pl result, memory used is 17.80%
[root@lcsridb14 ~]# free -m
total used free shared buffers cached
Mem: 12015 11873 142 0 617 9776
-/+ buffers/cache: 1480 10535
Swap: 32767 0 32767
Result from "free -m", 11873/12015 x 100% = 98.8%
10:00:01 AM kbmemfree kbmemused %memused kbbuffers kbcached kbcommit %commit
10:05:01 AM 154448 12149708 98.74 629976 10008400 708344 1.54
10:10:01 AM 140128 12164028 98.86 630000 10009576 722492 1.58
10:15:01 AM 337788 11966368 97.25 630032 9789020 745932 1.63
10:20:01 AM 153108 12151048 98.76 630096 10010076 708320 1.54
10:25:01 AM 156284 12147872 98.73 630128 10005980 708308 1.54
10:30:01 AM 210552 12093604 98.29 630164 9888484 942148 2.05
Result from sar -r, %memused = 98.29%
If this script is not suitable to run for these two version of Linux because we are unable to get alert if they are in high memory usage.
Where can I download a correct scripts for check memory usage?
Question for check_linux_stats.pl
Re: Question for check_linux_stats.pl
They are returning different values for me as well, the check_linux_stats.pl script is actually pulling from /proc/meminfo.
Can you validate the contents of meminfo with what you are seeing from free -m/sar -r?
Can you validate the contents of meminfo with what you are seeing from free -m/sar -r?
Code: Select all
cat /proc/meminfoRe: Question for check_linux_stats.pl
I should note that it's actually the perl module Sys-Statistics-Linux-MemStats that is pulling from /proc/meminfo.
So it's doing the calculations directly from the /proc/meminfo output.
Code: Select all
$meminfo{memused} = sprintf('%u', $meminfo{memtotal} - $meminfo{memfree});
$meminfo{memusedper} = sprintf('%.2f', 100 * $meminfo{memused} / $meminfo{memtotal});
Re: Question for check_linux_stats.pl
Hi,
I think /proc/meminfo, sar -r and free -k are matched to each other, it should be calculation mistake in script
I think /proc/meminfo, sar -r and free -k are matched to each other, it should be calculation mistake in script
Code: Select all
[root@lcsridb14 libexec]# cat /proc/meminfo
MemTotal: 12304156 kB
MemFree: 128716 kB
Buffers: 639328 kB
Cached: 9960676 kB
SwapCached: 24 kB
Active: 4508564 kB
Inactive: 6717436 kB
Active(anon): 283776 kB
Inactive(anon): 342780 kB
Active(file): 4224788 kB
Inactive(file): 6374656 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 33554428 kB
SwapFree: 33554352 kB
Dirty: 78052 kB
Writeback: 0 kB
AnonPages: 626388 kB
Mapped: 26828 kB
Shmem: 404 kB
Slab: 763844 kB
SReclaimable: 408412 kB
SUnreclaim: 355432 kB
KernelStack: 2648 kB
PageTables: 8196 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 39706504 kB
Committed_AS: 754468 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 339000 kB
VmallocChunk: 34359325580 kB
HardwareCorrupted: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 10588 kB
DirectMap2M: 12570624 kB
Code: Select all
10:30:01 AM kbmemfree kbmemused %memused kbbuffers kbcached kbcommit %commit
10:35:01 AM 152484 12151672 98.76 638996 9975480 712616 1.55
10:40:01 AM 157768 12146388 98.72 639036 9933704 751320 1.64
10:45:01 AM 154608 12149548 98.74 639056 9973228 712688 1.55
10:50:01 AM 156260 12147896 98.73 639072 9971924 712628 1.55
10:55:01 AM 131160 12172996 98.93 639084 9960088 751296 1.64
11:00:01 AM 155456 12148700 98.74 639112 9972548 712676 1.55
11:05:01 AM 156672 12147484 98.73 639168 9970224 712640 1.55
11:10:01 AM 157812 12146344 98.72 639204 9970288 712640 1.55
11:15:01 AM 96920 12207236 99.21 639228 9962144 946472 2.06
11:20:01 AM 147728 12156428 98.80 639248 9973440 722196 1.57
11:25:01 AM 153880 12150276 98.75 639256 9971168 717452 1.56
11:30:01 AM 149268 12154888 98.79 639292 9974720 718216 1.57
11:35:01 AM 357404 11946752 97.10 639328 9733316 754168 1.64
Average: 169680 12134476 98.62 637452 9950236 734261 1.60
Code: Select all
[root@lcsridb14 libexec]# free -k
total used free shared buffers cached
Mem: 12304156 11893816 410340 404 639340 9679356
-/+ buffers/cache: 1575120 10729036
Swap: 33554428 76 33554352
Code: Select all
[root@lcsridb14 libexec]# ./check_linux_stats.pl -M -w 90 -c 95
MEMORY OK : Mem used: 17.74%, Swap used: 0.00% |MemUsed=17.74%;90;95 SwapUsed=0.00%;; MemCached=81.05% SwapCached=0.00% Active=36.48%
Re: Question for check_linux_stats.pl
The plugin subtracts the cached memory first, which explains the discrepancy.[root@cmnndns01 etc]# free -m
total used free shared buffers cached
Mem: 7870 1739 6130 0 409 848
-/+ buffers/cache: 482 7387
Swap: 8191 0 8191
Result from "free -m", 1739/7870 x 100% = 22%
( (free - cached) / total ) * 100%
( (1739 - 848) / 7870 ) * 100% = (891 / 7870) * 100% = 0.1132*100 = 11.3%
There is some rounding going on but that's pretty close.
[root@cmnndns01 etc]# /usr/local/nagios/libexec/check_linux_stats.pl -M -w 90 -c 95
MEMORY OK : Mem used: 11.38%, Swap used: 0.00% |MemUsed=11.38%;90;95 SwapUsed=0.00%;; MemCached=10.78% SwapCached=0.00% Active=14.29%
From check_linux_stats.pl result, memory used is 11.38%
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Question for check_linux_stats.pl
Hi lmiltchev,
Thank you for your explanation.
Thank you for your explanation.