mirror of
https://github.com/thegeeklab/prometheus-pve-sd.git
synced 2024-11-24 18:30:40 +00:00
feat: add option service to run sd in a loop (default: true)
This commit is contained in:
parent
c40eac65f4
commit
fdc41dcdef
@ -48,6 +48,12 @@ class PrometheusSD:
|
||||
action="store",
|
||||
help="delay between discovery runs"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--no-service",
|
||||
dest="service",
|
||||
action="store_false",
|
||||
help="run discovery as a service"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-v", dest="logging.level", action="append_const", const=-1, help="increase log level"
|
||||
)
|
||||
@ -90,12 +96,15 @@ class PrometheusSD:
|
||||
output_file = self.config.config["output_file"]
|
||||
|
||||
self.logger.info("Writes targets to {}".format(output_file))
|
||||
self.logger.debug("Propagate from PVE")
|
||||
|
||||
while True:
|
||||
self.logger.debug("Propagate from PVE")
|
||||
self._write(self.discovery.propagate())
|
||||
|
||||
self.logger.info("Waiting {} seconds for next loop".format(loop_delay))
|
||||
if not self.config.config["service"]:
|
||||
break
|
||||
|
||||
self.logger.info("Waiting {} seconds for next discovery loop".format(loop_delay))
|
||||
sleep(self.config.config["loop_delay"])
|
||||
|
||||
def _write(self, host_list: HostList):
|
||||
|
@ -61,6 +61,12 @@ class Config():
|
||||
"file": True,
|
||||
"type": environs.Env().int
|
||||
},
|
||||
"service": {
|
||||
"default": True,
|
||||
"env": "SERVICE",
|
||||
"file": True,
|
||||
"type": environs.Env().bool
|
||||
},
|
||||
"exclude_state": {
|
||||
"default": [],
|
||||
"env": "EXCLUDE_STATE",
|
||||
|
Loading…
Reference in New Issue
Block a user