mirror of
https://github.com/thegeeklab/prometheus-pve-sd.git
synced 2024-11-25 02:40:39 +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",
|
action="store",
|
||||||
help="delay between discovery runs"
|
help="delay between discovery runs"
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--no-service",
|
||||||
|
dest="service",
|
||||||
|
action="store_false",
|
||||||
|
help="run discovery as a service"
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-v", dest="logging.level", action="append_const", const=-1, help="increase log level"
|
"-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"]
|
output_file = self.config.config["output_file"]
|
||||||
|
|
||||||
self.logger.info("Writes targets to {}".format(output_file))
|
self.logger.info("Writes targets to {}".format(output_file))
|
||||||
|
self.logger.debug("Propagate from PVE")
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
self.logger.debug("Propagate from PVE")
|
|
||||||
self._write(self.discovery.propagate())
|
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"])
|
sleep(self.config.config["loop_delay"])
|
||||||
|
|
||||||
def _write(self, host_list: HostList):
|
def _write(self, host_list: HostList):
|
||||||
|
@ -61,6 +61,12 @@ class Config():
|
|||||||
"file": True,
|
"file": True,
|
||||||
"type": environs.Env().int
|
"type": environs.Env().int
|
||||||
},
|
},
|
||||||
|
"service": {
|
||||||
|
"default": True,
|
||||||
|
"env": "SERVICE",
|
||||||
|
"file": True,
|
||||||
|
"type": environs.Env().bool
|
||||||
|
},
|
||||||
"exclude_state": {
|
"exclude_state": {
|
||||||
"default": [],
|
"default": [],
|
||||||
"env": "EXCLUDE_STATE",
|
"env": "EXCLUDE_STATE",
|
||||||
|
Loading…
Reference in New Issue
Block a user