Network Mount Monitoring is a Python-based tool designed to monitor and manage network mounts on a Linux system. The tool uses D-Bus interfaces provided by NetworkManager and systemd to monitor network state changes and systemd journal logs for network mount errors. It aims to prevent system hangs due to network mount issues by automatically handling mount and automount units.
- NetworkManager D-Bus Monitoring: Listens to NetworkManager signals for network device state changes and global network state changes.
- Systemd Journal Monitoring: Monitors systemd journal for kernel log messages related to network mount errors.
- Systemd Unit Control: Manages systemd mount and automount units, including resetting failed units and restarting them as needed.
network_mount_monitoring_project/
├── network_mount_monitoring/
│ ├── __main__.py
│ ├── __init__.py
│ ├── config.py
│ ├── dbus_monitoring.py
│ ├── journal_monitoring.py
│ └── mount_control.py
└── requirements.txt
network_mount_monitoring/__main__.py
: The main script to run the network mount monitoring.network_mount_monitoring/__init__.py
: Initializes the package.network_mount_monitoring/config.py
: Configuration file for the project, including the list of network mounts.network_mount_monitoring/dbus_monitoring.py
: Contains theDbusMonitoring
class for monitoring NetworkManager D-Bus signals.network_mount_monitoring/journal_monitoring.py
: Contains theJournalctlMonitoring
class for monitoring systemd journal logs.network_mount_monitoring/mount_control.py
: Contains theMountControl
class for controlling systemd units.requirements.txt
: Python dependencies required for the project.
-
Clone the repository:
git clone [ THIS PROJECT URL ] cd network_mount_monitoring
-
Create a virtual environment and activate it:
python3 -m venv .venv source .venv/bin/activate
-
Install the dependencies:
pip install -r requirements.txt
Edit the network_mount_monitoring/config.py
file to specify the list of network mounts you want to monitor. For example:
NETWORK_MOUNT_NAMES = ["home-vaarlion-Nas", "home-vaarlion-Media"]
Note that this expect that you've already created the .mount
and .automount
unit yourself.
Run the main script to start monitoring:
python -m network_mount_monitoring
The project uses the logging
module to provide information about its operations. By default, it logs to the console. You can configure the logging settings in the main.py
file by adjusting the logging.basicConfig
call.
If you would like to contribute to this project, please fork the repository and submit a pull request. For major changes, please open an issue to discuss what you would like to change.
This project is licensed under the GNU GPLv3 License. See the LICENSE
file for details.