This Python script collects system information and sends it as a JSON payload to a server every 10 minutes. It utilizes the psutil library to gather information about CPU utilization, RAM usage, disk space utilization, network data, system uptime, and battery percentage (for laptops and mobile devices).
Before running the script, ensure you have the following:
- Python installed on your system.
- The required Python libraries installed. You can install them using pip:
pip install psutil schedule requests python-dotenv- Create a
.envfile in the same directory as the script. - Add the necessary environment variables to the
.envfile:
SERVER_URL=<your_server_url>
TOKEN=<your_authentication_token>- Run the script using the following command:
python main.py
The script will start collecting system information and sending it to the specified server URL via HTTP POST requests every 10 minutes. It will print the status of each request to the console.
Please make sure that the server is properly configured to handle incoming POST requests and process the system information accordingly.
- The script fetches the CPU utilization, RAM utilization, disk utilization, network data, uptime, and battery percentage (if available) to create a JSON payload.
- The
psutillibrary is used for system information retrieval. - The
dotenvlibrary is used to load environment variables from the.envfile. - The script runs indefinitely, sending system information in regular intervals, until manually stopped.
SERVER_URL=http://192.168.68.122:7940 TOKEN=q3Ynm4QsAkaqqNdGtMRyp5WLTJmM6cga