✘✘ GRAYBYTE WORDPRESS FILE MANAGER ✘✘

​🇳​​🇦​​🇲​​🇪♯➤ premium290.web-hosting.com ​🇻​♯➤ 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP 🇾​♯➤ 2025

𝗛𝗢𝗠𝗘 𝗜𝗗 ♯➤ 63.250.38.37 ♯➤ 𝗔𝗗𝗠𝗜𝗡 𝗜𝗗 216.73.216.104
𝗢𝗣𝗧𝗜𝗢𝗡𝗦 ♯ CRL ♯➤ 𝗢𝗞 ┃ WGT ♯➤ 𝗢𝗞 ┃ SDO ♯➤ 𝗢𝗙𝗙 ┃ PKEX ♯➤ 𝗢𝗙𝗙
𝗗𝗘𝗔𝗖𝗧𝗜𝗩𝗔𝗧𝗘𝗗 ♯➤ 𝗔𝗟𝗟 𝗪𝗢𝗥𝗞𝗜𝗡𝗚....

𝗛𝗢𝗠𝗘
𝗖𝗨𝗥𝗥𝗘𝗡𝗧 𝗙𝗜𝗟𝗘 : /opt/cloudlinux/venv/lib/python3.11/site-packages/ssa/modules//storage.py
# -*- coding: utf-8 -*-

# Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2021 All Rights Reserved
#
# Licensed under CLOUD LINUX LICENSE AGREEMENT
# http://cloudlinux.com/docs/LICENSE.TXT
"""
Represents storage where ssa data is collected, stored and extracted
"""
import itertools
from dataclasses import dataclass
from typing import List, Iterator, Tuple, Dict

import sqlalchemy
from sqlalchemy import func, cast, distinct

from ssa.db import session_scope, RequestResult


@dataclass
class DomainData:
    domain_name: str
    domain_total_reqs: List[int]
    is_a_wordpress_domain: bool
    urls_number: int


def iter_domains_data(engine) -> Iterator[DomainData]:
    """
    Iterates data from database domain-by-domain.
    """
    with session_scope(engine) as db:
        results_by_hour = db.query(
            RequestResult.domain,
            func.strftime('%H', RequestResult.created_at),
            func.Count(RequestResult.id),
            func.max(RequestResult.wordpress),
            func.count(distinct(RequestResult.path))
        ).group_by(
            RequestResult.domain,
            func.strftime('%H', RequestResult.created_at)
        ).order_by(
            RequestResult.domain,
            func.strftime('%H', RequestResult.created_at)
        )

        results_by_hour_grouped = itertools.groupby(results_by_hour, key=lambda item: item[0])

        for domain_name, group in results_by_hour_grouped:
            domain_results_by_hour = tuple(group)

            urls_number = 0
            # at some hours there may be no requests
            # so we must normalize data to match 24h data format
            requests_number_by_hour = [0] * 24
            for _, hour, requests_num, is_wordpress, urls in domain_results_by_hour:
                requests_number_by_hour[int(hour)] = requests_num
                urls_number = max(urls_number, urls)

            yield DomainData(
                domain_name=domain_name,
                domain_total_reqs=requests_number_by_hour,
                is_a_wordpress_domain=is_wordpress,
                urls_number=urls_number
            )

def iter_urls_data(engine, domain_name, all_paths):
    """
    Iterates urls data from database url-by-url.
    """
    with session_scope(engine) as db:
        urls_data = db.query(
            RequestResult.path,
            func.strftime('%H', RequestResult.created_at),
            func.Sum(cast(
                RequestResult.hitting_limits, sqlalchemy.Integer
            )).label('url_throttled_reqs'),
            func.Count(
                RequestResult.id
            ).label('url_total_reqs'),
            func.Sum(cast(
                RequestResult.is_slow_request, sqlalchemy.Integer)
            ).label('url_slow_reqs')
        ).filter(
            RequestResult.domain == domain_name
        ).filter(
            RequestResult.path.in_(all_paths)
        ).group_by(
            RequestResult.path, func.strftime('%H', RequestResult.created_at)
        ).order_by(
            RequestResult.path, func.strftime('%H', RequestResult.created_at)
        )

        previous_path = None
        url_throttled_reqs, url_total_reqs, url_slow_reqs = \
            [0] * 24, [0] * 24, [0] * 24

        for path, hour, url_throttled_req, url_total_req, url_slow_req in urls_data:
            if previous_path and previous_path != path:
                yield previous_path, dict(
                    path=previous_path,
                    url_throttled_reqs=url_throttled_reqs,
                    url_total_reqs=url_total_reqs,
                    url_slow_reqs=url_slow_reqs
                )
                url_throttled_reqs, url_total_reqs, url_slow_reqs = \
                    [0] * 24, [0] * 24, [0] * 24

            url_throttled_reqs[int(hour)] = url_throttled_req
            url_total_reqs[int(hour)] = url_total_req
            url_slow_reqs[int(hour)] = url_slow_req

            previous_path = path

        yield path, dict(
            path=path,
            url_throttled_reqs=url_throttled_reqs,
            url_total_reqs=url_total_reqs,
            url_slow_reqs=url_slow_reqs
        )


def get_url_durations(engine, domain_name) -> Dict[str, Tuple[int]]:
    """
    Get information about durations of requests url-by-url.
    """
    with session_scope(engine) as db:
        urls_data = db.query(
            RequestResult.path,
            RequestResult.duration
        ).filter(
            RequestResult.domain == domain_name
        ).order_by(
            RequestResult.path
        )

        # Use iterator directly to avoid loading all data into RAM
        durations_by_path = itertools.groupby(
            urls_data, lambda item: item[0])
        for key, group in durations_by_path:
            yield key, [duration for _, duration in group]


def iter_domain_url_data(engine, domain_name):
    """
    Stream per-URL data for a single domain.

    Yields ``(path, durations, url_data)`` per path, where:
    - ``path`` is the URL path (str);
    - ``durations`` is a list of raw request durations for that path;
    - ``url_data`` is a dict with per-hour aggregates
      (``url_throttled_reqs``, ``url_total_reqs``, ``url_slow_reqs``
      as 24-element lists) plus ``path``.

    Merges two ``ORDER BY path`` streams in lock-step instead of
    materialising the per-domain ``{path: [durations...]}`` dict up
    front, which caused OOM on large databases (CLPRO-3077). A second
    benefit: this drops the redundant ``WHERE path IN (...)`` clause —
    both queries already filter by ``domain``, so the path list adds
    no selectivity, only memory pressure on the SQL parser.
    """
    with session_scope(engine) as db:
        agg_query = db.query(
            RequestResult.path,
            func.strftime('%H', RequestResult.created_at),
            func.Sum(cast(
                RequestResult.hitting_limits, sqlalchemy.Integer
            )).label('url_throttled_reqs'),
            func.Count(
                RequestResult.id
            ).label('url_total_reqs'),
            func.Sum(cast(
                RequestResult.is_slow_request, sqlalchemy.Integer)
            ).label('url_slow_reqs')
        ).filter(
            RequestResult.domain == domain_name
        ).group_by(
            RequestResult.path,
            func.strftime('%H', RequestResult.created_at)
        ).order_by(
            RequestResult.path,
            func.strftime('%H', RequestResult.created_at)
        )

        dur_query = db.query(
            RequestResult.path,
            RequestResult.duration
        ).filter(
            RequestResult.domain == domain_name
        ).order_by(
            RequestResult.path
        )

        agg_by_path = itertools.groupby(agg_query, key=lambda r: r[0])
        dur_by_path = itertools.groupby(dur_query, key=lambda r: r[0])

        agg_item = next(agg_by_path, None)
        dur_item = next(dur_by_path, None)

        while agg_item is not None and dur_item is not None:
            agg_path, agg_group = agg_item
            dur_path, dur_group = dur_item

            if agg_path == dur_path:
                url_throttled_reqs = [0] * 24
                url_total_reqs = [0] * 24
                url_slow_reqs = [0] * 24
                for _, hour, throttled, total, slow in agg_group:
                    url_throttled_reqs[int(hour)] = throttled
                    url_total_reqs[int(hour)] = total
                    url_slow_reqs[int(hour)] = slow

                durations = [d for _, d in dur_group]

                yield agg_path, durations, dict(
                    path=agg_path,
                    url_throttled_reqs=url_throttled_reqs,
                    url_total_reqs=url_total_reqs,
                    url_slow_reqs=url_slow_reqs,
                )

                agg_item = next(agg_by_path, None)
                dur_item = next(dur_by_path, None)
            elif agg_path < dur_path:
                # Defensive: both queries scan the same WHERE filter, so
                # path sets should match. If they ever diverge (concurrent
                # write between the two queries, indexed collation
                # mismatch, …), skip the unmatched side rather than crash.
                agg_item = next(agg_by_path, None)
            else:
                dur_item = next(dur_by_path, None)


Current_dir [ 𝗡𝗢𝗧 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ] Document_root [ 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ]


[ Back ]
𝗡𝗔𝗠𝗘
𝗦𝗜𝗭𝗘
𝗟𝗔𝗦𝗧 𝗧𝗢𝗨𝗖𝗛
𝗨𝗦𝗘𝗥
𝗦𝗧𝗔𝗧𝗨𝗦
𝗙𝗨𝗡𝗖𝗧𝗜𝗢𝗡𝗦
..
--
8 Jul 2026 7.00 AM
root / root
0755
__pycache__
--
8 Jul 2026 7.02 AM
root / root
0755
__init__.py
0 KB
25 Jun 2026 12.49 PM
root / root
0644
autotracer.py
20.747 KB
25 Jun 2026 12.49 PM
root / root
0644
common.py
1.97 KB
25 Jun 2026 12.49 PM
root / root
0644
decision_maker.py
9.963 KB
25 Jun 2026 12.49 PM
root / root
0644
processor.py
10.473 KB
25 Jun 2026 12.49 PM
root / root
0644
stat_sender.py
7.904 KB
25 Jun 2026 12.49 PM
root / root
0644
storage.py
8.182 KB
25 Jun 2026 12.49 PM
root / root
0644

✘✘ GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME ✘✘
Static GIF Static GIF