Skip to content

Commit

Permalink
added --once parameter to health check command
Browse files Browse the repository at this point in the history
  • Loading branch information
nurbal committed Dec 17, 2024
1 parent 87ad1b1 commit 453aaaf
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion sarc/cli/health/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import gifnoc

from sarc.alerts.common import config
from sarc.alerts.common import CheckStatus, config
from sarc.alerts.runner import CheckRunner

logger = logging.getLogger(__name__)
Expand All @@ -14,6 +14,7 @@
@dataclass
class HealthCheckCommand:
config: Path = None
once: bool = False

name: str = None

Expand All @@ -26,6 +27,17 @@ def execute(self) -> int:
for k, status in results.statuses.items():
print(f"{status.name} -- {k}")
print(f"{results.status.name}")
elif self.once:
for check in [c for c in config.checks.values() if c.active]:
results = check(write=False)
if results.status == CheckStatus.OK:
print(f"Check '{check.name}' succeeded.")
else:
print(f"Check '{check.name}' failed.")
pprint(results)
for k, status in results.statuses.items():
print(f"{status.name} -- {k}")
print(f"{results.status.name}")
else:
try:
runner = CheckRunner(
Expand Down

0 comments on commit 453aaaf

Please sign in to comment.