mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fixes #9718 This PR adds POE graphs, even if not all the values that are polled on other OSes are available on this one. DO NOT DELETE THIS TEXT #### Please note > Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting. - [X] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/) #### Testers If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 10075` After you are done testing, you can remove the changes with `./scripts/github-remove`. If there are schema changes, you can ask on discord how to revert.
83 lines
3.9 KiB
PHP
83 lines
3.9 KiB
PHP
<?php
|
|
|
|
use LibreNMS\RRD\RrdDefinition;
|
|
|
|
$rrd_name = getPortRrdName($port_id, 'poe');
|
|
$rrd_def = RrdDefinition::make()
|
|
->addDataset('PortPwrAllocated', 'GAUGE', 0)
|
|
->addDataset('PortPwrAvailable', 'GAUGE', 0)
|
|
->addDataset('PortConsumption', 'GAUGE', 0)
|
|
->addDataset('PortMaxPwrDrawn', 'GAUGE', 0);
|
|
|
|
if (($device['os'] == 'vrp')) {
|
|
//Tested against Huawei 5720 access switches
|
|
if (isset($this_port['hwPoePortEnable'])) {
|
|
$upd = "$polled:".$this_port['hwPoePortReferencePower'].':'.$this_port['hwPoePortMaximumPower'].':'.$this_port['hwPoePortConsumingPower'].':'.$this_port['hwPoePortPeakPower'];
|
|
|
|
$fields = array(
|
|
'PortPwrAllocated' => $this_port['hwPoePortReferencePower'],
|
|
'PortPwrAvailable' => $this_port['hwPoePortMaximumPower'],
|
|
'PortConsumption' => $this_port['hwPoePortConsumingPower'],
|
|
'PortMaxPwrDrawn' => $this_port['hwPoePortPeakPower'],
|
|
);
|
|
|
|
$tags = compact('ifName', 'rrd_name', 'rrd_def');
|
|
data_update($device, 'poe', $tags, $fields);
|
|
echo 'PoE(vrp) ';
|
|
}
|
|
} elseif (($device['os'] == 'linksys-ss')) {
|
|
//Tested 318P
|
|
if (isset($this_port['pethPsePortAdminEnable'])) {
|
|
$upd = "$polled:".$this_port['rlPethPsePortPowerLimit'].':'.$this_port['rlPethPsePortOutputPower'];
|
|
|
|
$fields = array(
|
|
'PortPwrAllocated' => $this_port['rlPethPsePortPowerLimit'],
|
|
'PortPwrAvailable' => $this_port['rlPethPsePortPowerLimit'],
|
|
'PortConsumption' => $this_port['rlPethPsePortOutputPower'],
|
|
'PortMaxPwrDrawn' => $this_port['rlPethPsePortPowerLimit'],
|
|
);
|
|
|
|
$tags = compact('ifName', 'rrd_name', 'rrd_def');
|
|
data_update($device, 'poe', $tags, $fields);
|
|
echo 'PoE(linksys) ';
|
|
}
|
|
} elseif (($device['os'] == 'ios') || ($device['os'] == 'iosxe')) {
|
|
// Code for Cisco IOS and IOSXE, tested on 2960X
|
|
if (isset($this_port['cpeExtPsePortPwrAllocated'])) {
|
|
// if we have cpeExtPsePortPwrAllocated, we have the complete array so we can populate the RRD
|
|
$upd = "$polled:".$port['cpeExtPsePortPwrAllocated'].':'.$port['cpeExtPsePortPwrAvailable'].':'.
|
|
$port['cpeExtPsePortPwrConsumption'].':'.$port['cpeExtPsePortMaxPwrDrawn'];
|
|
echo "$this_port[cpeExtPsePortPwrAllocated],$this_port[cpeExtPsePortPwrAvailable],$this_port[cpeExtPsePortPwrConsumption],$this_port[cpeExtPsePortMaxPwrDrawn]\n";
|
|
$fields = array(
|
|
'PortPwrAllocated' => $this_port['cpeExtPsePortPwrAllocated'],
|
|
'PortPwrAvailable' => $this_port['cpeExtPsePortPwrAvailable'],
|
|
'PortConsumption' => $this_port['cpeExtPsePortPwrConsumption'],
|
|
'PortMaxPwrDrawn' => $this_port['cpeExtPsePortMaxPwrDrawn'],
|
|
);
|
|
|
|
$tags = compact('ifName', 'rrd_name', 'rrd_def');
|
|
data_update($device, 'poe', $tags, $fields);
|
|
echo 'PoE(IOS) ';
|
|
}//end if
|
|
} else {
|
|
//This is the legacy code, to be tested against devices. This code looks terribly broken. There is
|
|
//most probably no device that can show anything out of this ...
|
|
|
|
if ($this_port['dot3StatsIndex'] && $port['ifType'] == 'ethernetCsmacd') {
|
|
$upd = "$polled:".$port['cpeExtPsePortPwrAllocated'].':'.$port['cpeExtPsePortPwrAvailable'].':'.
|
|
$port['cpeExtPsePortPwrConsumption'].':'.$port['cpeExtPsePortMaxPwrDrawn'];
|
|
|
|
$fields = array(
|
|
'PortPwrAllocated' => $port['cpeExtPsePortPwrAllocated'],
|
|
'PortPwrAvailable' => $port['cpeExtPsePortPwrAvailable'],
|
|
'PortConsumption' => $port['cpeExtPsePortPwrConsumption'],
|
|
'PortMaxPwrDrawn' => $port['cpeExtPsePortMaxPwrDrawn'],
|
|
);
|
|
|
|
$tags = compact('ifName', 'rrd_name', 'rrd_def');
|
|
data_update($device, 'poe', $tags, $fields);
|
|
|
|
echo 'PoE(generic) ';
|
|
}//end if
|
|
}
|