Rename PASSWORD_FILE env var to RESTIC_REPO_PASSWORD_FILE
This commit is contained in:
parent
f04f5468d8
commit
3e00452190
3 changed files with 8 additions and 11 deletions
|
@ -20,7 +20,7 @@ Requirements:
|
|||
pip install -r /requirements.txt
|
||||
|
||||
export RESTIC_REPO_URL=/data
|
||||
export PASSWORD_FILE=/restic_password_file
|
||||
export RESTIC_REPO_PASSWORD_FILE=/restic_password_file
|
||||
python restic-exporter.py
|
||||
```
|
||||
|
||||
|
|
|
@ -3,17 +3,14 @@
|
|||
# Exit on error. For debug use set -x
|
||||
set -e
|
||||
|
||||
export PASSWORD_FILE="/tmp/restic_passwd"
|
||||
|
||||
if [ -z "${RESTIC_REPO_PASSWORD}" ]; then
|
||||
if [ -z "${RESTIC_REPO_PASSWORD_FILE}" ]; then
|
||||
echo "You have to define one of these environment variables: RESTIC_REPO_PASSWORD or RESTIC_REPO_PASSWORD_FILE"
|
||||
exit 1
|
||||
else
|
||||
cp "${RESTIC_REPO_PASSWORD_FILE}" "${PASSWORD_FILE}"
|
||||
fi
|
||||
else
|
||||
echo "${RESTIC_REPO_PASSWORD}" > "${PASSWORD_FILE}"
|
||||
export RESTIC_REPO_PASSWORD_FILE="/tmp/restic_passwd"
|
||||
echo "${RESTIC_REPO_PASSWORD}" > "${RESTIC_REPO_PASSWORD_FILE}"
|
||||
fi
|
||||
|
||||
/usr/local/bin/python -u /restic-exporter.py
|
||||
|
|
|
@ -14,9 +14,9 @@ import prometheus_client.core
|
|||
|
||||
|
||||
class ResticCollector(object):
|
||||
def __init__(self, repository, password_file_):
|
||||
def __init__(self, repository, password_file):
|
||||
self.repository = repository
|
||||
self.password_file = password_file_
|
||||
self.password_file = password_file
|
||||
# todo: the stats cache increases over time -> remove old ids
|
||||
# todo: cold start -> the stats cache could be saved in a persistent volume
|
||||
# todo: cold start -> the restic cache (/root/.cache/restic) could be saved in a persistent volume
|
||||
|
@ -212,16 +212,16 @@ if __name__ == "__main__":
|
|||
sys.exit(1)
|
||||
|
||||
try:
|
||||
password_file = os.environ["PASSWORD_FILE"]
|
||||
restic_repo_password_file = os.environ["RESTIC_REPO_PASSWORD_FILE"]
|
||||
except Exception:
|
||||
logging.error("Configuration error. The environment variable PASSWORD_FILE is mandatory")
|
||||
logging.error("Configuration error. The environment variable RESTIC_REPO_PASSWORD_FILE is mandatory")
|
||||
sys.exit(1)
|
||||
|
||||
exporter_address = os.environ.get("LISTEN_ADDRESS", "0.0.0.0")
|
||||
exporter_port = int(os.environ.get("LISTEN_PORT", 8001))
|
||||
exporter_refresh_interval = int(os.environ.get("REFRESH_INTERVAL", 60))
|
||||
|
||||
collector = ResticCollector(restic_repo_url, password_file)
|
||||
collector = ResticCollector(restic_repo_url, restic_repo_password_file)
|
||||
|
||||
prometheus_client.core.REGISTRY.register(collector)
|
||||
prometheus_client.start_http_server(exporter_port, exporter_address)
|
||||
|
|
Loading…
Reference in a new issue