Skip to Content.
Sympa Menu

idok-commit - [idok-commit] idok commit r345 - trunk/python/dms_nagios

idok-commit AT lists.psi.ch

Subject: Commit emails of the iDok project

List archive

[idok-commit] idok commit r345 - trunk/python/dms_nagios


Chronological Thread 
  • From: "AFS account Florian Huebner" <huebner AT savannah.psi.ch>
  • To: idok-commit AT lists.psi.ch
  • Subject: [idok-commit] idok commit r345 - trunk/python/dms_nagios
  • Date: Thu, 19 Mar 2009 08:34:02 +0100
  • List-archive: <https://lists.web.psi.ch/pipermail/idok-commit/>
  • List-id: Commit emails of the iDok project <idok-commit.lists.psi.ch>

Author: huebner
Date: Thu Mar 19 08:34:02 2009
New Revision: 345

Log:
added a check for the rest search service and removed CMD_ENV variable so the
standard PATH of the Nagios system will be used

Modified:
trunk/python/dms_nagios/check_dms.py

Modified: trunk/python/dms_nagios/check_dms.py
==============================================================================
--- trunk/python/dms_nagios/check_dms.py (original)
+++ trunk/python/dms_nagios/check_dms.py Thu Mar 19 08:34:02 2009
@@ -30,6 +30,10 @@
are required

@author Roman Geus
+@date 01.06.2007
+
+
+Update 19.03.2009: removed the CMD_ENV variable so the standard path of the
Nagios system will be used
"""

import commands, os, signal, socket, sys, time
@@ -37,7 +41,8 @@
USER_PRINCIPAL = "dmsnagios AT D.PSI.CH"
KEYTAB_FILE = "/afs/psi.ch/project/dms/admin/nagios/keytab.dmsnagios"
KRB5_CONF = "/afs/psi.ch/project/dms/admin/prod/opt/dms/krb5.conf"
-CMD_ENV = "PATH=/usr/java/jdk1.5.0_11/bin:$PATH"
+###CMD_ENV = "PATH=/usr/java/jdk1.5.0_16/bin:$PATH"
+CMD_ENV = "PATH=/usr/java/jdk/bin:$PATH"
IDOK_TEST_URLPATH = "ait/nagios"
TIMEOUT = 20
IDOK_HOST_DIR = {'dms.psi.ch': '/afs/psi.ch/project/dms/admin/prod/opt/dms',
@@ -94,8 +99,8 @@
idok_path = "%s/idok" % (IDOK_HOST_DIR[host],)
url = "https://%s/%s"; % (host, IDOK_TEST_URLPATH)
time0 = time.time()
- status = os.system("%s %s ls %s > /dev/null"
- % (CMD_ENV, idok_path, url))
+ #status = os.system("%s %s ls %s > /dev/null" % (CMD_ENV, idok_path,
url))
+ status = os.system("%s ls %s > /dev/null" % (idok_path, url))
etime = time.time() - time0
signal.alarm(0)
if status == 0:
@@ -109,7 +114,9 @@
def check_admin_service(host):
"Test access to iDok service daemon using CORBA"
idok_admin_path = "%s/idok_admin" % (IDOK_HOST_DIR[host],)
- cmd = "%s %s query -t ait/nagios" % (CMD_ENV, idok_admin_path)
+ #cmd = "%s %s query -t ait/nagios" % (CMD_ENV, idok_admin_path)
+ cmd = " %s query -t ait/nagios" % (idok_admin_path)
+ #print cmd
try:
signal.signal(signal.SIGALRM, handler)
signal.alarm(TIMEOUT)
@@ -131,8 +138,9 @@
def check_search_service(host):
"Test access to iDok service daemon using CORBA"
idok_path = "%s/idok" % (IDOK_HOST_DIR[host],)
- cmd = "%s %s search --meta ait/nagios::python" \
- % (CMD_ENV, idok_path)
+ #cmd = "%s %s search --meta ait/nagios::python" % (CMD_ENV, idok_path)

+ cmd = "%s search --meta ait/nagios::python" % (idok_path)
+ #print cmd
try:
signal.signal(signal.SIGALRM, handler)
signal.alarm(TIMEOUT)
@@ -151,6 +159,34 @@
signal.alarm(0)
return ERRORS['CRITICAL'], 'ERROR: Authentication timed out'

+def check_rest_search(host):
+ "Test access to the rest search service"
+ #idok_path = "%s/idok" % (IDOK_HOST_DIR[host],)
+ url = "https://%s/api/v1/search/%s?q=python"; % (host, IDOK_TEST_URLPATH)
+# cmd = "%s curl --negotiate -u : '%s'" \
+# % (CMD_ENV, url)
+ os.environ["KRB5RCACHENAME"] = "/tmp/krb5cc_$UID"
+ cmd = "KRB5_CONFIG=%s curl --negotiate -u : '%s'" \
+ % (KRB5_CONF, url)
+ #print cmd
+ try:
+ signal.signal(signal.SIGALRM, handler)
+ signal.alarm(TIMEOUT)
+ time0 = time.time()
+ status, output = commands.getstatusoutput(cmd)
+ etime = time.time() - time0
+ signal.alarm(0)
+ if status == 0:
+ if "Mardal_et_al_CiSE.pdf" in output:
+ return ERRORS['OK'], "OK: elapsed time %.1f sec" % (etime,)
+ else:
+ return ERRORS['WARNING'], "WARNING: result incorrect"
+ else:
+ return ERRORS['CRITICAL'], "ERROR: Cannot access rest search
service"
+ except TimeOutError:
+ signal.alarm(0)
+ return ERRORS['CRITICAL'], 'ERROR: Authentication timed out'
+
def usage(checks):
"Print usage help."
buf = "usage: %s <hostname> [ " % (sys.argv[0],)
@@ -163,7 +199,8 @@
"Main program"
checks = {"repo_access": check_repository_access,
"admin_service": check_admin_service,
- "search_service": check_search_service}
+ "search_service": check_search_service,
+ "rest_search": check_rest_search}

if len(sys.argv) != 3:
usage(checks)



  • [idok-commit] idok commit r345 - trunk/python/dms_nagios, AFS account Florian Huebner, 03/19/2009

Archive powered by MHonArc 2.6.19.

Top of Page