Skip to content

Commit

Permalink
Merge pull request #27 from cms-DQM/dev128
Browse files Browse the repository at this point in the history
  • Loading branch information
nothingface0 authored Jun 27, 2024
2 parents 77689a9 + f06d40c commit a282994
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 24 deletions.
19 changes: 10 additions & 9 deletions bin/visDQMIndexCastorStager
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,16 @@ def executeCommand(command):
# Alert email addresses given as parameter about a failure of the process.
def alertBySendingEmail(errorText):
process = Popen("/usr/sbin/sendmail -t", shell=True, stdin=PIPE)
# TODO: encode() the strings for python3, when Offline GUI upgrades
process.stdin.write("To: %s\n" % args.EMAIL)
process.stdin.write("Subject: Problem sending DQM GUI index backup to EOS\n")
process.stdin.write("\n") # blank line separating headers from body
process.stdin.write("Problem sending DQM GUI index backup to EOS\n")
process.stdin.write("Hostname: %s\n" % gethostname())
process.stdin.write("Index: %s\n" % args.INDEX)
process.stdin.write("%s\n" % errorText)
process.stdin.write("Please check logs!\n")
process.stdin.write(f"To: {args.EMAIL}\n".encode())
process.stdin.write(
"Subject: Problem sending DQM GUI index backup to EOS\n".encode()
)
process.stdin.write("\n".encode()) # blank line separating headers from body
process.stdin.write("Problem sending DQM GUI index backup to EOS\n".encode())
process.stdin.write(f"Hostname: {gethostname()}\n".encode())
process.stdin.write(f"Index: {args.INDEX}\n".encode())
process.stdin.write(f"{errorText}\n".encode())
process.stdin.write("Please check logs!\n".encode())
process.stdin.close()
returncode = process.wait()
if returncode != 0:
Expand Down
8 changes: 5 additions & 3 deletions bin/visDQMIndexMonitoring
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,16 @@ check_index_limits_and_send_email() {
tree_current_size=$(grep "${_tree_types[$i]}" "${TMP_CATALOGUE_FILE}_${FLAVOR}" | wc -l)
tree_limit=$(grep -oE "${_tree_types_limit_name[$i]}[[:space:]]+[0-9]+" "$visdqmindex_header_file" | awk '{print $2}')
percent_full=$(bc -l <<<"($tree_current_size/$tree_limit)*100")
echo "Found $tree_current_size ${_tree_types[$i]} in the catalogue. Limit is $tree_limit ($(printf '%.2f' $percent_full)%)"
echo "Found $tree_current_size ${_tree_types[$i]} in the catalogue. Limit is $tree_limit ($(printf '%.2f' $percent_full)% full)"
# Check if alarm threshold is exceeded
threshold=$(printf '%.0f' $(bc <<<"$ALERT_THRESHOLD * $tree_limit"))
if [ $tree_current_size -gt $threshold ]; then
msg=$(printf "%s" "${msg}There are $tree_current_size ${_tree_types[$i]} in the index, which is above the $threshold threshold!\n")
msg=$(printf "%s" "${msg}WARNING: DQMGUI's index tree ${_tree_types[$i]} has $tree_current_size entries out of the maximum ${tree_limit} ($(printf '%.2f' $percent_full)% full))\n")
fi
done
if [ -n "$msg" ]; then
printf "$msg" | mail -s "visDQMIndexMonitoring on $(hostname)" "$EMAIL_ADDRESS_TO_NOTIFY"
echo "Sending email to $EMAIL_ADDRESS_TO_NOTIFY"
printf "$msg" | mail -s "visDQMIndexMonitoring on $(hostname) (${FLAVOR})" "$EMAIL_ADDRESS_TO_NOTIFY"
fi
}

Expand Down Expand Up @@ -105,3 +106,4 @@ for step in "${steps[@]}"; do
echo "Skipping step: $step"
fi
done
echo "Done!"
9 changes: 4 additions & 5 deletions bin/visDQMZipCastorVerifier
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@ def runme(cmd, *args, **keys):


def sendmail(body="Hello from visDQMZipCastorVerifier"):
# TODO: encode() when Offline DQMGUI updates to python3
scall = Popen("%s -t" % SENDMAIL, shell=True, stdin=PIPE)
scall.stdin.write("To: %s\n" % EMAIL)
scall.stdin.write("Subject: Problem verifying file transfer to EOS\n")
scall.stdin.write("\n") # blank line separating headers from body
scall.stdin.write("%s\n" % body)
scall.stdin.write(f"To: {EMAIL}\n".encode())
scall.stdin.write("Subject: Problem verifying file transfer to EOS\n".encode())
scall.stdin.write("\n".encode()) # blank line separating headers from body
scall.stdin.write(f"{body}\n".encode())
scall.stdin.close()
rc = scall.wait()
if rc != 0:
Expand Down
12 changes: 6 additions & 6 deletions src/python/Core/Plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ def jsonmap(self):
{
"coords": [
self._map[name][2 * i : (2 * i) + 1]
for i in range(len(self._map[name]) / 2)
for i in range(int(len(self._map[name]) / 2))
],
"title": name,
"value": value,
Expand Down Expand Up @@ -1015,7 +1015,7 @@ def __init__(self, span, series, data, legend, props):
self._axisFormat = "%Y"
spanFormat = "%Y"
else:
raise "Bad time series span"
raise Exception("Bad time series span")

self.title = "%s\n%d %ss from %s to %s UTC" % (
self.get("title", ""),
Expand Down Expand Up @@ -1105,7 +1105,7 @@ def draw(self):
p = map_patches[k]
maparea = []

def reduce_verts(verts):
def reduce_verts(verts: list) -> list:
if len(verts) >= 4:
if not (
verts[0][0] == verts[-1][0] and verts[0][1] == verts[-1][1]
Expand All @@ -1124,7 +1124,7 @@ def reduce_verts(verts):
# There is only ever a single patch here
# verts = reduce_verts(p.get_transform().transform(p.get_verts()))
verts = reduce_verts(p.get_transform().transform(p.get_paths()[0].vertices))
if len(verts) > 0:
if verts and len(verts) > 0:
for v in verts:
maparea.extend((v[0], float(self.get("height")) - v[1]))
self._map[k] = maparea
Expand Down Expand Up @@ -1190,7 +1190,7 @@ def jsonmap(self):
{
"coords": [
self._map[name][2 * i : (2 * i) + 1]
for i in range(len(self._map[name]) / 2)
for i in range(int(len(self._map[name]) / 2))
],
"title": name,
"value": value,
Expand Down Expand Up @@ -1228,7 +1228,7 @@ def __init__(self, span, series, data, legend, props):
self._axisFormat = "%Y"
spanFormat = "%Y"
else:
raise "Bad time series span"
raise Exception("Bad time series span")

self.title = "%s\n%d %ss from %s to %s UTC" % (
self.get("title", ""),
Expand Down
1 change: 0 additions & 1 deletion src/python/DQM/GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,6 @@ def plot(self, *junk, **options):
labels[i],
)
)
print(final, options)
assert len(labels) == len(objs)
a = self._plot(final, options)
return (a[0], bytes(a[1]))
Expand Down

0 comments on commit a282994

Please sign in to comment.