naparuba / check-linux-by-ssh

Shinken checks designed to be run without installing something on the distant linux (aside ssh keys of course!)
MIT License
43 stars 47 forks source link

check_memory_by_ssh.py: free on rhel7 change the calcul mode of used #49

Closed oliiivier closed 8 years ago

oliiivier commented 8 years ago

the command free has change on RHEL7, field are not the same : in old linux :

free -k

         total       used       free     shared    buffers     cached

Mem: 8057792 6401856 1655936 0 463348 1582792 -/+ buffers/cache: 4355716 3702076 Swap: 2097144 98736 1998408

in new linux (redhat el7) $ free -k total used free shared buff/cache available Mem: 1877688 124584 708416 98708 1044688 1456760 Swap: 1679356 0 1679356

used = total - free - buff/cache here : "used" is your consumed calculate value.

cached field = available when the first line end with available, we set cached variable containt available value... set the variable to 0.

best regards,

oliiivier commented 8 years ago

second commit fix perfdata compatibility with pnp4nagios. The standard format is : 'label'=value[UOM];[warn];[crit];[min];[max]

remove UOM on warn,crit,min and max value.

best regards, olivier

dguenault commented 8 years ago

Thx for submiting this patch but it will not be accepted as it is better to rely on proc than on a command that could change it's output at any time.

oliiivier commented 8 years ago

Hi,

You're right, /proc/meminfo will be more reliable instead of free command.

I've cat /proc/meminfo on rhel 4 to 7 in my environnement to help you in future development on this check. I see new field on new kernel version.

best regards, Olivier

cat /etc/redhat-release Red Hat Enterprise Linux Server release 6.5 (Santiago)

cat /proc/meminfo MemTotal: 132021844 kB MemFree: 46668668 kB Buffers: 1183496 kB Cached: 35143656 kB SwapCached: 0 kB Active: 38385324 kB Inactive: 558388 kB Active(anon): 3008148 kB Inactive(anon): 290028 kB Active(file): 35377176 kB Inactive(file): 268360 kB Unevictable: 345488 kB Mlocked: 345516 kB SwapTotal: 33558524 kB SwapFree: 33558524 kB Dirty: 1300 kB Writeback: 664 kB AnonPages: 3043124 kB Mapped: 329008 kB Shmem: 536524 kB Slab: 2299360 kB SReclaimable: 1434796 kB SUnreclaim: 864564 kB KernelStack: 9336 kB PageTables: 125540 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 78593828 kB Committed_AS: 9516560 kB VmallocTotal: 34359738367 kB VmallocUsed: 565940 kB VmallocChunk: 34359167036 kB HardwareCorrupted: 0 kB HugePages_Total: 20484 HugePages_Free: 213 HugePages_Rsvd: 210 HugePages_Surp: 0 Hugepagesize: 2048 kB DirectMap4k: 10480 kB DirectMap2M: 3125248 kB DirectMap1G: 131072000 kB

cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.1 (Maipo)

cat /proc/meminfo MemTotal: 1877688 kB MemFree: 329660 kB MemAvailable: 1453856 kB Buffers: 1112 kB Cached: 905600 kB SwapCached: 0 kB Active: 695640 kB Inactive: 295124 kB Active(anon): 136016 kB Inactive(anon): 46748 kB Active(file): 559624 kB Inactive(file): 248376 kB Unevictable: 0 kB Mlocked: 0 kB SwapTotal: 1679356 kB SwapFree: 1679356 kB Dirty: 4 kB Writeback: 0 kB AnonPages: 84092 kB Mapped: 39644 kB Shmem: 98712 kB Slab: 515068 kB SReclaimable: 485132 kB SUnreclaim: 29936 kB KernelStack: 6064 kB PageTables: 4208 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 2618200 kB Committed_AS: 453212 kB VmallocTotal: 34359738367 kB VmallocUsed: 146956 kB VmallocChunk: 34359588864 kB HardwareCorrupted: 0 kB AnonHugePages: 20480 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB DirectMap4k: 46976 kB DirectMap2M: 2050048 kB

cat /etc/redhat-release Red Hat Enterprise Linux Server release 5.3 (Tikanga)

cat /proc/meminfo MemTotal: 4148364 kB MemFree: 152616 kB Buffers: 79224 kB Cached: 2744716 kB SwapCached: 136 kB Active: 2939796 kB Inactive: 890056 kB HighTotal: 3275088 kB HighFree: 7100 kB LowTotal: 873276 kB LowFree: 145516 kB SwapTotal: 5242864 kB SwapFree: 5222588 kB Dirty: 1440 kB Writeback: 0 kB AnonPages: 1005764 kB Mapped: 505068 kB Slab: 62108 kB PageTables: 86200 kB NFS_Unstable: 0 kB Bounce: 0 kB CommitLimit: 7317044 kB Committed_AS: 3361132 kB VmallocTotal: 116728 kB VmallocUsed: 5892 kB VmallocChunk: 110292 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 Hugepagesize: 2048 kB

cat /etc/redhat-release Red Hat Enterprise Linux ES release 4 (Nahant Update 4)

cat /proc/meminfo MemTotal: 8308784 kB MemFree: 1555420 kB Buffers: 315728 kB Cached: 5166632 kB SwapCached: 0 kB Active: 4180816 kB Inactive: 2076956 kB HighTotal: 7471040 kB HighFree: 1515712 kB LowTotal: 837744 kB LowFree: 39708 kB SwapTotal: 1052248 kB SwapFree: 1052248 kB Dirty: 632 kB Writeback: 0 kB Mapped: 830816 kB Slab: 463304 kB CommitLimit: 5206640 kB Committed_AS: 2414516 kB PageTables: 9908 kB VmallocTotal: 106488 kB VmallocUsed: 4216 kB VmallocChunk: 102064 kB HugePages_Total: 0 HugePages_Free: 0 Hugepagesize: 2048 kB

dguenault commented 8 years ago

Thx for the feedback actually see issue #30 for the modified code (get_memory)

and yes new fields are available and shared is now obsolete. For more information : https://access.redhat.com/solutions/406773

oliiivier commented 8 years ago

this new version will be perfect!

thanks! :)