mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
* Extract DiscoveryItem and move some things to better places. Extract model class Fix up model construction. I have problem with construction... Makeshift model working. Switch constructor to factory. discover() and create() Support legacy discovery. Remove uneeded custom pollers Remove netonix custom detection as we try ucd on all os now. Add a few yaml procs. Fix a couple things. More processor discovery conversions Move Calix e7 to standard hrProcessorLoad, but it doesn't fully implement the HR-MIB, move things around to make it work. Add a few yaml procs. Fix a couple things. Correct some stupid mib stuff. Move more, drop php 5.3 Add netscaler which uses string indexes. Port fiberhome to yaml and use skip_values More conversions. BroadcomProcessorUsage Trait Serveriron and Ironware share some mibs. Create a common abstract os for them. Add yaml support for mib specification in each data entry Make legacy discover_processor() set 0 for hrDeviceIndex Untangle Dell switch OS processors Use use shared OS for groups if they don't have a specific group. fix silly mib mistake Make index optional Move HR and UCD to Traits and out of Processor. * forgot to update the fortiswitch index * Make sgos and avaya-ers match the old index. * fix comware test data * fix merge errors * fix dsm and remove pointless empty modules * file not found exception is in the wrong place. * Updated processor development docs
3.6 KiB
3.6 KiB
source: Developing/os/Mem-CPU-Information.md
This document will guide you through adding detection for Memory / Processor for your new device.
Memory
Detection for memory is done via two php scripts, one for discovery and the other for polling:
includes/discovery/mempools/pulse.inc.php
<?php
if ($device['os'] === 'pulse') {
echo 'PULSE-MEMORY-POOL: ';
$usage = str_replace('"', "", snmp_get($device, 'iveMemoryUtil.0', '-OvQ', 'PULSESECURE-PSG-MIB'));
if (is_numeric($usage)) {
discover_mempool($valid_mempool, $device, 0, 'pulse-mem', 'Main Memory', '100', null, null);
}
}
includes/polling/mempools/pulse.inc.php
<?php
echo 'Pulse Secure MemPool\n';
$perc = str_replace('"', "", snmp_get($device, "iveMemoryUtil.0", '-OvQ', 'PULSESECURE-PSG-MIB'));
if (is_numeric($perc)) {
$memory_available = str_replace('"', "", snmp_get($device, "memTotalReal.0", '-OvQ', 'UCD-SNMP-MIB'));
$mempool['total'] = $memory_available;
$mempool['used'] = ($memory_available / 100 * $perc);
$mempool['free'] = ($memory_available - $mempool['used']);
}
Processor
Detection for processors is done via a yaml file unless custom processing of data is required.
YAML
includes/definitions/discovery/pulse.yaml
mib: PULSESECURE-PSG-MIB
modules:
processors:
data:
-
oid: iveCpuUtil
num_oid: '.1.3.6.1.4.1.12532.10.{{ $index }}'
type: pulse
Available yaml data keys:
Key | Default | Description |
---|---|---|
oid | required | The string based oid to fetch data, could be a table or a single value |
num_oid | required | the numerical oid to fetch data from when polling, usually should be appended by {{ $index }} |
value | optional | Oid to retrieve data from, primarily used for tables |
precision | 1 | The multiplier to multiply the data by. If this is negative, the data will be multiplied then subtracted from 100. |
descr | Processor | Description of this processor, may be an oid or plain string. Helpful values {{ $index }} and {{$count}} |
type | Name of this sensor. This is used with the index to generate a unique id for this sensor. | |
index | {{ $index }} | The index of this sensor, defaults to the index of the oid. |
skip_values | optional | Do not detect this sensor if the value matches |
Accessing values within yaml:
{{ $index }} | The index after the given oid |
{{ $count }} | The count of entries (starting with 1) |
{{ $oid }} |
Any oid in the table or pre-fetched |
Custom Discovery and Polling
If you need to implement custom discovery or polling you can implement the ProcessorDiscovery interface and the ProcessorPolling interface in the OS class.
OS Class files reside under LibreNMS\OS
<?php
namespace LibreNMS\OS;
use LibreNMS\Device\Processor;
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
use LibreNMS\Interfaces\Polling\ProcessorPolling;
use LibreNMS\OS;
class ExampleOS extends OS implements ProcessorDiscovery, ProcessorPolling
{
/**
* Discover processors.
* Returns an array of LibreNMS\Device\Processor objects that have been discovered
*
* @return array Processors
*/
public function discoverProcessors()
{
// discovery code here
}
/**
* Poll processor data. This can be implemented if custom polling is needed.
*
* @param array $processors Array of processor entries from the database that need to be polled
* @return array of polled data
*/
public function pollProcessors(array $processors)
{
// polling code here
}
}