Tim Landscheidt has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/111457

Change subject: Revert "icinga: remove check_ram.sh doesn't seem to be used 
anywhere"
......................................................................

Revert "icinga: remove check_ram.sh doesn't seem to be used anywhere"

This reverts commit 95fdd0550466d0e307504cdbdddc0c0709a8f60c.  check_ram.sh is 
used by Icinga on Wikimedia Labs.

Change-Id: Ieca1ef96e88a2b62b19019865646fbf63d1e666c
---
A files/icinga/check_ram.sh
M manifests/misc/icinga.pp
M modules/nrpe/templates/nrpe_local.cfg.erb
3 files changed, 70 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/57/111457/1

diff --git a/files/icinga/check_ram.sh b/files/icinga/check_ram.sh
new file mode 100755
index 0000000..2341d10
--- /dev/null
+++ b/files/icinga/check_ram.sh
@@ -0,0 +1,69 @@
+#!/bin/sh
+#
+# Plugin to check free ram space
+# using check_by_ssh
+# by Markus Walther (voltsh...@gmx.de)
+# modified by Petr Bena (benap...@gmail.com)
+# The script needs a working check_by_ssh connection and needs to run on the 
client to check it
+#
+# Command-Line for check_by_ssh
+# command_line $USER1$/check_by_ssh -H $HOSTNAME$ -p $ARG1$ -C "$ARG2$ $ARG3$ 
$ARG4$ $ARG5$ $ARG6$"
+#
+# Command-Line for service (example)
+# check_by_ssh!82!/nagios/check_ram.sh!20!10
+#
+##########################################################
+
+case $1 in
+  --help | -h )
+        echo "Usage: check_ram [warn] [crit]"
+        echo " [warn] and [crit] as int"
+        echo " Example: check_ram 20 10"
+        exit 3
+         ;;
+  * )
+    ;;
+esac
+
+warn=$1
+crit=$2
+buffer=$3
+
+if [ ! "$1" -o ! "$2" ]; then
+        echo "Usage: check_ram [warn] [crit]"
+        echo " [warn] and [crit] as int"
+        echo " Example: check_ram 20 10"
+        echo "Unknown: Options missing: using default (warn=20, crit=10)"
+        warn=`echo $((20))`
+        crit=`echo $((10))`
+fi
+
+if [ "$buffer" != "b" ];then
+    full=`free | grep Mem | sed -r 's/\ +/\ /g' | cut -d \  -f 3`
+    free=`free | grep Mem | sed -r 's/\ +/\ /g' | cut -d \  -f 4`
+else
+    full=`free | grep 'buffers\/cache' | sed 's/\-\/+\sbuffers\/cache\://' | 
sed -r 's/\ +/\ /g' | cut -d \  -f 2`
+    free=`free | grep 'buffers\/cache' | sed 's/\-\/+\sbuffers\/cache\://' | 
sed -r 's/\ +/\ /g' | cut -d \  -f 3`
+fi
+
+if [ "$warn" -lt "$crit" -o "$warn" -eq "$crit" ]; then
+   echo "Unknown: [warn] must be larger than [crit]"
+        exit 3
+fi
+
+use=`echo $(( ($free * 100) / ( $full + $free ) ))`
+
+if [ "$use" -gt "$warn" -o "$use" -eq "$warn" ]; then
+        echo "OK: $use% free memory"
+        exit 0
+ elif [ "$use" -lt "$warn" -a "$use" -gt "$crit" ]; then
+        echo "Warning: $use% free memory"
+        exit 1
+ elif [ "$use" -eq "$crit" -o "$use" -lt "$crit" ]; then
+        echo "Critical: $use% free memory"
+        exit 2
+ else
+        echo "Unknown"
+        exit 3
+fi
+
diff --git a/manifests/misc/icinga.pp b/manifests/misc/icinga.pp
index c84eb0d..3303855 100644
--- a/manifests/misc/icinga.pp
+++ b/manifests/misc/icinga.pp
@@ -587,9 +587,7 @@
       owner => 'root',
       group => 'root',
       mode => '0755';
-#after absent everywhere, remove entire resource as it is not used
     '/usr/lib/nagios/plugins/check_ram.sh':
-      ensure => 'absent',
       source => 'puppet:///files/icinga/check_ram.sh',
       owner => 'root',
       group => 'root',
diff --git a/modules/nrpe/templates/nrpe_local.cfg.erb 
b/modules/nrpe/templates/nrpe_local.cfg.erb
index cd30c25..0413dae 100644
--- a/modules/nrpe/templates/nrpe_local.cfg.erb
+++ b/modules/nrpe/templates/nrpe_local.cfg.erb
@@ -10,6 +10,7 @@
 command[check_disk_5_2]=/usr/lib/nagios/plugins/check_disk -w 5% -c 2% -l -e
 command[check_disk_6_3]=/usr/lib/nagios/plugins/check_disk -w 6% -c 3% -l -e
 command[check_disk_6_4]=/usr/lib/nagios/plugins/check_disk -w 6% -c 4% -l -e
+command[check_ram]=/usr/lib/nagios/plugins/check_ram.sh 20 5 b
 
 # process checks, we can't make this generic because we don't pass args via 
nrpe (security)
 command[check_mailman]=/usr/lib/nagios/plugins/check_procs -w 1:25 -c 1:35 -a 
mailman

-- 
To view, visit https://gerrit.wikimedia.org/r/111457
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieca1ef96e88a2b62b19019865646fbf63d1e666c
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Tim Landscheidt <t...@tim-landscheidt.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to