# LLM-Powered Monitoring Agent This project is a self-hosted monitoring agent that uses a local Large Language Model (LLM) to detect anomalies in system and network data. It's designed to be a simple, self-contained Python script that can be easily deployed on a server. ## 1. Installation To get started, you'll need to have Python 3.8 or newer installed. Then, follow these steps: 1. **Clone the repository or download the files:** ```bash git clone cd ``` 2. **Create and activate a Python virtual environment:** ```bash python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate` ``` 3. **Install the required Python libraries:** ```bash pip install -r requirements.txt ``` ## 2. Setup Before running the agent, you need to configure it and ensure the necessary services are running. ### Prerequisites - **Ollama:** The agent requires that [Ollama](https://ollama.com/) is installed and running on the server. - **LLM Model:** You must have the `llama3.1:8b` model pulled and available in Ollama. You can pull it with the following command: ```bash ollama pull llama3.1:8b ``` ### Configuration All configuration is done in the `config.py` file. You will need to replace the placeholder values with your actual credentials and URLs. - `DISCORD_WEBHOOK_URL`: Your Discord channel's webhook URL. This is used to send alerts. - `HOME_ASSISTANT_URL`: The URL of your Home Assistant instance (e.g., `http://192.168.1.50:8123`). - `HOME_ASSISTANT_TOKEN`: A Long-Lived Access Token for your Home Assistant instance. You can generate this in your Home Assistant profile settings. - `GOOGLE_HOME_SPEAKER_ID`: The `media_player` entity ID for your Google Home speaker in Home Assistant (e.g., `media_player.kitchen_speaker`). ## 3. Usage Once the installation and setup are complete, you can run the monitoring agent with the following command: ```bash python monitor_agent.py ``` The script will start a continuous monitoring loop. Every 5 minutes, it will: 1. Collect simulated system and network data. 2. Send the data to the local LLM for analysis. 3. If the LLM detects an anomaly, it will send an alert to your configured Discord channel and broadcast a message to your Google Home speaker via Home Assistant. The script will print its status and any detected anomalies to the console.