,IVsa d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dl m Z d dlmZ dZ dZ ee Z G d d Ze d efd ZdS ) N)Iterator)contextmanager)BinaryIOz/var/lve/snapshotsz .snapshotc e Zd ZdZd dededdfdZdedefd Ze d Z deddfdZdee fdZ d edz dedz dee fdZd edz dedz dee fdZdedefdZdefdZdefdZdedefdZdedefdZdeddfdZe dededz fd Ze d!dee d edz dedz dee fd Ze dedefd ZdS )"Snapshotaj Class responsible for loading and saving snapshot files for the interval. The files will be saved in a format of: `/var/lve/snapshots/[uid]/dump_time.snapshot` dump_time is the timestamp/integer. The directories `/var/lve/snapshots/[uid]` and the dump files themselves will be owned by user. They will not be readable by other users. incident compresslevelreturnNc T || _ || _ t j d | _ d S )Nzlib-snapshot)r r logging getLoggerlog)selfr r s /builddir/build/BUILDROOT/lve-stats-4.3.2-1.el9.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/lvestats/lib/snapshot.py__init__zSnapshot.__init__# s' * $^44 datac |d }|J | | t j t j | | j }| | 5 }| | | j d|j d d d n# 1 swxY w Y |j S )N dump_timezSnapshot dumped to file %s)_replace_unicode_datazlibcompressjsondumpsencoder create_filewriter debugname)r r dump_datejson_compressedfs r savez Snapshot.save( s % $$$ ""4(((- 4(8(8(?(?(A(A4CUVV i ( ( AA GGO$$$HNN7@@@ A A A A A A A A A A A A A A A v s 56B77B;>B;c \ t | t r| dd S | S )Nzutf-8replace) isinstancebytesdecode)objs r _to_unicodezSnapshot._to_unicode4 s- c5!! 2::gy111 r c Z g }| dg D ]7}| t t | j | 8||d<