Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
tutorial:adm:server_monitoring [2019/03/25 15:02]
fiserp [Monitoring of server with CzechIdM]
tutorial:adm:server_monitoring [2019/03/25 15:50]
fiserp [Implementation]
Line 35: Line 35:
   * NRPE daemon will listen on 5666\tcp (its default port). Open the port in your iptables by adding the rule: ''-A INPUT -m state --state ESTABLISHED,RELATED -p tcp --dport 5666 -j ACCEPT''.   * NRPE daemon will listen on 5666\tcp (its default port). Open the port in your iptables by adding the rule: ''-A INPUT -m state --state ESTABLISHED,RELATED -p tcp --dport 5666 -j ACCEPT''.
   * All probes are located in their default installation location ''/usr/lib64/nagios/plugins/''.   * All probes are located in their default installation location ''/usr/lib64/nagios/plugins/''.
-  * We use one external probe check\_mem which can be downloaded here: [[https://exchange.nagios.org/directory/Plugins/System-Metrics/Memory/check_mem-2Esh/details]]. This probe, however, returns bad results on RHEL7 because of the different meaning of the ''free'' command output. The fixed version is: +  * We use one external probe check\_mem which can be downloaded here: [[https://exchange.nagios.org/directory/Plugins/System-Metrics/Memory/check_mem-2Esh/details]]. This probe, however, returns bad results on RHEL7 because of the different meaning of the ''free'' command output. You can dowload the fixed version from [[https://github.com/bcvsolutions/czechidm-monitoring/blob/master/nagios-plugins/check_mem/check_mem|here]].
-<file bash check_mem> +
-#!/bin/bash +
- +
-# Original (GPL-licensed) version https://exchange.nagios.org/directory/Plugins/System-Metrics/Memory/check_mem-2Esh/details +
-# Modified for CentOS7/RHEL7 - Petr Fiser, BCV solutions s.r.o. +
-if [ "$1" = "-w" ] && [ "$2" -gt "0" ] && [ "$3" = "-c" ] && [ "$4" -gt "0" ]; then +
- +
-        memTotal_b=`free -b |grep Mem |awk '{print $2}'+
-        memFree_b=`free -b |grep Mem |awk '{print $4}'+
-        memBuffer_b=`free -b |grep Mem |awk '{print $6}'+
- +
-        memTotal_m=`free -m |grep Mem |awk '{print $2}'+
-        memFree_m=`free -m |grep Mem |awk '{print $4}'+
-        memBuffer_m=`free -m |grep Mem |awk '{print $6}'+
- +
-        memUsed_b=$(($memTotal_b-$memFree_b-$memBuffer_b)) +
-        memUsed_m=$(($memTotal_m-$memFree_m-$memBuffer_m)) +
- +
-        memUsedPrc=$((($memUsed_b*100)/$memTotal_b)) +
- +
- +
-        if [ "$memUsedPrc" -ge "$4" ]; then +
-                echo "Memory: CRITICAL Total: $memTotal_m MB - Used: $memUsed_m MB - $memUsedPrc% used!|TOTAL=$memTotal_b;;;; USED=$memUsed_b;;;; BUFFER=$memBuffer_b;;;;" +
-                $(exit 2) +
-        elif [ "$memUsedPrc" -ge "$2" ]; then +
-                echo "Memory: WARNING Total: $memTotal_m MB - Used: $memUsed_m MB - $memUsedPrc% used!|TOTAL=$memTotal_b;;;; USED=$memUsed_b;;;; BUFFER=$memBuffer_b;;;;" +
-                $(exit 1) +
-        else +
-                echo "Memory: OK Total: $memTotal_m MB - Used: $memUsed_m MB - $memUsedPrc% used|TOTAL=$memTotal_b;;;; USED=$memUsed_b;;;; BUFFER=$memBuffer_b;;;;" +
-                $(exit 0) +
-        fi +
- +
-else +
-        echo "check_mem v1.1" +
-        echo "" +
-        echo "Usage:" +
-        echo "check_mem.sh -w <warnlevel> -c <critlevel>" +
-        echo "" +
-        echo "warnlevel and critlevel is percentage value without %" +
-        echo "" +
-        echo "Copyright (C) 2012 Lukasz Gogolin (lukasz.gogolin@gmail.com)" +
-        exit +
-fi +
-</file>+
  
 **Deployment** **Deployment**
  • by urbanl