Test Failed
Push — develop ( 55b248...7d9761 )
by Tony
21:25
created

Processor::getRRDGraphDefinition()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Processor.php
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 *
18
 * @package    LibreNMS
19
 * @link       http://librenms.org
20
 * @copyright  2016 Neil Lathwood
21
 * @author     Neil Lathwood <[email protected]>
22
 */
23
24
namespace App\Graphs\Device;
25
26
use App\Data\RRD;
27
use App\Graphs\Graph;
28
use Illuminate\Database\Query\Builder;
29
30
class Processor extends Graph
31
{
32
    protected function getRelation()
33
    {
34
        if ($this->hasIDs()) {
35
            return [
36
                'processors' => function (Builder $query) {
37
                    $query->whereIn('processor_id', $this->getIDs());
38
                },
39
            ];
40
        }
41
42
        return 'processors';
43
    }
44
45
    protected function getData()
46
    {
47
        return $this->device->processors;
48
    }
49
50
    protected function getHeaders()
51
    {
52
        $headers = [];
53
        foreach ($this->getData() as $proc) {
54
            $headers[] = $proc->getFormattedDescription();
55
        }
56
        return $headers;
57
    }
58
59
    protected function getRRDGraphDefinition()
60
    {
61
        // TODO: Implement getRRDGraphDefinition() method.
62
    }
63
64
    protected function getRRDXportDefinition()
65
    {
66
        $defs = '';
67
        foreach ($this->getData() as $proc) {
68
            /** @var /App/Models/Processor $proc */
0 ignored issues
show
Documentation introduced by
The doc-type /App/Models/Processor could not be parsed: Unknown type name "/App/Models/Processor" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
69
            $id = $proc->hrDeviceIndex;
70
            $rrd_file = RRD::getFileName($this->device, array('processor', 'hr', $id));
71
            $defs .= "DEF:ds$id=$rrd_file:usage:AVERAGE \
72
                XPORT:ds$id:'".$proc->getFormattedDescription()."' ";
73
        }
74
        return $defs;
75
    }
76
}
77