add exclude

This commit is contained in:
ducoterra
2020-04-05 18:57:47 -04:00
parent 3bee35b090
commit 3207ed1508
4 changed files with 26 additions and 7 deletions

View File

@@ -8,7 +8,7 @@ from collector.helper import *
CONFIG_FILE = os.getenv("COLLECTOR_CONF", "collector.json")
REQUIRED = ["graphite","os","data"]
VALID_DATAPOINTS = ["storage"]
VALID_DATAPOINTS = ["storage", "heartbeat"]
VALID_OS = ["linux", "osx"]
REQUIRED_STORAGE = ["path", "name"]
CONFIG = {}
@@ -67,5 +67,12 @@ if "storage" in data_points:
else:
name = item["name"]
path = item["path"]
storage_sender = functools.partial(sender, f"{HOSTNAME}.storage.{name}")
thread(collect_storage, storage_sender, path)
exclude = item.get("exclude", None)
else:
storage_sender = functools.partial(sender, f"{HOSTNAME}.storage.{name}")
thread(collect_storage, storage_sender, path, exclude = exclude)
# Check heartbeat
if "heartbeat" in data_points:
heartbeat_sender = functools.partial(sender, f"{HOSTNAME}.heartbeat")
thread(lambda: 1, heartbeat_sender)

View File

@@ -4,7 +4,6 @@ import threading
import subprocess
import re
import functools
import random
import time
from .sender import send
@@ -36,6 +35,9 @@ def collect_temp():
def collect_compute():
pass
def collect_storage(path):
storage = nice_run(["du", "-sk", path])
def collect_storage(path, exclude = None):
cmd = ["du", "-sk", path]
if exclude:
cmd += [f"--exclude={exclude}"]
storage = nice_run(cmd)
return clean_storage(storage)