Skip to content

Commit

Permalink
omicron-status: improve formatting of segments for nagios
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmmacleod committed Apr 24, 2023
1 parent 3e972c9 commit cd59c44
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 cd59c44

Please sign in to comment.