Add unsupported device to Observium (Fiberhome OLT)

Add unsupported devices

To be able to add unsupported devices, we need to have the device's mib file. On this tutorial, we use Fiberhome OLT as example. First, download the Fiberhome mib file from here. For the observium enterprise/professional, It is already provided in the /opt/observium/mibs/fiberhome folder. Download the file and put in the /opt/observium/mibs/rfc.
Check the device sysDescr and sysObjectID using snmpget command:
[root@observium ~]# snmpget -v2c -c public fiberhome-olt .1.3.6.1.2.1.1.1.0 .1.3.6.1.2.1.1.2.0 -On
.1.3.6.1.2.1.1.1.0 = STRING: "AN5516-01"
.1.3.6.1.2.1.1.2.0 = OID: .1.3.6.1.4.1.5875.800.1001.11
Based on that result, the device needs to be defined in the config.php as follows:

$os = "fh-olt";
$config['os'][$os]['text']                  = "Fiberhome OLT";
$config['os'][$os]['type']                  = "network";
$config['os'][$os]['vendor']                = "Fiberhome";
$config['os'][$os]['icon']                  = "fiberhome";
$config['os'][$os]['sysObjectID'][]         = ".1.3.6.1.4.1.5875.800.1001";
$config['os'][$os]['sysDescr'][]           = "/^AN5516-01/";
$config['os'][$os]['mibs'][]            = "FIBERHOME-DATACOMM-MIB";
$config['os'][$os]['mibs'][]            = "GEPON-OLT-COMMON-MIB";
$config['os'][$os]['mibs'][]            = "GEPON-OLT-VOICE-MIB";
Icon is a png image that is placed in the html/images/os/ folder.
From now on, the device will be recognized as fh-olt from the discovery tools:
[root@observium ~]# ./discovery.php -h fiberhome-server -m os
#####  fiberhome-server  #####
 o OS Type              fh-olt
 o SNMP Version         v2c
 o Last discovery       2018-11-16 15:37:32
 o Last duration        7.73 seconds
#####  Module Start: os  #####
+-------------+-------------------------------+
| OID         |                               |
+-------------+-------------------------------+
| sysDescr    | AN5516-01                     |
| sysObjectID | .1.3.6.1.4.1.5875.800.1001.11 |
+-------------+-------------------------------+
 o Detect OS matched (fh-olt: Fiberhome OLT):
+-------------+----------------------------+-------------------------------+
| OID         | Matched definition         |                               |
+-------------+----------------------------+-------------------------------+
| sysObjectID | .1.3.6.1.4.1.5875.800.1001 | .1.3.6.1.4.1.5875.800.1001.11 |
+-------------+----------------------------+-------------------------------+

Add custom port

In this example, we want to show all onu status as port. So we need to know which oid that related to that. From the mib file, the information can be collected from:
  • onuIndex
  • authOnuListPon --> pon number
  • authOnuListSlot --> slot number
  • onuStatus --> onu status (0 - fibercut, 1 - online, 2 - powercut, 3 - offline)
  • authOnuListOnuid --> onu number
  • authOnuListMac --> onu mac
After that, create file /opt/observium/includes/discovery/ports/gepon-olt-common-mib.inc.php with this content:
<?php
// GEPON-OLT-COMMON-MIB
$mib = 'GEPON-OLT-COMMON-MIB';
if (count($port_stats) && $device['os'] == 'fh-olt'){
  $f5_stats = snmpwalk_cache_oid($device, 'onuIndex',    array(), $mib);
  if ($GLOBALS['snmp_status']){
    $f5_stats = snmpwalk_cache_oid($device, 'authOnuListPon', $f5_stats, $mib);
    $f5_stats = snmpwalk_cache_oid($device, 'authOnuListSlot', $f5_stats, $mib);
    $f5_stats = snmpwalk_cache_oid($device, 'onuStatus', $f5_stats, $mib);
    $f5_stats = snmpwalk_cache_oid($device, 'authOnuListOnuid', $f5_stats, $mib);
    $f5_stats = snmpwalk_cache_oid($device, 'authOnuListMac', $f5_stats, $mib);

    if(!empty($f5_stats)){
      foreach ($f5_stats as $ifIndex => $port){
        switch ($port['onuStatus']){
           case "0": $status = "fiber cut"; $osstat = "down"; break;
           case "1": $status = "online"; $osstat = "up"; break;
           case "2": $status = "power cut"; $osstat = "lowerLayerDown"; break;
           default: $status = "offline"; $osstat = "dormant"; break;
        }
        $port_stats[$ifIndex]['ifName'] = "S" . $port['authOnuListSlot'] . "/P" . $port['authOnuListPon'] . "/O" . $port['authOnuListOnuid'];
        $port_stats[$ifIndex]['ifDescr'] = $port_stats[$ifIndex]['ifName'];
        $port_stats[$ifIndex]['ifType'] = "onuStatus";
        $port_stats[$ifIndex]['ifAlias'] = $status;
        $port_stats[$ifIndex]['ifOperStatus'] = $osstat;
        $port_stats[$ifIndex]['ifPhysAddress'] = $port['authOnuListMac'];
      }
    }
  }
  // Clean
  unset($f5_stats, $ifIndex, $status, $osstat);
}
?>
And create file /opt/observium/includes/polling/ports/gepon-olt-common-mib.inc.php with this content:
 <?php
 $mib = 'GEPON-OLT-COMMON-MIB';
 
 if (count($port_stats) && $device['os'] == 'fh-olt'){
     $f5_stats = snmpwalk_cache_oid($device, 'onuIndex', array(), $mib);
 
     if (OBS_DEBUG > 1 && count($f5_stats)) { print_vars($f5_stats); }
 
     $f5_stats = snmpwalk_cache_oid($device, 'onuStatus', $f5_stats, $mib);
     $f5_stats = snmpwalk_cache_oid($device, 'onuPonSpeed', $f5_stats, $mib);
     $f5_stats = snmpwalk_cache_oid($device, 'authOnuListMac', $f5_stats, $mib);
     $f5_stats = snmpwalk_cache_oid($device, 'authOnuListPon', $f5_stats, $mib);
     $f5_stats = snmpwalk_cache_oid($device, 'authOnuListSlot', $f5_stats, $mib);
     $f5_stats = snmpwalk_cache_oid($device, 'authOnuListOnuid', $f5_stats, $mib);
 
     if(!empty($f5_stats)){
       foreach ($f5_stats as $ifIndex => $port){
         switch ($port['onuStatus']){
            case "0": $status = "fiber cut"; $osstat = "down"; break;
            case "1": $status = "online"; $osstat = "up"; break;
            case "2": $status = "power cut"; $osstat = "lowerLayerDown"; break;
            default: $status = "offline"; $osstat = "dormant"; break;
         }
         $port_stats[$ifIndex]['ifOperStatus'] = $osstat;
         $port_stats[$ifIndex]['ifPhysAddress'] = $port['authOnuListMac'];
         $port_stats[$ifIndex]['ifSpeed'] = $port['onuPonSpeed'];
         $port_stats[$ifIndex]['ifName'] = "S" . $port['authOnuListSlot'] . "/P" . $port['authOnuListPon'] . "/O" . $port['authOnuListOnuid'];
         $port_stats[$ifIndex]['ifDescr'] = $port_stats[$ifIndex]['ifName'];
         $port_stats[$ifIndex]['ifType'] = "onuStatus";
         $port_stats[$ifIndex]['ifAlias'] = $status;
         $port_stats[$ifIndex]['ifPhysAddress'] = $port['authOnuListMac'];
       }
     }
 
     // Clean
     unset($f5_stats, $port, $status, $osstat, $ifIndex);
 }
 ?>
That's it, the onu status should show up as port.

Add custom sensors

In this example, we want to show all onu status as sensor. The onu status is represented as power, with 10 as multiplication factor, the value will be
  • 0 - fibercut
  • 10 - online
  • 20 - powercut
  • 30 - offline.
To make the sensors show alert, the limit should be set. 5 for the limit_low and 40 for the limit_high. With that value, alert will be showed up when the status is 0.
The file that is needed to create is /opt/observium/includes/discovery/sensors/gepon-olt-common-mib.inc.php, put the code like below:
<?php
if( $device['os'] == 'fh-olt' ){
$mib = 'GEPON-OLT-COMMON-MIB';
$oids = snmpwalk_cache_oid($device, 'onuIndex', array(), $mib);
$oids = snmpwalk_cache_oid($device, 'authOnuListPon', $oids, $mib);
$oids = snmpwalk_cache_oid($device, 'authOnuListSlot', $oids, $mib);
$oids = snmpwalk_cache_oid($device, 'onuStatus', $oids, $mib);
$oids = snmpwalk_cache_oid($device, 'authOnuListOnuid', $oids, $mib);

if (OBS_DEBUG > 1 && count($oids)){
  print_vars($oids);
}
foreach ($oids as $index => $entry){
  $options = array('entPhysicalIndex' => $index);
  $port = get_port_by_ifIndex($device['device_id'], $index);

  $sensor_name = "S" . $entry['authOnuListSlot'] . "/P" . $entry['authOnuListPon'] . "/O" . $entry['authOnuListOnuid'];

  if (is_array($port)){
    $entry['ifDescr']           = $port['port_label'] . ' Onu Status';
    $options['measured_class']  = 'port';
    $options['measured_entity'] = $port['port_id'];
    $options['entPhysicalIndex_measured'] = $port['ifIndex'];
  } else {
    $entry['ifDescr'] = $sensor_name;
  }
  $descr    = $entry['ifDescr'];
  $scale    = 10;
  $oid_name = 'onuStatus';
  $oid_num  = '1.3.6.1.4.1.5875.800.3.10.1.1.11.'.$entry['onuIndex'];
  $type     = $mib . '-' . $oid_name;
  $value    = $entry['onuStatus'];

  // Limits
  $options['limit_low'] = 5;
  $options['limit_high'] = 40;

  discover_sensor($valid['sensor'], 'power', $device, $oid_num, $index, $type, $descr, $scale, $value, $options);
}
}
?>
That's it, the onu status should show up as sensors.

Add custom status

For custom status, mib should be mapped. In this example, onu status will be shown as status. First, create mib file mapping /opt/observium/includes/definitions/mibs/fiberhome.inc.php with this code:
<?php
$mib = 'GEPON-OLT-COMMON-MIB';
$config['mibs'][$mib]['enable'] = 1;
$config['mibs'][$mib]['mib_dir'] = 'fiberhome';
$config['mibs'][$mib]['descr'] = '';
$config['mibs'][$mib]['states']['fiberhome-onustatus'][0] = array('name' => 'fiberCut', 'event' => 'alert');
$config['mibs'][$mib]['states']['fiberhome-onustatus'][1] = array('name' => 'online', 'event' => 'ok');
$config['mibs'][$mib]['states']['fiberhome-onustatus'][2] = array('name' => 'powerCut', 'event' => 'warning');
$config['mibs'][$mib]['states']['fiberhome-onustatus'][3] = array('name' => 'offline', 'event' => 'warning');
?>
and then create file /opt/observium/includes/discovery/status/gepon-olt-common-mib.inc.php with this code:
<?php
if( $device['os'] == 'fh-olt' ){
$mib = 'GEPON-OLT-COMMON-MIB';
$oids = snmpwalk_cache_oid($device, 'onuIndex', array(), $mib);
$oids = snmpwalk_cache_oid($device, 'authOnuListPon', $oids, $mib);
$oids = snmpwalk_cache_oid($device, 'authOnuListSlot', $oids, $mib);
$oids = snmpwalk_cache_oid($device, 'onuStatus', $oids, $mib);
$oids = snmpwalk_cache_oid($device, 'authOnuListOnuid', $oids, $mib);
foreach ($oids as $index => $entry){
  $name = "S" . $entry['authOnuListSlot'] . "/P" . $entry['authOnuListPon'] . "/O" . $entry['authOnuListOnuid'];
  $descr = $name;
  $oid   = '1.3.6.1.4.1.5875.800.3.10.1.1.11.'.$index;
  $value = $entry['onuStatus'];
  discover_status($device, $oid, 'OnuStatus'.$index, 'fiberhome-onustatus', $descr, $value, array('entPhysicalClass' => 'other'));
}
}
?>
Done, the onu status should be showed up as status.

Comments

Popular Posts