summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ssh_exporter/__main__.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/ssh_exporter/__main__.py b/ssh_exporter/__main__.py
index 49f2894..5adcecd 100644
--- a/ssh_exporter/__main__.py
+++ b/ssh_exporter/__main__.py
@@ -1,5 +1,6 @@
"""Connect to server over SSH and collect metrics."""
+import argparse
import yaml
from prometheus_client import Counter, start_http_server
import jc.parsers.ifconfig
@@ -38,6 +39,10 @@ def main():
"""Entry point."""
running_user = os.getenv("USERNAME", "root")
+ parser = argparse.ArgumentParser(description="Prometheus SSH exporter")
+ parser.add_argument("-c", "--config", help="Config file", type=str)
+ args = parser.parse_args()
+
node_network_receive_bytes_total = Counter(
"node_network_receive_bytes_total",
"Network device statistic receive_bytes.",
@@ -62,12 +67,13 @@ def main():
["device", "target"],
)
- with open("/tmp/config.yml") as config_file:
+ with open(args.config) as config_file:
config = yaml.load(config_file, Loader=yaml.FullLoader)
listen_addresses = config["listen"] if "listen" in config else "0.0.0.0:9101"
interval = config["interval"] if "interval" in config else 10
start_http_server(
- port=int(listen_addresses.split(":")[1]), addr=listen_addresses.split(":")[0]
+ port=int(listen_addresses.split(":")[1]),
+ addr=listen_addresses.split(":")[0],
)
while True:
for host in config["hosts"].keys():