Atoparser is a zero dependency Atop log processing library written in Python. The library supports reading binary C data directly from compressed or uncompressed Atop log files, without the need to install Atop or call a subprocess. The converted data contains structured Python objects, that can then be used for JSON, CSV, or other types of output, storage, and analysis.
For full information on the amazing performance monitoring software that creates these files, known as "Atop", refer to:
Atop - The one stop shop for all your tops
- Supports Python 3.10+
- Supports Atop 1.26 and 2.3 through 2.11.
Install Atoparser via pip:
pip install atoparser
Or via git clone:
git clone <path to fork>
cd atoparser
pip install .
Or build and install from wheel:
# Build locally.
git clone <path to fork>
cd atoparser
make wheel
# Push dist/atoparser*.tar.gz to environment where it will be installed.
pip install dist/atoparser*.tar.gz
atoparser ~/atop.log -P CPU --pretty
import atoparser
with open(file, 'rb') as raw_file:
header = atoparser.get_header(raw_file)
for record, sstat, tstats, cgroups in atoparser.generate_statistics(raw_file, header):
total_cycles = record.interval * sstat.cpu.nrcpu * header.hertz
usage = 1 - sstat.cpu.all.itime / total_cycles
print(f'CPU usage was {usage:.02%}')
import json
import atoparser
with open(file, 'rb') as raw_file:
header = atoparser.get_header(raw_file)
print(json.dumps(atoparser.struct_to_dict(header), indent=2))
Refer to the Contributing Guide for information on how to contribute to this project.
Refer to Advanced How Tos for more advanced topics, such as adding a new Atop version.