Skip to content

Commit feb1ca3

Browse files
committed
improve configuration handlong, healthcheck set to ALARM if 1
1 parent 07cd358 commit feb1ca3

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

init.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/local/bin/python
1+
#!/usr/bin/python
22
"""Thios is Jenkins HTTP check remote modue."""
33
import sys
44
import os
@@ -10,12 +10,15 @@
1010

1111

1212
# Parse config file
13-
with open("config.yaml", 'r') as stream:
13+
with open("/app/cfg/config.yaml", 'r') as stream:
1414
try:
1515
config = yaml.load(stream)
1616
except yaml.YAMLError as exc:
1717
print(exc)
1818
sys.exit(1)
19+
except IOError as e:
20+
print(("Config file not found: {0}").format(e))
21+
sys.exit(1)
1922

2023
cfg_metrics = config['metrics']
2124

@@ -63,7 +66,7 @@ def host_ping():
6366
api.Metric.send(
6467
metric='jenkins.healthcheck.ping',
6568
host=config['host'],
66-
points=1,
69+
points=0,
6770
tags=ping_tag,
6871
type='gauge'
6972
)
@@ -83,10 +86,10 @@ def report_healthcheck():
8386
sys.exit(1)
8487
# populate mentrics tags
8588
for check in healthcheck.keys():
86-
if healthcheck[check]['healthy'] == 'true':
87-
check_value = 1
88-
else:
89+
if healthcheck[check]['healthy'] is True:
8990
check_value = 0
91+
else:
92+
check_value = 1
9093
api.Metric.send(
9194
metric=("jenkins.healthcheck.{0}").format(check),
9295
host=config['host'],

0 commit comments

Comments
 (0)