Naemon/Plugins

From Segfault
Jump to navigation Jump to search

FreeBSD

SMART

Use nagios-check_smartmon[1] as a Nagios plugin to check on disk devices:

$ pkg install nagios-check_smartmon                                    # Might depend on smartmontools
$ /usr/local/libexec/nagios/check_smartmon -d /dev/ada0
OK: device is functional and stable (temperature: 35)|TEMP=35;55;60;

Memory

Sensors

There was bsdhwmon[2], but it's dead, apparently. I know of no other tool to grab sensor data off a FreeBSD system :-\

Linux

Memory

Standard check_memory:

$ sudo apt-get install libnagios-plugin-perl
$ /usr/lib/naemon/plugins/check_memory -w 85 -c 90
MEMORY CRITICAL - 254M free | free=267235328b;85;90

pmp-check-unix-memory from Percona:

$ /usr/lib/naemon/plugins/pmp-check-unix-memory -w 85 -c 90
OK Memory 74% used | memory_used=74;85;90;0;100

check_mem.pl outputs caches too:

git clone https://github.com/justintime/nagios-plugins.git justintime-nagios-plugins-git
cd justintime-nagios-plugins-git/
sudo install -o root -g root -m 0755 check_mem/check_mem.pl /usr/local/share/nagios/plugins/check_mem.pl

$ /usr/local/share/nagios/plugins/check_mem.pl -u -w 80 -c 90
CRITICAL - 91.5% (937376 kB) used!|TOTAL=1024452KB;;;; USED=937376KB;819561;922006;; FREE=87076KB;;;; CACHES=225700KB;;;;

check_mem outputs caches and buffers too:

git clone https://github.com/jasonhancock/nagios-memory.git nagios-memory-git
cd nagios-memory-git
sudo install -o root -g root -m 0755 plugins/check_mem /usr/local/share/nagios/plugins/check_mem
sudo install -o root -g root -m 0644 pnp4nagios/templates/check_mem.php /opt/pnp4nagios/share/templates/

$ plugins/check_mem -w 80 -c 90
MEMORY OK - 73% used | used=775139328;; cached=172224512;; buffers=21344256;; free=80330752;;

A bash version, but no cache and no buffer information and no percentage can be given. Also, the plugin seems to emulate the check_procs --metric RSS command:

git clone https://github.com/DennyZhang/check_proc_mem.git zhang-check_proc_mem-git
cd zhang-check_proc_mem-git

$ ./check_proc_mem.sh -w 960 -c 1024 --pid $$
Memory: OK VIRT: 25 MB - RES: 8 MB used!|RES=8388608;;;;

check_mem.sh outputs caches and buffers too, but has no source code repository:

wget "http://exchange.nagios.org/components/com_mtree/attachment.php?link_id=4174&cf_id=24" -O check_mem.sh

For some reason the script is damaged and needs to be repaired:

(echo '#!/bin/sh'; tail -n +2 check_mem.sh | fromdos) > check_mem_fixed.sh
sudo install -o root -g root -m 0755 check_mem_fixed.sh /usr/local/share/nagios/plugins/check_mem.sh

$ /usr/local/share/nagios/plugins/check_mem.sh -w 80 -c 90
Memory: OK Total: 1000 MB - Used: 729 MB - 72% used|TOTAL=1049038848;;;; USED=763695104;;;; CACHE=167231488;;;; BUFFER=23158784;;;;

And a Python variant too, but without performance data, no percentage can be given and there's no buffer or cache output either:

wget "http://exchange.nagios.org/components/com_mtree/attachment.php?link_id=3209&cf_id=24" -O check_memory.py
sudo install -o root -g root -m 0755 check_memory.py /usr/local/share/nagios/plugins/check_memory.p

$ /usr/local/share/nagios/plugins/check_memory.py 960 1024
OK -- Total Memory 1000MB Current Memory Usage is 923MB Free Memory 76MB

Another one in bash, but without performance data and the switches to display buffer and cache information are not working - and the output is totally off the charts anyway. Only included here for the same of completenes:

git clone https://bitbucket.org/shreix/nagios-plugins.git shreix-nagios-plugins-git
cd shreix-nagios-plugins-git/
sudo install -o root -g root -m 0755 check_memory.sh /usr/local/share/nagios/plugins/check_memory.sh

$ /usr/local/share/nagios/plugins/check_memory.sh -w 20 -c 90 -i -b
MEMORY OK - 8.341% is used out of 1024452 kB

Links

Sensors

TBD

Modules

TBD: list unused kernel modules

MacOS X

Sensors

TBD

Generic

monitoring-plugins

apt install automake autoconf gcc make libtool-bin libc6-dev                         # For Debian systems
dnf install automake autoconf gcc make glibc-devel                                   # For Fedora systems

git clone https://github.com/monitoring-plugins/monitoring-plugins.git monitoring-plugins-git
cd monitoring-plugins-git

./autogen.sh --prefix=/opt/monitoring-plugins
 make && sudo make install

Adjust the configuration parameters as needed to compile a different set of plugins.

nagios-plugins

For the Nagios version, install:

git clone https://github.com/nagios-plugins/nagios-plugins.git nagios-plugins-git
cd nagios-plugins-git

./autogen.sh --prefix=/opt/nagios-plugins
 make && sudo make install

Adjust the configuration parameters as needed to compile a different set of plugins.

check_logfiles

For monitoring log files, the stock check_log.sh plugin may be too simple, especially with regards to logfile rotation. Let's use check_logfiles instead:

git clone https://github.com/lausser/check_logfiles.git check_logfiles-git
cd check_logfiles-git

autoreconf --install && ./configure --prefix=/opt/check_logfiles --with-nagios-user=nagios --with-nagios-group=nagios
make && sudo make install

Or, just install the plugin manually:

sudo install -m 0755 -o root -g root plugins-scripts/check_logfiles /usr/local/share/nagios/plugins/

Links

References

  1. nagios-check_smartmon
  2. bsdhwmon (Archive) - The bsdhwmon project is currently on hiatus.