1<?php
2
3/**
4 * Observium
5 *
6 *   This file is part of Observium.
7 *
8 * @package    observium
9 * @subpackage discovery
10 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2015 Observium Limited
11 *
12 */
13
14echo(" F5-BIGIP-SYSTEM-MIB ");
15
16$index = 1; $chassis_pos = 0;
17$inventory[$index] = array(
18    'entPhysicalName'         => $device['hardware'].' Chassis',
19    'entPhysicalDescr'        => $device['hostname'],
20    'entPhysicalClass'        => 'chassis',
21    'entPhysicalIsFRU'        => 'true',
22    'entPhysicalModelName'    => $device['hardware'],
23    'entPhysicalSerialNum'    => $device['serial'],
24    'entPhysicalHardwareRev'  => snmp_get($device, "sysGeneralHwName.0", "-Oqv", "F5-BIGIP-SYSTEM-MIB"),
25    'entPhysicalFirmwareRev'  => $device['version'],
26    'entPhysicalAssetID'      => $device['asset_tag'],
27    'entPhysicalContainedIn'  => 0,
28    'entPhysicalParentRelPos' => -1,
29    'entPhysicalMfgName'      => 'F5'
30);
31discover_inventory($device, $index, $inventory[$index], $mib);
32
33if (!isset($cache_discovery['f5-bigip-system-mib']))
34{
35  $cache_discovery['f5-bigip-system-mib']['chassis']['port']        = snmpwalk_cache_oid($device, 'sysInterfaceTable',          array(), 'F5-BIGIP-SYSTEM-MIB');
36  $cache_discovery['f5-bigip-system-mib']['chassis']['powerSupply'] = snmpwalk_cache_oid($device, 'sysChassisPowerSupplyTable', array(), 'F5-BIGIP-SYSTEM-MIB');
37  $cache_discovery['f5-bigip-system-mib']['chassis']['fan']         = snmpwalk_cache_oid($device, 'sysChassisFanTable',         array(), 'F5-BIGIP-SYSTEM-MIB');
38  $cache_discovery['f5-bigip-system-mib']['chassis']['temp']        = snmpwalk_cache_oid($device, 'sysChassisTempTable',        array(), 'F5-BIGIP-SYSTEM-MIB');
39  $cache_discovery['f5-bigip-system-mib']['slot']['voltage']        = snmpwalk_cache_oid($device, 'sysBladeVoltageTable',       array(), 'F5-BIGIP-SYSTEM-MIB');
40  $cache_discovery['f5-bigip-system-mib']['slot']['cpu']            = snmpwalk_cache_oid($device, 'sysCpuSensorTable',          array(), 'F5-BIGIP-SYSTEM-MIB');
41  $cache_discovery['f5-bigip-system-mib']['slot']['disk']           = snmpwalk_cache_oid($device, 'sysPhysicalDiskTable',       array(), 'F5-BIGIP-SYSTEM-MIB');
42  $cache_discovery['f5-bigip-system-mib']['slot']['temp']           = snmpwalk_cache_oid($device, 'sysBladeTempTable',          array(), 'F5-BIGIP-SYSTEM-MIB');
43}
44
45$cache_ports = dbFetchRows('SELECT `ifName`,`ifIndex` FROM `ports` WHERE `device_id` = ?', array($device['device_id']));
46foreach ($cache_ports as $row => $port)
47{
48  $cache_ports[$port['ifName']] = $port['ifIndex'];
49}
50
51$fru = array(
52         'fan' => 'false',
53         'powerSupply' => 'true',
54         'temp' => 'false',
55         'disk' => 'false',
56         'port' => 'false',
57       );
58
59$class = array(
60         'fan' => 'fan',
61         'powerSupply' => 'powerSupply',
62         'temp' => 'sensor',
63         'disk' => 'disk',
64         'port' => 'port',
65       );
66
67foreach ($cache_discovery['f5-bigip-system-mib']['chassis'] as $type => $cache)
68{
69  if (!count($cache)) continue;
70  $index++; $chassis_pos++;
71  $container = $index;
72  $inventory[$index] = array(
73    'entPhysicalName'         => 'Chassis '.ucfirst($type).' Container',
74    'entPhysicalDescr'        => $device['hostname'].' - Chassis '.ucfirst($type).' Container',
75    'entPhysicalClass'        => 'container',
76    'entPhysicalIsFRU'        => $fru[$type],
77    'entPhysicalContainedIn'  => 1,
78    'entPhysicalParentRelPos' => $chassis_pos,
79    'entPhysicalMfgName'      => 'F5'
80  );
81  discover_inventory($device, $index, $inventory[$index], $mib);
82
83  $pos = 0;
84  foreach ($cache as $id => $entry)
85  {
86    $index++; $pos++;
87    $name = ucfirst($type).' '.$id;
88    $serial = NULL;
89    $ifindex = NULL;
90    if ($type == 'port')
91    {
92      $ifindex = $cache_ports[$id];
93    }
94    $inventory[$index] = array(
95      'entPhysicalName'         => $name,
96      'entPhysicalDescr'        => $device['hostname'].' - '.$name,
97      'entPhysicalClass'        => $class[$type],
98      'entPhysicalIsFRU'        => $fru[$type],
99      'entPhysicalSerialNum'    => $serial,
100      'entPhysicalContainedIn'  => $container,
101      'entPhysicalParentRelPos' => $pos,
102      'entPhysicalMfgName'      => 'F5',
103      'ifIndex'                 => $ifindex
104    );
105    discover_inventory($device, $index, $inventory[$index], $mib);
106    unset($ifIndex);
107  }
108}
109
110// Build and array of stuff by slot
111foreach ($cache_discovery['f5-bigip-system-mib']['slot'] as $type => $sensors)
112{
113  foreach ($sensors as $tmp => $sensor)
114  switch ($type)
115  {
116    case 'cpu':
117      $slots[$sensor['sysCpuSensorSlot']]['cpu'] = $sensor;
118      break;
119    case 'disk':
120      $slots[$sensor['sysPhysicalDiskSlotId']]['disk'] = $sensor;
121      break;
122    case 'temp':
123      $slots[$sensor['sysBladeTempSlot']]['temp'][$sensor['sysBladeTempIndex']] = $sensor;
124      break;
125    case 'voltage':
126      $slots[$sensor['sysBladeVoltageSlot']]['voltage'][$sensor['sysBladeVoltageIndex']] = $sensor;
127      break;
128  }
129}
130
131foreach ($slots as $slot => $sensors)
132{
133  $index++; $chassis_pos++;
134  $slot_container = $index;
135  $pos = 0;
136  $inventory[$index] = array(
137    'entPhysicalName'         => 'Blade Slot '.$slot.' Container',
138    'entPhysicalDescr'        => $device['hostname'].' - Blade Slot '.$slot.' Container',
139    'entPhysicalClass'        => 'container',
140    'entPhysicalIsFRU'        => 'false',
141    'entPhysicalContainedIn'  => 1,
142    'entPhysicalParentRelPos' => $chassis_pos,
143    'entPhysicalMfgName'      => 'F5'
144  );
145  discover_inventory($device, $index, $inventory[$index], $mib);
146
147  foreach ($sensors as $type => $entry)
148  {
149    $index++;
150    if ($type == 'disk')
151    {
152      $pos++;
153      $name   = $entry['sysPhysicalDiskName'];
154      $serial = $entry['sysPhysicalDiskSerialNumber'];
155      $inventory[$index] = array(
156        'entPhysicalName'         => $name,
157        'entPhysicalDescr'        => $device['hostname'].' - '.$name,
158        'entPhysicalClass'        => $class[$type],
159        'entPhysicalIsFRU'        => $fru[$type],
160        'entPhysicalSerialNum'    => $serial,
161        'entPhysicalContainedIn'  => $slot_container,
162        'entPhysicalParentRelPos' => $pos,
163        'entPhysicalMfgName'      => 'F5',
164      );
165      discover_inventory($device, $index, $inventory[$index], $mib);
166    }
167    else if ($type == 'cpu')
168    {
169      $pos++;
170      $cpu_container = $index;
171      $inventory[$index] = array(
172        'entPhysicalName'         => 'Blade Slot '.$slot.' CPU Container',
173        'entPhysicalDescr'        => $device['hostname'].' - Chassis Slot '.$slot.' CPU Container',
174        'entPhysicalClass'        => 'container',
175        'entPhysicalIsFRU'        => 'false',
176        'entPhysicalContainedIn'  => $slot_container,
177        'entPhysicalParentRelPos' => $pos,
178        'entPhysicalMfgName'      => 'F5'
179      );
180      discover_inventory($device, $index, $inventory[$index], $mib);
181      $index++;
182      $name = $entry['sysCpuSensorName'].' Temperature';
183      $inventory[$index] = array(
184        'entPhysicalName'         => $name,
185        'entPhysicalDescr'        => $device['hostname'].' - '.$name,
186        'entPhysicalClass'        => 'sensor',
187        'entPhysicalIsFRU'        => 'false',
188        'entPhysicalContainedIn'  => $cpu_container,
189        'entPhysicalParentRelPos' => 1,
190        'entPhysicalMfgName'      => 'F5',
191      );
192      discover_inventory($device, $index, $inventory[$index], $mib);
193      $index++;
194      $name = $entry['sysCpuSensorName'].' Fan';
195      $inventory[$index] = array(
196        'entPhysicalName'         => $name,
197        'entPhysicalDescr'        => $device['hostname'].' - '.$name,
198        'entPhysicalClass'        => 'fan',
199        'entPhysicalIsFRU'        => 'false',
200        'entPhysicalContainedIn'  => $cpu_container,
201        'entPhysicalParentRelPos' => 2,
202        'entPhysicalMfgName'      => 'F5',
203      );
204      discover_inventory($device, $index, $inventory[$index], $mib);
205    }
206    else if ($type == 'temp')
207    {
208      $pos++;
209      $temp_container = $index;
210      $inventory[$index] = array(
211        'entPhysicalName'         => 'Blade Slot '.$slot.' Temp Container',
212        'entPhysicalDescr'        => $device['hostname'].' - Chassis Slot '.$slot.' Temp Container',
213        'entPhysicalClass'        => 'container',
214        'entPhysicalIsFRU'        => 'false',
215        'entPhysicalContainedIn'  => $slot_container,
216        'entPhysicalParentRelPos' => $pos,
217        'entPhysicalMfgName'      => 'F5'
218      );
219      discover_inventory($device, $index, $inventory[$index], $mib);
220
221      foreach ($entry as $temp_index => $temp_sensor)
222      {
223        $index++;
224        $inventory[$index] = array(
225          'entPhysicalName'         => $temp_sensor['sysBladeTempLocation'],
226          'entPhysicalDescr'        => $device['hostname'].' - '.$temp_sensor['sysBladeTempLocation'],
227          'entPhysicalClass'        => 'sensor',
228          'entPhysicalIsFRU'        => 'false',
229          'entPhysicalContainedIn'  => $temp_container,
230          'entPhysicalParentRelPos' => $temp_index,
231          'entPhysicalMfgName'      => 'F5',
232        );
233        discover_inventory($device, $index, $inventory[$index], $mib);
234      }
235    }
236    else if ($type == 'voltage')
237    {
238      $pos++;
239      $voltage_container = $index;
240      $inventory[$index] = array(
241        'entPhysicalName'         => 'Blade Slot '.$slot.' Voltage Container',
242        'entPhysicalDescr'        => $device['hostname'].' - Chassis Slot '.$slot.' Voltage Container',
243        'entPhysicalClass'        => 'container',
244        'entPhysicalIsFRU'        => 'false',
245        'entPhysicalContainedIn'  => $slot_container,
246        'entPhysicalParentRelPos' => $pos,
247        'entPhysicalMfgName'      => 'F5'
248      );
249      discover_inventory($device, $index, $inventory[$index], $mib);
250
251      $volt_pos = 0;
252      foreach ($entry as $volt_index => $volt_sensor)
253      {
254        $index++; $volt_pos++;
255        $inventory[$index] = array(
256          'entPhysicalName'         => $volt_index,
257          'entPhysicalDescr'        => $device['hostname'].' - '.$volt_index,
258          'entPhysicalClass'        => 'sensor',
259          'entPhysicalIsFRU'        => 'false',
260          'entPhysicalContainedIn'  => $voltage_container,
261          'entPhysicalParentRelPos' => $volt_pos,
262          'entPhysicalMfgName'      => 'F5',
263        );
264        discover_inventory($device, $index, $inventory[$index], $mib);
265      }
266    }
267  }
268}
269
270unset($cache_ports, $slots, $name, $index, $container, $pos, $slot_container, $cpu_container, $temp_container, $voltage_container);
271// EOF
272