Skip to content

Commit 9cb54a2

Browse files
authored
Merge pull request #314 from Helene/rawcount
Enable overwriting rawCounters by using cli or env variables
2 parents 3e630d5 + 7c4df90 commit 9cb54a2

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ ENV LOGPATH=$DEFAULTLOGPATH
8383
ARG DEFAULTLOGLEVEL=15
8484
ENV LOGLEVEL=$DEFAULTLOGLEVEL
8585

86+
ARG RAWDATA=None
87+
ENV RAWCOUNTERS=$RAWDATA
88+
8689
RUN echo "the HTTP/S protocol is set to $PROTOCOL" && \
8790
echo "the HTTP/S basic authentication is set to $BASICAUTH" && \
8891
echo "the OpentTSDB API HTTP/S port is set to $PORT" && \
@@ -157,7 +160,7 @@ RUN chown -R $UID:$GID /opt/IBM/bridge && \
157160
# Switch user
158161
USER $GID
159162

160-
CMD ["sh", "-c", "python3 zimonGrafanaIntf.py -c $LOGLEVEL -s $SERVER -r $PROTOCOL -b $BASICAUTH -u $BASICAUTHUSER -a $BASICAUTHPASSW -p $PORT -e $PROMETHEUS -P $SERVERPORT -t $TLSKEYPATH -l $LOGPATH -k $TLSKEYFILE -m $TLSCERTFILE -n $APIKEYNAME -v $APIKEYVALUE"]
163+
CMD ["sh", "-c", "python3 zimonGrafanaIntf.py -c $LOGLEVEL -s $SERVER -r $PROTOCOL -b $BASICAUTH -u $BASICAUTHUSER -a $BASICAUTHPASSW -p $PORT -e $PROMETHEUS -P $SERVERPORT -t $TLSKEYPATH -l $LOGPATH -k $TLSKEYFILE -m $TLSCERTFILE -n $APIKEYNAME -v $APIKEYVALUE -w $RAWCOUNTERS"]
161164

162165
EXPOSE 4242 8443 9250
163166

source/confParser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ def parse_cmd_args(argv):
252252
help='Enter your apiKey value:')
253253
parser.add_argument('-d', '--includeDiskData', action="store", choices=["yes", "no"], default=None,
254254
help='Use or not the historical data from disk (Default from config.ini: "no")')
255+
parser.add_argument('-w', '--rawCounters', action="store", choices=["True", "False"], default=None,
256+
help='Controls if original sensor counters should be exposed by PrometheusExporter (Default from config.ini: "True")')
255257

256258
args = parser.parse_args(argv)
257259
return args, ''

tests/test_params.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
def my_setup():
10-
global a, b, c, d, e, f, g, m, n, o, p, y, r, s
10+
global a, b, c, d, e, f, g, m, n, o, p, y, r, s, w, v
1111
a = ConfigManager().defaults
1212
y = ConfigManager().defaults.copy()
1313
y['apiKeyValue'] = '/tmp/mykey'
@@ -18,6 +18,7 @@ def my_setup():
1818
m, n = parse_cmd_args(['-d', 'yes'])
1919
o, p = parse_cmd_args(['-v', 'e40960c9-de0a-4c75-bc71-0bcae6db23b2'])
2020
r, s = parse_cmd_args(['-p', '4242', '-e', '9250'])
21+
w, v = parse_cmd_args(['-w', 'False'])
2122

2223

2324
@with_setup(my_setup)
@@ -199,3 +200,12 @@ def test_case16():
199200
assert 'password' not in result.keys()
200201
assert valid
201202
assert len(msg) == 0
203+
204+
205+
@with_setup(my_setup)
206+
def test_case17():
207+
if version >= "8.0":
208+
result = merge_defaults_and_args(a, w)
209+
assert len(result.keys()) > 0
210+
assert 'rawCounters' in result.keys()
211+
assert result.get('rawCounters') == eval("False")

0 commit comments

Comments
 (0)