Skip to content

Commit

Permalink
move to passive checks
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-manzi committed May 14, 2020
1 parent 0ba7f36 commit 5b7663b
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions plugins/srm_probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import gridutils
import tempfile
import datetime

import filecmp
import gfal2
import nap.core
Expand Down Expand Up @@ -41,7 +40,7 @@
# Reasonable defaults for timeouts
LCG_GFAL_BDII_TIMEOUT = 10

gfal2.set_verbose(gfal2.verbose_level.debug)
gfal2.set_verbose(gfal2.verbose_level.normal)

# Service version(s)
svcVers = ['1','2']
Expand Down Expand Up @@ -153,7 +152,7 @@ def getSURLFromBDII(args,io):
return eps


@app.metric(seq=1, metric_name="GetSURLs", passive=False)
@app.metric(seq=1, metric_name="GetSURLs", passive=True)
def getSURLs(args, io):
"""
Use provided endpoint as SURL or use the BDII to retrieve the Storage Area and build the SURLs to test
Expand All @@ -175,7 +174,7 @@ def getSURLs(args, io):
io.status = nap.OK


@app.metric(seq=2, metric_name="VOLsDir", passive=False)
@app.metric(seq=2, metric_name="VOLsDir", passive=True)
def metricVOLsDir(args, io):
"""
List content of VO's top level space area(s) in SRM using gfal2.listdir().
Expand Down Expand Up @@ -212,7 +211,7 @@ def metricVOLsDir(args, io):
(str(e), sys.exc_info()[0]))


@app.metric(seq=3, metric_name="VOPut", passive=False)
@app.metric(seq=3, metric_name="VOPut", passive=True)
def metricVOPut(args, io):
"""Copy a local file to the SRM into space area(s) defined by VO."""

Expand Down Expand Up @@ -272,7 +271,7 @@ def metricVOPut(args, io):
(str(e), sys.exc_info()[0]))


@app.metric(seq=4, metric_name="VOLs", passive=False)
@app.metric(seq=4, metric_name="VOLs", passive=True)
def metricVOLs(args, io):
"""Stat (previously copied) file(s) on the SRM."""

Expand Down Expand Up @@ -310,7 +309,7 @@ def metricVOLs(args, io):
(str(e), sys.exc_info()[0]))


@app.metric(seq=5, metric_name="VOGetTurl", passive=False)
@app.metric(seq=5, metric_name="VOGetTurl", passive=True)
def metricVOGetTURLs(ags, io):
"""Get Transport URLs for the file copied to storage"""

Expand Down Expand Up @@ -348,7 +347,7 @@ def metricVOGetTURLs(ags, io):
(str(e), sys.exc_info()[0]))


@app.metric(seq=6, metric_name="VOGet", passive=False)
@app.metric(seq=6, metric_name="VOGet", passive=True)
def metricVOGet(args, io):
"""Copy given remote file(s) from SRM to a local file."""

Expand Down Expand Up @@ -403,7 +402,7 @@ def metricVOGet(args, io):
(str(e), sys.exc_info()[0]))


@app.metric(seq=7, metric_name="VODel", passive=False)
@app.metric(seq=7, metric_name="VODel", passive=True)
def metricVODel(args, io):
"""Delete given file(s) from SRM."""

Expand Down Expand Up @@ -433,10 +432,26 @@ def metricVODel(args, io):
io.set_status(
nap.UNKNOWN, 'problem invoking gfal2 unlink(): %s:%s' %
(str(e), sys.exc_info()[0]))


@app.metric(seq=8, metric_name="VOAll", passive=False)
def metricVOAlll(args, io):
"""Active metric to conbine the result from the previous passive ones"""

results = app.metric_results()

statuses = [e[1] for e in results]

if all(st == 0 for st in statuses):
io.set_status(nap.OK, "All fine")
if 2 in statuses:
io.set_status(nap.CRITICAL, "Error executing passive checks")

try:
shutil.rmtree(workdir_metric)
except OSError as e:
pass


if __name__ == '__main__':
app.run()
app.run()

0 comments on commit 5b7663b

Please sign in to comment.