Mj0 d dl Z d dlZd dlZd dlZd dlmZmZ d dlmZmZm Z m
Z
mZmZm
Z
mZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d Zed
z ZdZ e Z ej d Z G d
de Z!d!dZ"d Z#d Z$d Z%d Z&d Z'd Z(d Z)d Z*d Z+d"dZ,d Z-d Z.d Z/ej0 defd Z1dS )# N)datetime timedelta)
ColumnBooleanDateTimeIndexIntegerString
create_engineeventfunctext)declarative_base) Inspector)Session)close_all_sessions)
DatabaseErrorz/var/lve/ssa.dbz.old cleanup_old_datac e Zd ZdZdZ eddd fZ eed Z ee
d Z ee
d Z eed Z
eed Z eed Z eed Z eed Z eed Z eed Z e ed
ej d Z e ed
ej ej Zd
S )
RequestResultay
Describes processed request stored in database file.
E.g.
{
"timestamp": "1650008727",
"url": "http://mydomain.com/index.php",
"duration": 162077,
"hitting_limits": false,
"throttled_time": 0,
"io_throttled_time": 0,
"wordpress": true
}
Note: created_at, updated_at is saved in local TZ format
scrape_resultix_scrape_result_domain_pathdomainpathT)primary_keyF)nullable)timezone)server_defaultindex)onupdater N)__name__
__module____qualname____doc__
__tablename__r __table_args__r r idr
r r timestampdurationr is_slow_requesthitting_limitsthrottled_timeio_throttled_time wordpressr r
now
created_at
updated_at =/opt/cloudlinux/venv/lib64/python3.11/site-packages/ssa/db.pyr r sg " $M e:HfMMON T * * *B
VFU
+
+
+F6&5)))Dw///Ivg...HfWu555OVGe444NVGe444Nw777w///I $///
RVWWWJ$///($(**U]UYU]U_U_```JJJr4 r ' c t j t t z
}d} t | 5 }| t
d ||d }|j }||z
}|dk r
ddd n ddd n# 1 swxY w Y nt d| t | dS )a
Removes outdated records from database, saving disk space.
Deletions are batched to avoid loading the entire database into
the cgroup's page cache, which causes OOM on large databases.
Runs VACUUM after deletion to reclaim disk space.
)daysr TzrDELETE FROM scrape_result WHERE rowid IN (SELECT rowid FROM scrape_result WHERE created_at < :cutoff LIMIT :batch))cutoffbatchNzCleanup deleted %d old records)r todayr RETENTION_TIME_DAYS
session_scopeexecuter rowcountloggerinfovacuum_database)engine
batch_size
n_days_ago
total_deletedsessionresultdeleteds r5 r r S s6 !!I3F$G$G$GGJM
6
"
" g__` &
;; F oGW$M!|| KK0-@@@Fs :BBBc j t j t j t }t j |t j r6| d| d t d| dS t
d|| dS )u
Point SQLite's temp store at the database directory (on disk) for the
given operation. SQLite spills large sorts / temp B-trees and VACUUM
copies to the system temp directory, which can be tmpfs (RAM-backed).
When it is, the spill is charged against the MemoryMax=1G cgroup and
OOM-kills the agent on large databases — the same hazard for VACUUM
and for index builds / ORDER BY sorts (CLPRO-2819, CLPRO-3077).
PRAGMA temp_store_directory = ''z&Set SQLite temp_store_directory to: %szJDirectory %s not writable. %s will fall back to the default temp location.N)osr dirnameabspathSSA_DBaccessW_OKr> r@ rA warning)cursor operationdb_dirs r5 _redirect_temp_store_to_diskrW m s W__RW__V44
5
5F y!! xBBBBCCC