-
Notifications
You must be signed in to change notification settings - Fork 497
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new alert source file in support of periodic truenas_verify runs.
Update audit setup to generate an 'initial' version tagged truenas_verify log. Fix truenas_verify audit setup. Use ThreadedAlertSource Fix up import formatting. Removed setup_truenas_verify as an API endpoint. Moved to an audit utility. Converted truenas_verify call to middleware async 'run'. Small Flake8 fix: json was imported but not used. Convert to run_in_thread module call. Move from once per hour to once per day.
- Loading branch information
Showing
3 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/middlewared/middlewared/alert/source/truenas_verify.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from datetime import timedelta | ||
import subprocess | ||
|
||
from middlewared.alert.base import AlertClass, AlertCategory, Alert, AlertLevel, ThreadedAlertSource | ||
from middlewared.alert.schedule import IntervalSchedule | ||
|
||
|
||
# --------------- Monitored Alerts ---------------- | ||
class TrueNASVerifyServiceChangeDetectionAlertClass(AlertClass): | ||
category = AlertCategory.AUDIT | ||
level = AlertLevel.ERROR | ||
title = "TrueNAS Verify Service: Changes detected in root file system." | ||
text = "%(verrs)s" | ||
|
||
|
||
class TrueNASVerifyServiceChangeDetectionAlertSource(ThreadedAlertSource): | ||
''' | ||
Periodic verification of root file system | ||
''' | ||
schedule = IntervalSchedule(timedelta(hours=24)) | ||
run_on_backup_node = False | ||
|
||
def check_sync(self): | ||
# Capture the results in syslog | ||
res = subprocess.run(['truenas_verify', 'syslog'], capture_output=True, text=True) | ||
if res.returncode: | ||
errmsg = f"{res.stderr} See syslog for details." | ||
return Alert( | ||
TrueNASVerifyServiceChangeDetectionAlertClass, | ||
{'verrs': errmsg}, | ||
key=None | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters