| 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 */ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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 |  |  |  | 
            
                        
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.