Welcome to Yasmon’s documentation!
Yet Another System Monitor written in Python with flexible and extensible tasks and callbacks, as well as proper logging facilities. Written with Python 3.11 onwards in mind.
Design choices
Configuration in a single YAML file
Detailed logging to system journal
Runnable as a system service
Concurrent execution of tasks and callbacks
Task attributes for callback parameters
Repurposable callbacks
Tasks
Monitoring file and directory changes,
yasmon.tasks.WatchfilesTask
🚧 Running scheduled tasks,
yasmon.tasks.SchedulerTask
🚧 Monitoring general shell commands,
yasmon.tasks.ShellTask
🚧 Monitoring disk usage,
yasmon.tasks.DiskUsageTask
🚧 Monitoring systemd services,
yasmon.tasks.SystemdServiceTask
🚧 Monitoring memory usage,
yasmon.tasks.MemoryUsageTask
🚧 Monitoring cpu load,
yasmon.tasks.CpuLoadTask
🚧 Monitoring file permissions,
yasmon.tasks.FilePermissionsTask
🚧 Monitoring ping,
yasmon.tasks.PingTask
Callbacks
Shell commands,
yasmon.callbacks.ShellCallback
Logger callback,
yasmon.callbacks.LoggerCallback
Mail notifications,
yasmon.callbacks.MailCallback
Example
Assume that we want to keep a directory in sync between two machines.
We could define a task with attributes src
and dest
that calls rsync
upon any change in /tmp/dir/
to sync with a remote host.
The rsync
shell callback can use the attributes associated with a task
and thus could be reused for other tasks. Additionally, we want to send an email
to report on changes and attach a log file.
---
log_journal:
level: info
log_file:
level: debug
path: /tmp/yasmon.log
tasks:
directory_monitor:
type: watchfiles
changes:
- modified
- added
- deleted
callbacks:
- rsync
- mail_report
paths:
- /tmp/dir/
attrs:
src: /tmp/dir/
dest: user@host.domain.com:/tmp/dir
callbacks:
rsync:
type: shell
command: rsync -av {src} {dest} --delete
mail_report:
type: mail
host: smtp.server.com
port: 587
login: user@server.com
password: password
security: starttls
from: user@server.com
to: destination@another.com
subject: "Yasmon notification"
message: |
Yasmon
======
Directory monitor reports: {path} has been {change}.
Running sync...
attach:
- /tmp/yasmon.log
delay: 10