Skip to content

Cache reported as negative #17

Open
@abchk1234

Description

@abchk1234

Hi!

For some time, I was facing issue that check_mem was reporting high memory usage, while free reported that memory usage was ok. On closer inspection, I found that the cache reported by check_mem was negative:

# /usr/local/nagios/libexec/check_mem -u -C -w 90 -c 95
WARNING - 92.9% (11695180 kB) used!|TOTAL=12582912KB;;;; USED=11695180KB;11324620;11953766;; FREE=887732KB;;;; CACHES=-2709560KB;;;;

The negative cache value is what causes the issue; if I choose to ignore cache dont get the warning:

# /usr/local/nagios/libexec/check_mem -u -w 90 -c 95
OK - 71.5% (8997588 kB) used.|TOTAL=12582912KB;;;; USED=8997588KB;11324620;11953766;; FREE=3585324KB;;;; CACHES=-2692876KB;;;;

Its a linux system, details are as follows:

# cat /proc/meminfo
MemTotal:       12582912 kB
MemFree:         3591364 kB
Cached:           518712 kB
Buffers:               0 kB
Active:          4081284 kB
Inactive:        1503948 kB
Active(anon):    3923484 kB
Inactive(anon):  1143036 kB
Active(file):     157800 kB
Inactive(file):   360912 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:               248 kB
Writeback:             0 kB
AnonPages:       5066520 kB
Shmem:           3292220 kB
Slab:             114076 kB
SReclaimable:      61008 kB
SUnreclaim:        53068 kB
# uname -sr
Linux 2.6.32-042stab120.16

=========================

Tried it on a different system with a more modern kernel, output is as follows:

# cat /proc/meminfo 
MemTotal:        8171680 kB
MemFree:          282784 kB
MemAvailable:    7199936 kB
Buffers:          640576 kB
Cached:          5530204 kB
SwapCached:          236 kB
Active:          4675496 kB
Inactive:        2069064 kB
Active(anon):     267576 kB
Inactive(anon):   443140 kB
Active(file):    4407920 kB
Inactive(file):  1625924 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:        524284 kB
SwapFree:         510304 kB
Dirty:              8688 kB
Writeback:             0 kB
AnonPages:        573612 kB
Mapped:           153592 kB
Shmem:            136924 kB
Slab:            1034884 kB
SReclaimable:     986028 kB
SUnreclaim:        48856 kB
KernelStack:        5856 kB
PageTables:        32552 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     4610124 kB
Committed_AS:    1730916 kB
VmallocTotal:   34359738367 kB
VmallocUsed:           0 kB
VmallocChunk:          0 kB
DirectMap4k:       14200 kB
DirectMap2M:     2082816 kB
DirectMap1G:     8388608 kB
# uname -sr
Linux 4.9.15-x86_64

Looks to be an issue with the Shmem usage in the code:
https://github.com/justintime/nagios-plugins/blob/master/check_mem/check_mem.pl#L159

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions