Skip to content

Commit

Permalink
Merge pull request #156 from duncanmmacleod/nagios-gaps-segment-format
Browse files Browse the repository at this point in the history
Improve formatting of segments for nagios from omicron-status
  • Loading branch information
duncanmmacleod authored Apr 27, 2023
2 parents 3e972c9 + cd59c44 commit 7005b25
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion omicron/cli/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
from collections import OrderedDict
from functools import reduce
from getpass import getuser
from os import linesep
from pathlib import Path
from textwrap import indent
from time import sleep

import htcondor
Expand Down Expand Up @@ -713,7 +715,16 @@ def print_nagios_json(code, message, outfile, tag='status', **extras):
jsonfp = outdir / "nagios-{}-{}.json".format(tag, group)
status.append((tag, jsonfp))
if chans:
gapstr = '\n'.join('%s: %s' % c for c in chans)
# format the segments nicely for Icinga 2
lines = []
for chan, ftsegs in chans:
lines.append(f"{chan}:")
for ft, segs in ftsegs.items():
lines.extend((
f" {ft}:",
indent(str(segs), " "),
))
gapstr = linesep.join(lines)
code = 1
message = ("%s found in Omicron files for group %r\n%s"
% (tag.title(), group, gapstr))
Expand Down

0 comments on commit 7005b25

Please sign in to comment.