11 from StringIO
import StringIO
13 log = logging.getLogger(__name__)
15 re_files = re.compile(
r"^run(?P<run>\d+)/run(?P<runf>\d+)_ls(?P<ls>\d+)_.+\.(dat|raw)+(\.deleted)*")
17 m = re_files.match(rl)
22 sort_key = (int(d[
"run"]), int(d[
"runf"]), int(d[
"ls"]), )
29 for root, dirs, files
in os.walk(top, topdown=
True):
31 fp = os.path.join(root, name)
32 rl = os.path.relpath(fp, top)
36 fsize = os.stat(fp).st_size
41 collected.append((sort_key, fp, fsize, ))
44 collected.sort(key=
lambda x: x[0])
47 for sort_key, fp, fsize
in collected:
52 stopSize = stopSize - fsize
56 total = st.f_blocks * st.f_frsize
57 used = total - (st.f_bavail * st.f_frsize)
58 threshold = used - float(total * threshold) / 100
61 return float(x) * 100 / total
63 log.info(
"Using %d (%.02f%%) of %d space, %d (%.02f%%) above %s threshold.",
64 used,
p(used), total, threshold,
p(threshold), string)
68 log.info(
"Done cleaning up for %s threshold.", string)
70 log.info(
"Threshold %s not reached, doing nothing.", string)
74 total = st.f_blocks * st.f_frsize
75 used = total - (st.f_bavail * st.f_frsize)
76 return float(used) * 100 / total
80 total = st.f_blocks * st.f_frsize
81 free = st.f_bavail * st.f_frsize
84 return used, free, total
87 def __init__(self, top, thresholds, email_to, report_directory, fake=True, ):
100 if f.endswith(
".deleted"):
106 log.warning(
"Renaming file (fake): %s -> %s", f,
107 os.path.relpath(fn, os.path.dirname(f)))
109 log.warning(
"Renaming file: %s -> %s", f,
110 os.path.relpath(fn, os.path.dirname(f)))
115 if not f.endswith(
".deleted"):
119 log.warning(
"Truncating file (fake): %s", f)
121 log.warning(
"Truncating file: %s", f)
125 now = datetime.datetime.now()
136 subject =
"Disk out of space (%.02f%%) on %s." % (used_pc, self.
hostname)
137 if "mail2sms" in email:
142 log.info(
"Sending email: %s", repr([
"/bin/mail",
"-s", subject, email]))
143 p = subprocess.Popen([
"/bin/mail",
"-s", subject, email], stdin=subprocess.PIPE, shell=
False)
144 p.communicate(input=text)
148 log.warning(
"Directory %s does not exists. Reports disabled.", self.
report_directory)
151 meminfo =
list(open(
"/proc/meminfo",
"r").readlines())
152 def entry_to_dict(line):
153 key, value = line.split()[:2]
155 return (key.strip(
":"), value, )
156 meminfo =
dict(
map(entry_to_dict, meminfo))
158 if os.path.isdir(self.
top):
161 used, free, total = -1, -1, -1
165 "memory_used": (meminfo[
"MemTotal"] - meminfo[
"MemFree"]) * 1024,
166 "memory_free": meminfo[
"MemFree"] * 1024,
167 "memory_total": meminfo[
"MemTotal"] * 1024,
174 "last_log": logout.split(
"\n"),
177 "_id":
"dqm-diskspace-%s" % self.
hostname,
178 "type":
"dqm-diskspace"
181 fn =
"dqm-diskspace-seq%06d" % (doc[
"sequence"], )
184 fd = open(tmp_fp,
"w")
186 json.dump(doc, fd, indent=
True)
190 os.rename(tmp_fp, final_fp)
194 if not os.path.isdir(self.
top):
195 log.warning(
"Directory %s does not exists.", self.
top)
209 sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
211 sock.bind(
'\0' + pname)
216 def daemon(deleter, log_capture, delay_seconds=30):
221 log_out = log_capture.getvalue()
222 log_capture.truncate(0)
223 deleter.make_report(log_out)
225 time.sleep(delay_seconds)
238 fl = open(logfile,
"a")
247 f = open(pidfile,
"w")
248 f.write(
"%d\n" % os.getpid())
252 if __name__ ==
"__main__":
263 sys.stderr.write(
"Already running, exitting.\n")
281 thresholds = thresholds,
284 "dmitrijus.bugelskis@cern.ch",
285 "atanas.batinkov@cern.ch",
286 "daniel.joseph.duggan@cern.ch",
288 report_directory =
"/tmp/dqm_monitoring/",
293 formatter = logging.Formatter(
'%(asctime)s - %(name)s - %(levelname)s - %(message)s')
295 log.setLevel(logging.INFO)
297 log_capture = StringIO()
298 log_capture_ch = logging.StreamHandler(log_capture)
299 log_capture_ch.setLevel(logging.INFO)
300 log_capture_ch.setFormatter(formatter)
301 log.addHandler(log_capture_ch)
304 daemonize(
"/var/log/fff_deleter.log",
"/var/run/fff_deleter.pid")
307 flog_ch = logging.StreamHandler()
308 flog_ch.setLevel(logging.INFO)
309 flog_ch.setFormatter(formatter)
310 log.addHandler(flog_ch)
313 log.info(
"Pid is %d", os.getpid())
314 daemon(deleter=deleter, log_capture=log_capture)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run