This Python tool collects and stores system information in a MongoDB database. The information includes CPU, memory, disk, network, system uptime, temperature, and user details. It also checks for available updates.
- Collects CPU, memory, disk, network, and uptime information.
- Retrieves system temperature for CPU and specific disks.
- Counts total and active users.
- Lists active network connections.
- Checks for operating system updates.
- Stores collected information in a MongoDB database.
- Python 3.7+
- MongoDB
- Required Python packages (listed in
requirements.txt
) smartmontools
for disk temperature readings
-
Clone the repository:
git clone https://github.com/P1ro/syspynfo.git cd syspynfo
-
Create and activate a virtual environment:
python3 -m venv .venv source .venv/bin/activate
-
Install the required Python packages:
pip install -r requirements.txt
-
Install
smartmontools
:-
Debian/Ubuntu:
sudo apt-get install smartmontools
-
Arch Linux:
sudo pacman -S smartmontools
-
Gentoo:
sudo emerge sys-apps/smartmontools
-
CentOS:
sudo yum install smartmontools
-
-
Configure MongoDB connection:
Create a
config.yaml
file with the following structure:mongo_uri: "your_mongo_db_uri" database_name: "your_database_name"
-
Run the tool:
./.venv/bin/python syspynfo.py
-
Output:
The tool will log the collected information and execution time. The information will be stored in the specified MongoDB database under the collections
hostcharts
,hostreports
, andhosts
.
convert_to_kilobytes(value)
: Converts bytes to kilobytes.get_local_ip(interface_name)
: Retrieves the local IP address for the given network interface.get_hostname()
: Returns the system hostname.get_kernel_info()
: Collects kernel information.get_operating_system_info()
: Retrieves operating system details.check_for_updates()
: Checks for available OS updates.get_cpu_info()
: Collects CPU information.get_memory_info()
: Retrieves memory details.get_disk_info()
: Collects disk usage information.get_net_io_counters()
: Retrieves network I/O counters.get_system_uptime()
: Calculates system uptime.get_temperature_info()
: Retrieves temperature data for CPU and specified disks.count_users()
: Counts total and active users.list_active_connections()
: Lists active network connections.get_system_info()
: Aggregates all system information.upload_to_mongodb(data, collection_name)
: Uploads collected data to MongoDB.
The tool uses Python's logging module to log information. The log level is set to INFO
.
This project is licensed under the MIT License - see the LICENSE file for details.
This script retrieves the temperature of a specified disk using smartctl
from smartmontools
. You can find the script here.