Coder Social home page Coder Social logo

check_mem's Introduction

check_mem

Nagios plugin for checking available memory and swap on a nix machine. Tested working on several nix flavors including:

  • Linux-3.10.0-327.4.4.el7.x86_64-x86_64-with-centos-7.2.1511-Core
  • Linux-3.16.0-30-generic-x86_64-with-Ubuntu-14.04-trusty
  • Linux-2.6.32-358.2.1.el6.x86_64-x86_64-with-redhat-6.4-Santiago
  • Linux-2.6.32-504.16.2.el6.x86_64-x86_64-with-centos-6.5-Final
  • Linux-2.6.32-504.el6.x86_64-x86_64-with-centos-6.6-Final

Prerequisites

Requires custom nagpyrc library for generating the Nagios return codes and perfdata in the right format

pip install nagpyrc

Usage

Usage: Basic check with no arguments, defaults to warn on 90% memory usage and critical on 95% memory usage. Swap warning/critical defaults to 75% and 90% respectively.

[root@SERVER] ~]# python check_mem.py

Output

OK MEMORY:::: Total: 1840 MB - Used: 148 MB - 8.07% used --- SWAP:::: Used: 1 MB - 0.07% used  ; | 'USED'=155623424B;;;; 'TOTAL'=1929613312B;;;; 'SWAP_USED'=1249280B;;;; 'SWAP_TOTAL'=1719660544B;;;; 'MEM_USED_PCT'=8.07%;;;; 'SWAP_USED_PCT'=0.07%;;;;

Check memory, warn at 3% usage, critical at 4% usage return proper Nagios return code if thresholds are reached.

[root@DOANTEST07 ~]# python check_mem.py -w 3 -c 4

Output

CRITICAL MEMORY:::: Total: 1840 MB - Used: 148 MB - 8.09% used --- SWAP:::: Used: 1 MB - 0.07% used  ; | 'USED'=156078080B;;;; 'TOTAL'=1929613312B;;;; 'SWAP_USED'=1249280B;;;; 'SWAP_TOTAL'=1719660544B;;;; 'MEM_USED_PCT'=8.09%;;;; 'SWAP_USED_PCT'=0.07%;;;;

check memory and gather perfdata but check will always return 1 "OK" even if threshold is reached

[root@DOANTEST07 ~]# python check_mem.py -w 3 -c 4 --perfdata_only yes

Output

OK MEMORY:::: Total: 1840 MB - Used: 148 MB - 8.08% used --- SWAP:::: Used: 1 MB - 0.07% used  ; | 'USED'=155918336B;;;; 'TOTAL'=1929613312B;;;; 'SWAP_USED'=1249280B;;;; 'SWAP_TOTAL'=1719660544B;;;; 'MEM_USED_PCT'=8.08%;;;; 'SWAP_USED_PCT'=0.07%;;;;

License

MIT

check_mem's People

Contributors

stunkymonkey avatar rendicott avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.