#!/bin/bash
#
# AORTA RESOURCE EXPORTER FOR HOSTS
#
# Usage of ./resource-exporter:
#   -allow.host string
#     	Allow Host (default "127.0.0.1")
#   -libvirt.driver string
#     	Available drivers: qemu:///system (Default), qemu:///session, xen:///system and test:///default  (default "qemu:///system")
#   -libvirt.uri string
#     	Libvirt URI from which to extract metrics. (default "/var/run/libvirt/libvirt-sock")
#   -web.listen-address string
#     	Address to listen on for web interface and telemetry. (default ":9100")
#   -web.telemetry-path string
#     	Path under which to expose metrics. (default "/metrics")

liste_port="0.0.0.0:9100"
allow_host="127.0.0.1,192.168.188.51,192.168.188.253"
libvi_sock="/var/run/libvirt/libvirt-sock"
old_proc=$(ps -ef | grep resource-exporter |awk /listen/'{print $2}')

# startup resource exporter
if [[ -z $old_proc ]];then
    ./resource-exporter -web.listen-address $liste_port -allow.host $allow_host &
else
    echo "Service is running"
fi
