Skip to main content

Comprehensive and concise system information querying tool.

Project description

Comprehensive and concise system information querying tool.

package version from PyPI build status from GitHub test coverage from Codecov grade from Codacy license

The goal is to gather all relevant:

  • hardware information (processors, accelerators, memory, networks, drives)

  • static operating system information (name, version, hostname)

  • runtime information (environment, libraries, system load, etc.)

and provide them in a concise form that’s both machine- and human-readable.

Another important goal is to also be fail-safe, even with unexpected hardware configurations, low-level tool errors and deal with incomplete information.

You can use system-query as a library and as a command-line tool.

Motivation

Where am I running?

One of the main motivations for creating system-query is to assist with answering the question “what is the actual hardware and software configuration of the system I’m using?” regardless of the official specification.

How to rerun this experiment?

The system-query was also created to assist with the computational experiment reproducibility and verification of results. Only if you know exactly where you ran your experiment, you can reason about its results and be able to reproduce them.

Using

Installing system-query doesn’t enable all the features by default. Some of the query functions will work only on some systems. To attempt installation with all features enables, run pip3 install system-query[all]. If something brakes, you can narrow down the features by typing a feature scope instead of all. You can choose from cpu, gpu, hdd, ram and swap. E.g. pip3 install system-query[gpu]. You can also select more than one feature at the same time, e.g. pip3 install system-query[cpu,hdd,ram].

As library

In [1]: import system_query

Usage examples are below and in examples.ipynb.

system_query.query_all()

This will get basic host and OS information and launch most of below functions, and then assemble the results into a single dictionary.

In [2]: system_query.query_all()
Out[2]:
{'host': 'hostname',
 'os': 'Linux-6.8.0-47-generic-x86_64-with-glibc2.35',
 'cpu': {'brand': 'Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz',
  'logical_cores': 12,
  'physical_cores': 6,
  'clock': 4131.882833333333,
  'clock_min': 800.0,
  'clock_max': 4500.0,
  'cache': {1: 196608, 2: 1572864, 3: 12582912}},
 'gpus': [{'brand': 'NVIDIA GeForce RTX 2060',
   'memory': 6214516736,
   'memory_clock': 7001000,
   'compute_capability': 7.5,
   'clock': 1200000,
   'multiprocessors': 30,
   'cores': None,
   'warp_size': 32}],
 'ram': {'total': 16631603200},
 'hdds': {'/dev/sdb': {'size': 0, 'model': '1081C'},
  '/dev/sdc': {'size': 0, 'model': '1081C'},
  '/dev/sda': {'size': 1953525168, 'model': 'WDC WD10SPZX-24Z'},
  '/dev/nvme0n1': {'size': 2000409264, 'model': 'SAMSUNG MZVLB1T0HBLR-000L2'}},
 'swap': {'total': 17179865088}}

system_query.query_cpu()

To be able to see details like cache size, clock speed and core counts, install Python packages pint and psutil.

In [3]: system_query.query_cpu()
Out[3]:
{'brand': 'Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz',
 'logical_cores': 12,
 'physical_cores': 6,
 'clock': 4182.955000000001,
 'clock_min': 800.0,
 'clock_max': 4500.0,
 'cache': {1: 196608, 2: 1572864, 3: 12582912}}

system_query.query_gpus()

To be able to see GPUs in the system, make sure you have CUDA installed and install Python package pycuda.

In [4]: system_query.query_gpus()
Out[4]:
[{'brand': 'NVIDIA GeForce RTX 2060',
  'memory': 6214516736,
  'memory_clock': 7001000,
  'compute_capability': 7.5,
  'clock': 1200000,
  'multiprocessors': 30,
  'cores': None,
  'warp_size': 32}]

system_query.query_hdds()

To be able to see HDDs in the system, make sure you have libudev installed and install Python package pyudev.

In [5]: system_query.query_hdds()
Out[5]:
{'/dev/sdb': {'size': 0, 'model': '1081C'},
 '/dev/sdc': {'size': 0, 'model': '1081C'},
 '/dev/sda': {'size': 1953525168, 'model': 'WDC WD10SPZX-24Z'},
 '/dev/nvme0n1': {'size': 2000409264, 'model': 'SAMSUNG MZVLB1T0HBLR-000L2'}}

system_query.query_ram()

To be able to see amount of memory, install Python package psutil.

In [6]: system_query.query_ram()
Out[6]: {'total': 16631603200}

When given an optional argument sudo, more information will be shown.

In [7]: system_query.query_ram(sudo=True)
[sudo] password for user: ...
Out[7]:
{'total': 16632750080,
 'banks': [{'memory': 8589934592, 'clock': 2667000000},
  {'memory': 8589934592, 'clock': 2667000000}]}

system_query.query_software()

This will attempt to gather version information of various common programs, assuming their executables are in system path.

In [8]: system_query.query_software()
Out[8]:
{'gcc': {'path': '/usr/bin/gcc',
  'version': 'gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0'},
 'g++': {'path': '/usr/bin/g++',
  'version': 'g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0'},
 'gfortran': {'path': '/usr/bin/gfortran',
  'version': 'GNU Fortran (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0'},
 'clang': {'path': '/usr/bin/clang',
  'version': 'Ubuntu clang version 14.0.0-1ubuntu1.1'},
 'clang++': {'path': '/usr/bin/clang++',
  'version': 'Ubuntu clang version 14.0.0-1ubuntu1.1'},
 'python': {'path': '/home/user/Software/Spack/opt/spack/linux-ubuntu22.04-skylake/gcc-12.3.0/python-3.11.6-pkgqipsrm2re32eisko6o7xa2xnwwzyh/bin/python',
  'version': 'Python 3.11.6',
  'packages': {'ipython': {'version': 'ipython==8.26.0'},
   'numpy': {'version': 'numpy @ file:///tmp/user/spack-stage/spack-stage-py-numpy-1.26.2-bpjavwbbxmsgiutvjzijlkjf5si5ki2v/spack-src'},
   'pandas': {'version': 'pandas==1.5.3'},
   'pycuda': {'version': 'pycuda==2024.1'},
   'scipy': {'version': 'scipy==1.13.0'}}},
 'python3': {'path': '/home/user/Software/Spack/opt/spack/linux-ubuntu22.04-skylake/gcc-12.3.0/python-3.11.6-pkgqipsrm2re32eisko6o7xa2xnwwzyh/bin/python3',
  'version': 'Python 3.11.6',
  'packages': {'ipython': {'version': 'ipython==8.26.0'},
   'numpy': {'version': 'numpy @ file:///tmp/user/spack-stage/spack-stage-py-numpy-1.26.2-bpjavwbbxmsgiutvjzijlkjf5si5ki2v/spack-src'},
   'pandas': {'version': 'pandas==1.5.3'},
   'pycuda': {'version': 'pycuda==2024.1'},
   'scipy': {'version': 'scipy==1.13.0'}}},
 'python3.10': {'path': '/usr/bin/python3.10',
  'version': 'Python 3.10.12',
  'packages': {}},
 'python3.11': {'path': '/home/user/Software/Spack/opt/spack/linux-ubuntu22.04-skylake/gcc-12.3.0/python-3.11.6-pkgqipsrm2re32eisko6o7xa2xnwwzyh/bin/python3.11',
  'version': 'Python 3.11.6',
  'packages': {'ipython': {'version': 'ipython==8.26.0'},
   'numpy': {'version': 'numpy @ file:///tmp/user/spack-stage/spack-stage-py-numpy-1.26.2-bpjavwbbxmsgiutvjzijlkjf5si5ki2v/spack-src'},
   'pandas': {'version': 'pandas==1.5.3'},
   'pycuda': {'version': 'pycuda==2024.1'},
   'scipy': {'version': 'scipy==1.13.0'}}},
 'pip': {'path': '/home/user/Software/Spack/opt/spack/linux-ubuntu22.04-skylake/gcc-12.3.0/python-3.11.6-pkgqipsrm2re32eisko6o7xa2xnwwzyh/bin/pip',
  'version': 'pip 24.2 from /home/user/Software/Spack/opt/spack/linux-ubuntu22.04-skylake/gcc-12.3.0/python-3.11.6-pkgqipsrm2re32eisko6o7xa2xnwwzyh/lib/python3.11/site-packages/pip (python 3.11)'},
 'pip3': {'path': '/home/user/Software/Spack/opt/spack/linux-ubuntu22.04-skylake/gcc-12.3.0/python-3.11.6-pkgqipsrm2re32eisko6o7xa2xnwwzyh/bin/pip3',
  'version': 'pip 24.2 from /home/user/Software/Spack/opt/spack/linux-ubuntu22.04-skylake/gcc-12.3.0/python-3.11.6-pkgqipsrm2re32eisko6o7xa2xnwwzyh/lib/python3.11/site-packages/pip (python 3.11)'},
 'pip3.11': {'path': '/home/user/Software/Spack/opt/spack/linux-ubuntu22.04-skylake/gcc-12.3.0/python-3.11.6-pkgqipsrm2re32eisko6o7xa2xnwwzyh/bin/pip3.11',
  'version': 'pip 24.2 from /home/user/Software/Spack/opt/spack/linux-ubuntu22.04-skylake/gcc-12.3.0/python-3.11.6-pkgqipsrm2re32eisko6o7xa2xnwwzyh/lib/python3.11/site-packages/pip (python 3.11)'},
 'java': {'path': '/usr/lib/jvm/java-11-openjdk-amd64/bin/java',
  'version': 'openjdk version "11.0.24" 2024-07-16'},
 'ruby': {'path': '/usr/bin/ruby',
  'version': 'ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux-gnu]'},
 'nvcc': {'path': '/usr/bin/nvcc',
  'version': 'nvcc: NVIDIA (R) Cuda compiler driver'},
 'spack': {'path': '/home/user/Software/Scripts/spack', 'version': None}}

system_query.query_swap()

To be able to see amount of swap space, install Python package psutil.

In [9]: system_query.query_swap()
Out[9]: {'total': 17179865088}

system_query.query_and_export()

This function is for convenience of running the query and outputting the results in a designated format, to a designated location.

In [10]: import pathlib
In [11]: system_query.query_and_export('all', 'json', pathlib.Path('/tmp/system_info.json'))

As command-line tool

Below will run system_query.query_all() and output results to stdout:

$ python3 -m system_query
{'cpu': {'brand': 'Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz',
         'cache': {1: 196608, 2: 1572864, 3: 12582912},
         'clock': 3685.686166666667,
         'clock_max': 4500.0,
         'clock_min': 800.0,
         'logical_cores': 12,
         'physical_cores': 6},
 'gpus': [{'brand': 'NVIDIA GeForce RTX 2060',
           'clock': 1200000,
           'compute_capability': 7.5,
           'cores': None,
           'memory': 6214516736,
           'memory_clock': 7001000,
           'multiprocessors': 30,
           'warp_size': 32}],
 'hdds': {'/dev/nvme0n1': {'model': 'SAMSUNG MZVLB1T0HBLR-000L2',
                           'size': 2000409264},
          '/dev/sda': {'model': 'WDC WD10SPZX-24Z', 'size': 1953525168},
          '/dev/sdb': {'model': '1081C', 'size': 0},
          '/dev/sdc': {'model': '1081C', 'size': 0}},
 'host': 'mbLegion',
 'os': 'Linux-6.8.0-47-generic-x86_64-with-glibc2.35',
 'ram': {'total': 16631603200},
 'swap': {'total': 17179865088}}

Please use -h to see usage information:

$ python3 -m system_query -h
usage: system_query [-h] [-s {all,cpu,gpu,ram,swap}] [-f {raw,json}]
                    [-t TARGET] [--version]

Comprehensive and concise system information tool. Query a given hardware
and/or software scope of your system and get results in human- and machine-
readable formats.

options:
  -h, --help            show this help message and exit
  -s {all,cpu,gpu,ram,swap}, --scope {all,cpu,gpu,ram,swap}
                        Scope of the query (default: all)
  -f {raw,json}, --format {raw,json}
                        Format of the results of the query. (default: raw)
  -t TARGET, --target TARGET
                        File path where to write the results of the query.
                        Special values: "stdout" and "stderr" to write to
                        stdout and stderr, respectively. (default: stdout)
  --version             show program's version number and exit

Copyright 2017-2025 by the contributors, Apache License 2.0,
https://github.com/mbdevpl/system-query

Requirements

Python version 3.11 or later.

Python libraries as specified in requirements.txt. Recommended (but optional) packages are listed in requirements_optional.txt.

Building and running tests additionally requires packages listed in requirements_test.txt.

Tested on Linux, macOS and Windows.

Additionally, for all features to work you should have the following libraries installed in your system:

  • CUDA

  • libudev

Contributors

Aleksandr Drozd

Emil Vatai

Mateusz Bysiek

For licensing information, please see LICENSE and NOTICE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

system_query-0.4.2.tar.gz (25.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

system_query-0.4.2-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

Details for the file system_query-0.4.2.tar.gz.

File metadata

  • Download URL: system_query-0.4.2.tar.gz
  • Upload date:
  • Size: 25.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for system_query-0.4.2.tar.gz
Algorithm Hash digest
SHA256 119647248e36283ec1f8f9fc868750746e787562eb8bbba1e2046bc7bf26dfb5
MD5 ceef0a237001b909d700d77bec609591
BLAKE2b-256 7cc6a7dfcd2fe03fd2377d418a7f62b6729c24468bfefeb781196844662f29f6

See more details on using hashes here.

File details

Details for the file system_query-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: system_query-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 21.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for system_query-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 08dd456b8b0ec6f526f2f32285235b20b6f58223b434a139cd8c5e6073f146da
MD5 5f4a814e46432e7347308af18cd51101
BLAKE2b-256 f450241561942716ee92bdfdff458de4c7e0451c8c74a67fb322e76eb932ac01

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page