[MediaWiki-commits] [Gerrit] operations/puppet[production]: icinga: add plugin to check for long running screens

2017-08-23 Thread Dzahn (Code Review)
Dzahn has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/373135 )

Change subject: icinga: add plugin to check for long running screens
..


icinga: add plugin to check for long running screens

Adding Icinga/Nagios plugin to detect long-running screen sessions.

Bug: T165348
Change-Id: Ic72511092b685fd758f2c0f6d7410a715eed9ecc
---
A modules/icinga/files/check_long_screens
1 file changed, 64 insertions(+), 0 deletions(-)

Approvals:
  Alexandros Kosiaris: Looks good to me, but someone else must approve
  jenkins-bot: Verified
  Dzahn: Looks good to me, approved



diff --git a/modules/icinga/files/check_long_screens 
b/modules/icinga/files/check_long_screens
new file mode 100755
index 000..df821ad
--- /dev/null
+++ b/modules/icinga/files/check_long_screens
@@ -0,0 +1,64 @@
+#!/bin/bash
+# icinga/nagios plugin to detect long-running screen sessions
+#
+# https://phabricator.wikimedia.org/T165348
+#
+# Daniel Zahn () - Wikimedia Foundation Inc.
+#
+
+set -eu
+usage() { echo "Usage: $0 -w  -c " 1>&2; exit 1; }
+
+declare -i WARN_TIME="60"
+declare -i CRIT_TIME="120"
+
+DEBUG=false
+
+while getopts "w:c:" o; do
+case "${o}" in
+w)
+   WARN_TIME=${OPTARG}
+   ;;
+c)
+   CRIT_TIME=${OPTARG}
+   ;;
+*)
+   usage
+   ;;
+esac
+done
+
+if [ $WARN_TIME == 0 ] || [ $CRIT_TIME == 0 ]; then
+usage
+fi
+
+SCREEN_PID=""
+RUN_TIME=0
+PGREP=$(which pgrep)
+PS=$(which ps)
+XARGS=$(which xargs)
+
+for SCREEN_PID in $(${PGREP} -f SCREEN)
+  do
+ RUN_TIME=$(${PS} -o etimes= -p ${SCREEN_PID} | ${XARGS})
+ if $DEBUG; then
+ echo "Found a screen with PID ${SCREEN_PID}. It's been running since 
${RUN_TIME} seconds."
+ fi
+ if [ $RUN_TIME -gt $CRIT_TIME ]; then
+ echo "CRIT: Long running screen session. (PID ${SCREEN_PID}, 
${RUN_TIME}s > ${CRIT_TIME}s)"
+ exit 2
+ fi
+ if [ $RUN_TIME -gt $WARN_TIME ]; then
+ echo "WARN: Long running screen session. (PID ${SCREEN_PID}, 
${RUN_TIME}s > ${WARN_TIME}s)"
+ exit 1
+ fi
+ if [ $RUN_TIME -le $WARN_TIME ] && [ $RUN_TIME -le $CRIT_TIME ] ; then
+ echo "OK: No long running screen sessions detected."
+ exit 0
+ fi
+done
+
+echo "UNKNOWN: something went wrong with the plugin. check $0"
+exit 3
+
+

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic72511092b685fd758f2c0f6d7410a715eed9ecc
Gerrit-PatchSet: 3
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Dzahn 
Gerrit-Reviewer: Alexandros Kosiaris 
Gerrit-Reviewer: Dzahn 
Gerrit-Reviewer: jenkins-bot <>

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


[MediaWiki-commits] [Gerrit] operations/puppet[production]: icinga: add plugin to check for long running screens

2017-08-22 Thread Dzahn (Code Review)
Dzahn has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/373135 )

Change subject: icinga: add plugin to check for long running screens
..

icinga: add plugin to check for long running screens

Bug: T165348
Change-Id: Ic72511092b685fd758f2c0f6d7410a715eed9ecc
---
A modules/icinga/files/check_long_screens
1 file changed, 64 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/35/373135/1

diff --git a/modules/icinga/files/check_long_screens 
b/modules/icinga/files/check_long_screens
new file mode 100755
index 000..df821ad
--- /dev/null
+++ b/modules/icinga/files/check_long_screens
@@ -0,0 +1,64 @@
+#!/bin/bash
+# icinga/nagios plugin to detect long-running screen sessions
+#
+# https://phabricator.wikimedia.org/T165348
+#
+# Daniel Zahn () - Wikimedia Foundation Inc.
+#
+
+set -eu
+usage() { echo "Usage: $0 -w  -c " 1>&2; exit 1; }
+
+declare -i WARN_TIME="60"
+declare -i CRIT_TIME="120"
+
+DEBUG=false
+
+while getopts "w:c:" o; do
+case "${o}" in
+w)
+   WARN_TIME=${OPTARG}
+   ;;
+c)
+   CRIT_TIME=${OPTARG}
+   ;;
+*)
+   usage
+   ;;
+esac
+done
+
+if [ $WARN_TIME == 0 ] || [ $CRIT_TIME == 0 ]; then
+usage
+fi
+
+SCREEN_PID=""
+RUN_TIME=0
+PGREP=$(which pgrep)
+PS=$(which ps)
+XARGS=$(which xargs)
+
+for SCREEN_PID in $(${PGREP} -f SCREEN)
+  do
+ RUN_TIME=$(${PS} -o etimes= -p ${SCREEN_PID} | ${XARGS})
+ if $DEBUG; then
+ echo "Found a screen with PID ${SCREEN_PID}. It's been running since 
${RUN_TIME} seconds."
+ fi
+ if [ $RUN_TIME -gt $CRIT_TIME ]; then
+ echo "CRIT: Long running screen session. (PID ${SCREEN_PID}, 
${RUN_TIME}s > ${CRIT_TIME}s)"
+ exit 2
+ fi
+ if [ $RUN_TIME -gt $WARN_TIME ]; then
+ echo "WARN: Long running screen session. (PID ${SCREEN_PID}, 
${RUN_TIME}s > ${WARN_TIME}s)"
+ exit 1
+ fi
+ if [ $RUN_TIME -le $WARN_TIME ] && [ $RUN_TIME -le $CRIT_TIME ] ; then
+ echo "OK: No long running screen sessions detected."
+ exit 0
+ fi
+done
+
+echo "UNKNOWN: something went wrong with the plugin. check $0"
+exit 3
+
+

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic72511092b685fd758f2c0f6d7410a715eed9ecc
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Dzahn 

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