# System Monitor API Usage Guide This guide explains how to interact with the System Monitor API to retrieve system performance metrics and process information. ## Authentication All requests to this API require an API key in the header: ``` X-API-Key: your-secret-api-key ``` ## Base URL The base URL for all API requests is: ``` https://automation.lunaskye.net ``` ## Available Endpoints ### 1. Check API Status **Request:** - Method: GET - Endpoint: / - Headers: X-API-Key **Response:** ```json { "message": "System Monitor API is running" } ``` ### 2. System Information **Request:** - Method: GET - Endpoint: /system - Headers: X-API-Key **Response:** ```json { "hostname": "server-name", "platform": "Linux", "platform_release": "5.15.0", "platform_version": "Ubuntu SMP", "architecture": "x86_64", "processor": "x86_64", "ram_total": 8589934592, "ram_available": 4294967296, "uptime": 86400.5 } ``` ### 3. Performance Metrics **Request:** - Method: GET - Endpoint: /performance - Headers: X-API-Key **Response:** ```json { "cpu_percent": 15.0, "memory_percent": 37.4, "disk_io_read": 278998985216, "disk_io_write": 79401723904, "network_sent": 2786123192, "network_received": 15942286230, "timestamp": "2025-03-18T20:33:52.289877" } ``` ### 4. Disk Information **Request:** - Method: GET - Endpoint: /disks - Headers: X-API-Key **Response:** ```json [ { "device": "/dev/sda1", "mountpoint": "/", "filesystem": "ext4", "total": 80307429376, "used": 38700105728, "free": 38284709888, "percent": 50.3 } ] ``` ### 5. Process List **Request:** - Method: GET - Endpoint: /processes - Headers: X-API-Key **Response:** ```json [ { "pid": 1, "name": "systemd", "username": "root", "status": "sleeping", "cpu_percent": 0.0, "memory_percent": 0.15, "created_time": 1740600425.2, "cmdline": ["/sbin/init"] } ] ``` ### 6. Specific Process Information **Request:** - Method: GET - Endpoint: /process/{pid} - Headers: X-API-Key **Response:** ```json { "pid": 1, "name": "systemd", "username": "root", "status": "sleeping", "cpu_percent": 0.0, "memory_percent": 0.15, "created_time": 1740600425.2, "cmdline": ["/sbin/init"] } ``` ### 7. Send Notifications **Request:** - Method: POST - Endpoint: /notify/issue - Headers: X-API-Key - Query Parameters: - message: The notification message - severity: The severity level (default: "info") **Response:** ```json { "status": "notification received", "timestamp": "2025-03-18T20:33:52.383916" } ``` ## Error Handling If the API key is invalid or missing, the API will return a 401 Unauthorized response. If a requested process does not exist, the API will return a 404 Not Found response.