|
Server : Apache System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64 User : njnconst ( 1116) PHP Version : 8.4.18 Disable Function : NONE Directory : /opt/alt/python37/lib/python3.7/site-packages/lvestats/lib/__pycache__/ |
Upload File : |
B
a��b� � @ s� d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlm Z m
Z
d dlmZ d dl
Z
d dlmZ dZdZee�ZG dd � d e�Zed
d� �ZdS )� )�absolute_importN)�Optional�List)�contextmanager)�mapz/var/lve/snapshotsz .snapshotc @ s� e Zd ZdZd$dd�Zdd� Zedd� �Zd d
� Zdd� Z d
d� Z
dd� Zdd� Zdd� Z
dd� Zdd� Zdd� Zdd� Zedd� �Zed%d d!��Zed"d#� �ZdS )&�Snapshotad
This class is 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/snaphosts/[uid] and the dump files itself will be owned by user
They will not be readable by other users.
� c C s || _ || _t�d�| _d S )Nzlib-snapshot)�
compresslevel�incident�loggingZ getLogger�log)�selfr
r � r �F/opt/alt/python37/lib/python3.7/site-packages/lvestats/lib/snapshot.py�__init__! s zSnapshot.__init__c C sn |d }|d k st �| �|� t�t�|��� | j�}| �|��"}|� |� | j
�d|j � W d Q R X |jS )NZ dump_timezSnapshot dumped to file %s)
�AssertionError�_replace_unicode_data�zlib�compress�json�dumps�encoder �create_file�writer �debug�name)r
�data� dump_dateZjson_compressed�fr r r �save'