This repository was archived by the owner on May 2, 2022. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ RUN pip install --no-cache-dir -r requirements.txt
99COPY jenkins_exporter.py /usr/src/app
1010
1111EXPOSE 9118
12+ ENV JENKINS_SERVER=http://jenkins:8080 VIRTUAL_PORT=9118 DEBUG=0
1213
1314ENTRYPOINT [ "python" , "-u" , "./jenkins_exporter.py" ]
14- CMD ["-j" , "http://jenkins:8080" , "-p" , "9118" ]
15+ CMD []
Original file line number Diff line number Diff line change 66import argparse
77from pprint import pprint
88
9+ import os
910from sys import exit
1011from prometheus_client import start_http_server
1112from prometheus_client .core import GaugeMetricFamily , REGISTRY
1213
13- DEBUG = 1
14+ DEBUG = int ( os . environ . get ( 'DEBUG' , '0' ))
1415
1516
1617class JenkinsCollector (object ):
@@ -144,15 +145,15 @@ def parse_args():
144145 metavar = 'jenkins' ,
145146 required = False ,
146147 help = 'server url from the jenkins api' ,
147- default = ' http://jenkins:8080'
148+ default = os . environ . get ( 'JENKINS_SERVER' , ' http://jenkins:8080')
148149 )
149150 parser .add_argument (
150151 '-p' , '--port' ,
151152 metavar = 'port' ,
152153 required = False ,
153154 type = int ,
154155 help = 'Listen to this port' ,
155- default = 9118
156+ default = int ( os . environ . get ( 'VIRTUAL_PORT' , ' 9118' ))
156157 )
157158 return parser .parse_args ()
158159
@@ -163,7 +164,7 @@ def main():
163164 port = int (args .port )
164165 REGISTRY .register (JenkinsCollector (args .jenkins ))
165166 start_http_server (port )
166- print "Serving at port: " , port
167+ print "Polling %s. Serving at port: %s" % ( args . jenkins , port )
167168 while True :
168169 time .sleep (1 )
169170 except KeyboardInterrupt :
You can’t perform that action at this time.
0 commit comments