Additional checks for paths
+import os
+import pathlib
+
from django.conf import settings
from django.core import checks
-from promgen import models
+from promgen import models, util
@checks.register(checks.Tags.models)
@@ -22,6 +25,29 @@ def sites(app_configs, **kwargs):
@checks.register(checks.Tags.models)
def shards(**kwargs):
if models.Shard.objects.filter(enabled=True).count() == 0:
- yield checks.Warning("Missing shards", hint="Ensure some shards are registerd")
+ yield checks.Warning("Missing shards", hint="Ensure some shards are enabled")
if models.Shard.objects.filter(proxy=True).count() == 0:
- yield checks.Warning("No proxy shards", hint="Ensure some shards are registerd")
+ yield checks.Warning("No proxy shards", hint="Ensure some shards are enabled")
+
+
+@checks.register("settings")
+def directories(**kwargs):
+ for key in ["prometheus:rules", "prometheus:blackbox", "prometheus:targets"]:
+ try:
+ path = pathlib.Path(util.setting(key)).parent
+ except TypeError:
+ yield checks.Warning("Missing setting for " + key)
+ else:
+ if not os.access(path, os.W_OK):
+ yield checks.Warning("Unable to write to %s" % path)
+
+
+@checks.register("settings")
+def promtool(**kwargs):
+ try:
+ path = pathlib.Path(util.setting("prometheus:promtool"))
+ except TypeError:
+ yield checks.Warning("Missing setting for " + key)
+ else:
+ if not os.access(path, os.X_OK):
+ yield checks.Warning("Unable to execute file %s" % path)
