Compare commits
No commits in common. "master" and "0.1" have entirely different histories.
|
@ -4,13 +4,12 @@ from prometheus_client import start_http_server, Gauge
|
|||
from time import sleep, mktime
|
||||
from dateutil import parser
|
||||
|
||||
import sys
|
||||
import os
|
||||
import json
|
||||
import subprocess
|
||||
|
||||
HTTP_PORT = 9401
|
||||
BACKUP_DIRECTORY = '/srv/backup'
|
||||
BACKUP_DIRECTORY = '/tmp/backup'
|
||||
INTERVAL = 30 * 60 # seconds
|
||||
|
||||
total_chunks = Gauge('borg_repository_total_chunks', 'Number of chunks', ['name'])
|
||||
|
@ -23,13 +22,6 @@ last_modified = Gauge('borg_repository_last_modified', 'Last modified UNIX
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) == 2:
|
||||
BACKUP_DIRECTORY = sys.argv[1]
|
||||
elif len(sys.argv) > 2:
|
||||
sys.exit("Invalid number of arguments. Usage: ./prometheus-borgbackup-exporter [backup-directory]")
|
||||
|
||||
print("Backup directory is: {}".format(BACKUP_DIRECTORY))
|
||||
|
||||
# Serve metrics over HTTP.
|
||||
print("Starting prometheus-orgbackup-exporter on port",
|
||||
"{}...".format(HTTP_PORT), end='')
|
||||
|
@ -49,17 +41,13 @@ if __name__ == '__main__':
|
|||
for entry in entries:
|
||||
if not entry.is_dir():
|
||||
print(">> Ignoring {} since it is not a directory.".format(entry.name))
|
||||
elif entry.name[0] == '.':
|
||||
print(">> Ignoring {} since it is a dot directory.".format(entry.name))
|
||||
else:
|
||||
repository_name = entry.name
|
||||
repository_path = entry.path
|
||||
|
||||
try:
|
||||
print(">> Querying borg for {}...".format(repository_name), end='')
|
||||
env = os.environ
|
||||
env["BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK"] = "yes"
|
||||
raw_borg_json = subprocess.check_output(['borg', 'info', '--json', repository_path], env=env)
|
||||
raw_borg_json = subprocess.check_output(['borg', 'info', '--json', repository_path])
|
||||
info = json.loads(raw_borg_json)
|
||||
|
||||
stats = info['cache']['stats']
|
||||
|
|
Reference in New Issue