| 123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- namespace ModulesGarden\Servers\ProxmoxCloudVps\App\UI\ServiceGraph\Pages;
- use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ProductService;
- use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Interfaces\AdminArea;
- use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Interfaces\ClientArea;
- use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Graphs\Line;
- use Illuminate\Database\Capsule\Manager as DB;
- class BaseGraph extends Line implements ClientArea, AdminArea
- {
- use ProductService;
- protected $graphSettingsEnabled = false;
- protected $graphHeight = 70;
- protected $graphWidth = 200;
- protected $showTitle = false;
- protected $title = '';
- protected $legend = [
- 'display' => false,
- 'position' => 'top'
- ];
- protected function rrdDataQuery(){
- $hi = (int) $this->getWhmcsParamByKey('serviceid');
- $now = new \DateTime();
- $now->modify('-1 hours');
- $since = $now->format("Y-m-d H:i:s");
- //Query
- return DB::select("SELECT AVG(diskread) AS diskread, AVG(diskwrite) AS diskwrite, AVG(cpu) AS cpu, AVG(maxcpu) AS maxcpu , AVG(mem) AS mem, AVG(maxmem) AS maxmem, AVG(netin) AS netin, AVG(netout) AS netout, `date` FROM (SELECT id, hosting_id, vm_id, (diskread), (diskwrite), (cpu), (maxcpu), (mem), (maxmem), (netin), (netout), DATE_FORMAT(FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(time) / 300) * 300), '%Y-%m-%d %H:%i') as `date` FROM `ProxmoxAddon_RrdData`
- WHERE hosting_id = {$hi} AND `time` >= '{$since}'
- ) as x GROUP BY date ORDER BY `date` ASC");
- }
- }
|