Skip to content

Commit b246b83

Browse files
Cameron-84laf
andauthored
Added processors and memory for Viptela (librenms#16983)
* Viptela vendor - Processor and Memory fix * Added test data and tidied up the yaml files * CI fix and function removal * Viptela - Processor and Memory fix * Removed usage of getHardware * Updated vedge1000 --------- Co-authored-by: Neil Lathwood <gh+n@laf.io>
1 parent 6321b34 commit b246b83

23 files changed

+42250
-26
lines changed

LibreNMS/OS/Viptela.php

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,34 +26,56 @@
2626
namespace LibreNMS\OS;
2727

2828
use App\Models\Device;
29+
use LibreNMS\Device\Processor;
30+
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
31+
use LibreNMS\Interfaces\Polling\ProcessorPolling;
32+
use LibreNMS\OS;
2933

30-
class Viptela extends \LibreNMS\OS
34+
class Viptela extends OS implements ProcessorDiscovery, ProcessorPolling
3135
{
36+
private string $procOid = '.1.3.6.1.4.1.41916.11.1.16.0';
37+
3238
public function discoverOS(Device $device): void
3339
{
3440
parent::discoverOS($device); // yaml
35-
$device->hardware = $this->getHardware($device->hardware);
3641
}
3742

38-
private function getHardware($id)
43+
/**
44+
* Discover processors.
45+
* Returns an array of LibreNMS\Device\Processor objects that have been discovered
46+
*
47+
* @return array Processor
48+
*/
49+
public function discoverProcessors()
3950
{
40-
$hardware = [
41-
'1' => 'Viptela vSmart Controller',
42-
'2' => 'Viptela vManage NMS',
43-
'3' => 'Viptela vBond Orchestrator',
44-
'4' => 'Viptela vEdge-1000',
45-
'5' => 'Viptela vEdge-2000',
46-
'6' => 'Viptela vEdge-100',
47-
'7' => 'Viptela vEdge-100-W2',
48-
'8' => 'Viptela vEdge-100-WM',
49-
'9' => 'Viptela vEdge-100-M2',
50-
'10' => 'Viptela vEdge-100-M',
51-
'11' => 'Viptela vEdge-100-B',
52-
'12' => 'Viptela vEdge Cloud',
53-
'13' => 'Viptela vContainer',
54-
'14' => 'Viptela vEdge-5000',
55-
];
56-
57-
return $hardware[(string) $id] ?? $id;
51+
$idle_cpu = 100 - (int) \SnmpQuery::get([$this->procOid])->value();
52+
$processors[] = Processor::discover(
53+
'viptela',
54+
$this->getDeviceId(),
55+
$this->procOid,
56+
0,
57+
'Processor',
58+
1,
59+
$idle_cpu,
60+
);
61+
62+
return $processors;
63+
}
64+
65+
/**
66+
* Poll processor data. This can be implemented if custom polling is needed.
67+
*
68+
* @param array $processors Array of processor entries from the database that need to be polled
69+
* @return array of polled data
70+
*/
71+
public function pollProcessors(array $processors)
72+
{
73+
$data = [];
74+
75+
foreach ($processors as $processor) {
76+
$data[$processor['processor_id']] = 100 - (int) \SnmpQuery::get([$this->procOid])->value();
77+
}
78+
79+
return $data;
5880
}
5981
}
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1+
mib: VIPTELA-OPER-SYSTEM:VIPTELA-HARDWARE
12
modules:
23
os:
3-
serial: .1.3.6.1.4.1.41916.3.1.1.1.5.1.0
4-
version: .1.3.6.1.4.1.41916.11.1.2.0
5-
hardware: .1.3.6.1.4.1.41916.11.1.47.0
4+
serial: VIPTELA-HARDWARE::hardwareInventorySerialNumber.chassis.0
5+
version: VIPTELA-OPER-SYSTEM::systemStatusVersion.0
6+
hardware: VIPTELA-OPER-SYSTEM::systemStatusModel.0
7+
mempools:
8+
data:
9+
-
10+
total: VIPTELA-OPER-SYSTEM::systemStatusMemTotal
11+
used: VIPTELA-OPER-SYSTEM::systemStatusMemUsed
12+
free: VIPTELA-OPER-SYSTEM::systemStatusMemFree
13+
precision: 1024
14+

includes/definitions/viptela.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ over:
77
- { graph: device_bits, text: 'Device Traffic' }
88
- { graph: device_processor, text: 'Processor Usage' }
99
- { graph: device_mempool, text: 'Memory Usage' }
10-
mib_dir: cisco
10+
mib_dir: viptela
1111
discovery:
1212
-
1313
sysObjectID:

0 commit comments

Comments
 (0)