| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- namespace ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Graph\Pages;
- 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 BaseSmallGraph extends Line implements ClientArea, AdminArea
- {
- protected $tableRowCol = 'lu-col-md-3';
- protected $graphSettingsEnabled = false;
- protected $graphHeight = 70;
- protected $graphWidth = 200;
- protected $showTitle = false;
- protected $title = '';
- protected $legend = [
- 'display' => false,
- 'position' => 'top'
- ];
- protected $timeframe = "day";
- protected $displayScaleLabel = true;
- protected function rrdDataQuery(){
- $hi = (int) $this->getWhmcsParamByKey('serviceid');
- $now = new \DateTime();
- $now->modify('-1 hours');
- $since = $now->format("Y-m-d H:i:s");
- $vmId = (int) \ModulesGarden\ProxmoxAddon\Core\Helper\sl('Vm')->getVmModel()->id;
- //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 vm_id ={$vmId} AND `time` >= '{$since}'
- ) as x GROUP BY date ORDER BY `date` ASC");
- }
- }
|