Skip to content

Commit 63ab78f

Browse files
committed
few extra changes, incorrect arg, use append for lists
1 parent c4355ab commit 63ab78f

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

condor_history_to_es.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ def es_import(document_generator):
8888
return success
8989

9090
failed = False
91-
if options.access_points:
91+
if options.access_points and options.collectors:
9292
for coll_address in options.positionals:
9393
try:
9494
gen = es_generator(read_from_collector(coll_address, options.access_points, history=True))
9595
success = es_import(gen)
9696
except htcondor.HTCondorIOError as e:
9797
failed = e
9898
logging.error('Condor error', exc_info=True)
99-
if options.collectors:
99+
elif options.collectors:
100100
for coll_address in options.positionals:
101101
try:
102102
gen = es_generator(read_from_collector(coll_address, history=True))

condor_history_to_prometheus.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ def locate_schedds(collector, access_points):
3838
if access_points:
3939
try:
4040
for ap in access_points:
41-
schedds += coll.locate(htcondor.DaemonTypes.Schedd, ap)
41+
schedds.append(coll.locate(htcondor.DaemonTypes.Schedd, ap))
4242
except htcondor.HTCondorIOError as e:
4343
logging.error(f'Condor error: {e}')
4444
else:
4545
try:
46-
schedds += coll.locateAll(htcondor.DaemonTypes.Schedd)
46+
schedds.append(coll.locateAll(htcondor.DaemonTypes.Schedd))
4747
except htcondor.HTCondorIOError as e:
4848
logging.error(f'Condor error: {e}')
4949

@@ -179,7 +179,7 @@ def iterate_ads(ads, name, metrics, last_job):
179179
# TODO: Add file tail function for condor history files
180180
#parser.add_option('-f','--histfile',
181181
# help='history file to read from')
182-
parser.add_option('-s','--schedd',default=False, action='store_true')
182+
parser.add_option('-a','--access_points',default=None)
183183
parser.add_option('-p','--port', default=9100,
184184
action='store', type='int',
185185
help='port number for prometheus exporter')
@@ -208,7 +208,7 @@ def iterate_ads(ads, name, metrics, last_job):
208208
while True:
209209
start = time.time()
210210
for collector in args:
211-
query_collector(collector, metrics, last_job)
211+
query_collector(collector, options.access_points, metrics, last_job)
212212

213213
delta = time.time() - start
214214
# sleep for interval minus scrape duration

condor_queue_to_es.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def es_generator(entries):
8484
es_import = partial(bulk, es, max_retries=20, initial_backoff=10, max_backoff=3600)
8585

8686
failed = False
87-
if options.access_points:
87+
if options.access_points and options.collectors:
8888
for coll_address in options.positionals:
8989
try:
9090
gen = es_generator(read_from_collector(coll_address, options.access_points))

condor_queue_to_prometheus.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def compose_ad_metrics(ads):
7575

7676
parser.add_option('-c','--collectors',default=False, action='store_true',
7777
help='read history from')
78-
78+
parser.add_option('-a','--access_points',default=None)
7979
parser.add_option('-p','--port', default=9100,
8080
action='store', type='int',
8181
help='port number for prometheus exporter')
@@ -97,14 +97,14 @@ def compose_ad_metrics(ads):
9797
while True:
9898
gens = []
9999
start = time.time()
100-
if options.access_points:
100+
if options.access_points and options.collectors:
101101
for coll_address in args:
102102
try:
103103
gens.append(read_from_collector(coll_address, options.access_points))
104104
except htcondor.HTCondorIOError as e:
105105
failed = e
106106
logging.error('Condor error', exc_info=True)
107-
if options.collectors:
107+
elif options.collectors:
108108
for coll_address in args:
109109
try:
110110
gens.append(read_from_collector(coll_address))

condor_status_to_es.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
class Dry:
3636
"""Helper class for debugging"""
3737
_dryrun = False
38-
38+
3939
def __init__(self, func):
4040
self.func = func
4141

@@ -44,7 +44,7 @@ def __call__(self, *args, **kwargs):
4444
logging.info(self.func.__name__)
4545
logging.info(args)
4646
logging.info(kwargs)
47-
47+
4848
else:
4949
return self.func(*args,**kwargs)
5050

@@ -296,7 +296,7 @@ def key = status+"."+resource;
296296
"--after", default=timedelta(hours=1), help="time to look back", type=parse_time
297297
)
298298
parser.add_argument(
299-
"-y",
299+
"-d",
300300
"--dry-run",
301301
default=False,
302302
action="store_true",
@@ -353,7 +353,7 @@ def key = status+"."+resource;
353353

354354
url = "{}://{}".format(prefix, address)
355355
logging.info("connecting to ES at %s", url)
356-
es = Elasticsearch(hosts=[url],
356+
es = Elasticsearch(hosts=[url],
357357
timeout=5000,
358358
bearer_auth=token,
359359
sniff_on_node_failure=True)

condor_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -774,8 +774,8 @@ def read_from_collector(address, access_points=None, history=False, constraint='
774774
coll = htcondor.Collector(address)
775775
schedd_ads = []
776776
if access_points:
777-
for ap in access_points:
778-
schedd_ads += coll.locate(htcondor.DaemonTypes.Schedd, ap)
777+
for ap in access_points.split(','):
778+
schedd_ads.append(coll.locate(htcondor.DaemonTypes.Schedd, ap))
779779
else:
780780
schedd_ads = coll.locateAll(htcondor.DaemonTypes.Schedd)
781781
for schedd_ad in schedd_ads:

0 commit comments

Comments
 (0)