commit version 22.12.12447
This commit is contained in:
@ -55,7 +55,9 @@ $bgp4_peers = snmpwalk_cache_oid($device, $def['oids']['PeerInUpdateElapsedTime'
|
||||
//$bgp4_peers = snmpwalk_cache_oid($device, $def['oids']['PeerIdentifier']['oid'], $bgp4_peers, $mib);
|
||||
|
||||
// Collect founded peers
|
||||
$bgp_peers = []; // need rewrite array for fix incorrect indexes
|
||||
if (!is_array($bgp_peers)) {
|
||||
$bgp_peers = []; // need rewrite array for fix incorrect indexes
|
||||
}
|
||||
foreach ($bgp4_peers as $index => $bgp4_entry) {
|
||||
$index_parts = explode('.', $index);
|
||||
if (safe_count($index_parts) > 4) {
|
||||
|
@ -45,7 +45,9 @@ $bgp4_peers = snmpwalk_cache_oid($device, $def['oids']['PeerInUpdateElapsedTime'
|
||||
//$bgp4_peers = snmpwalk_cache_oid($device, $def['oids']['PeerIdentifier']['oid'], $bgp4_peers, $mib);
|
||||
|
||||
// Collect founded peers
|
||||
$bgp_peers = []; // need rewrite array for fix incorrect indexes
|
||||
if (!is_array($bgp_peers)) {
|
||||
$bgp_peers = []; // need rewrite array for fix incorrect indexes
|
||||
}
|
||||
foreach ($bgp4_peers as $index => $bgp4_entry) {
|
||||
$peer_ip = $index;
|
||||
$peer_as = snmp_dewrap32bit($bgp4_entry['bgpPeerRemoteAs']); // Dewrap for 32bit ASN
|
||||
|
@ -349,20 +349,28 @@ foreach ($fdbs_db as $vlan => $fdb_macs) {
|
||||
$table_row = [];
|
||||
$table_row[] = $vlan;
|
||||
$table_row[] = $mac;
|
||||
//$table_row[] = $data['port_label_short'];
|
||||
$table_row[] = "Port {$data['port_index']}";
|
||||
$table_row[] = $data['port_id'];
|
||||
//$table_row[] = $fdb_port;
|
||||
//$table_row[] = $data['ifIndex'];
|
||||
$table_row[] = '%rdeleted%n';
|
||||
$table_rows[] = $table_row;
|
||||
//echo(str_pad($vlan, 8) . ' | ' . str_pad($mac,12) . ' | ' . str_pad($data['port_id'],25) .' | '. str_pad($data['fdb_status'],16));
|
||||
//echo("-\n");
|
||||
if (isset($data['fdb_id'])) {
|
||||
// Multi delete (for faster loop)
|
||||
$fdb_delete[] = $data['fdb_id'];
|
||||
//print_debug_vars($data);
|
||||
if ($data['deleted']) {
|
||||
// Do not poke db change when already deleted
|
||||
$table_row[] = '%ydeleted '.format_unixtime($data['fdb_last_change']).'%n';
|
||||
} else {
|
||||
$table_row[] = '%rdeleted%n';
|
||||
$fdb_delete[] = $data['fdb_id'];
|
||||
}
|
||||
} else {
|
||||
// CLEANME. After r12500
|
||||
$table_row[] = '%rdeleted%n';
|
||||
dbDelete('vlans_fdb', '`device_id` = ? AND `vlan_id` = ? AND `mac_address` = ?', [ $device['device_id'], $vlan, $mac ]);
|
||||
}
|
||||
$table_rows[] = $table_row;
|
||||
}
|
||||
}
|
||||
|
||||
@ -370,8 +378,8 @@ foreach ($fdbs_db as $vlan => $fdb_macs) {
|
||||
if (safe_count($fdb_delete)) {
|
||||
print_debug_vars($fdb_delete);
|
||||
// do not delete, set deleted flag
|
||||
dbUpdate([ 'fdb_last_change' => $polled, 'deleted' => 1 ], 'vlans_fdb', generate_query_values($fdb_delete, 'fdb_id', NULL, FALSE));
|
||||
//dbDelete('vlans_fdb', generate_query_values($fdb_delete, 'fdb_id', NULL, FALSE));
|
||||
dbUpdate([ 'fdb_last_change' => $polled, 'deleted' => 1 ], 'vlans_fdb', generate_query_values_ng($fdb_delete, 'fdb_id'));
|
||||
//dbDelete('vlans_fdb', generate_query_values_ng($fdb_delete, 'fdb_id'));
|
||||
}
|
||||
|
||||
/* MultiInsert new fdb entries
|
||||
|
@ -6,11 +6,10 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage poller
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Poll and cache entity _NUMERIC_ Oids,
|
||||
* need for cross cache between different entities, ie status and sensors
|
||||
@ -21,8 +20,7 @@
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function poll_cache_oids($device, $entity_type, &$oid_cache)
|
||||
{
|
||||
function poll_cache_oids($device, $entity_type, &$oid_cache) {
|
||||
global $config;
|
||||
|
||||
$use_walk = FALSE; // Use multi get by default
|
||||
@ -37,8 +35,7 @@ function poll_cache_oids($device, $entity_type, &$oid_cache)
|
||||
$deleted_field = $translate['deleted_field'];
|
||||
$device_field = $translate['device_id_field'];
|
||||
|
||||
switch ($entity_type)
|
||||
{
|
||||
switch ($entity_type) {
|
||||
case 'sensor':
|
||||
case 'status':
|
||||
case 'counter':
|
||||
@ -52,11 +49,17 @@ function poll_cache_oids($device, $entity_type, &$oid_cache)
|
||||
// Walk query
|
||||
$walk_query = "SELECT DISTINCT `$mib_field`, `$object_field` FROM `$table` WHERE `$device_field` = ? AND `$deleted_field` = ? AND `poller_type` = ?";
|
||||
$walk_query .= " AND `$mib_field` != ? AND `$object_field` != ?";
|
||||
$walk_params = [$device['device_id'], '0', 'snmp', '', ''];
|
||||
$walk_params = [ $device['device_id'], '0', 'snmp', '', '' ];
|
||||
|
||||
// Multi-get query
|
||||
$get_query = "SELECT DISTINCT `$oid_field` FROM `$table` WHERE `$device_field` = ? AND `$deleted_field` = ? AND `poller_type` = ?";
|
||||
$get_params = [$device['device_id'], '0', 'snmp'];
|
||||
$get_params = [ $device['device_id'], '0', 'snmp' ];
|
||||
|
||||
break;
|
||||
|
||||
case 'storage':
|
||||
|
||||
return poll_cache_storage($device, $oid_cache);
|
||||
|
||||
break;
|
||||
|
||||
@ -65,8 +68,8 @@ function poll_cache_oids($device, $entity_type, &$oid_cache)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ($use_walk)
|
||||
{
|
||||
// This seems actual only for sensor/status/counter
|
||||
if ($use_walk) {
|
||||
// Walk by mib & object
|
||||
$oid_to_cache = dbFetchRows($walk_query, $walk_params);
|
||||
print_debug_vars($oid_to_cache);
|
||||
@ -202,28 +205,28 @@ function poll_device($device, $options) {
|
||||
$device['status_type'] = $status_type;
|
||||
}
|
||||
|
||||
rrdtool_update_ng($device, 'status', array('status' => $status));
|
||||
rrdtool_update_ng($device, 'status', [ 'status' => $status ]);
|
||||
//print_vars(rrdtool_export_ng($device, 'status'));
|
||||
|
||||
if (!$attribs['ping_skip']) {
|
||||
// Ping response RRD database.
|
||||
rrdtool_update_ng($device, 'ping', array('ping' => ($device['pingable'] ?: 'U')));
|
||||
rrdtool_update_ng($device, 'ping', [ 'ping' => ($device['status_pingable'] ?: 'U') ]);
|
||||
}
|
||||
|
||||
// SNMP response RRD database.
|
||||
rrdtool_update_ng($device, 'ping_snmp', array('ping_snmp' => ($device['snmpable'] ?: 'U')));
|
||||
rrdtool_update_ng($device, 'ping_snmp', [ 'ping_snmp' => ($device['status_snmpable'] ?: 'U') ]);
|
||||
|
||||
$alert_metrics['device_status'] = $status;
|
||||
$alert_metrics['device_status_type'] = $status_type;
|
||||
$alert_metrics['device_ping'] = $device['pingable']; // FIXME, when ping skipped, here always 0.001
|
||||
$alert_metrics['device_snmp'] = $device['snmpable'];
|
||||
$alert_metrics['device_ping'] = $device['status_pingable']; // FIXME, when ping skipped, here always 0.001
|
||||
$alert_metrics['device_snmp'] = $device['status_snmpable'];
|
||||
|
||||
if ($status == "1") {
|
||||
// Arrays for store and check enabled/disabled graphs
|
||||
$graphs = array();
|
||||
$graphs_db = array();
|
||||
$graphs_insert = array();
|
||||
$graphs_delete = array();
|
||||
$graphs = [];
|
||||
$graphs_db = [];
|
||||
$graphs_insert = [];
|
||||
$graphs_delete = [];
|
||||
foreach (dbFetchRows("SELECT * FROM `device_graphs` WHERE `device_id` = ?", array($device['device_id'])) as $entry) {
|
||||
// Not know how empty was here
|
||||
if (empty($entry['graph'])) {
|
||||
@ -369,7 +372,7 @@ function poll_device($device, $options) {
|
||||
dbInsertMulti($graphs_insert, 'device_graphs');
|
||||
}
|
||||
if (safe_count($graphs_delete)) {
|
||||
dbDelete('device_graphs', generate_query_values($graphs_delete, 'device_graph_id', NULL, FALSE));
|
||||
dbDelete('device_graphs', generate_query_values_ng($graphs_delete, 'device_graph_id'));
|
||||
}
|
||||
|
||||
// Print graphs stats
|
||||
|
@ -21,11 +21,11 @@ $table_defs['TERADICI-PCOIPv2-MIB']['pcoipGenStatsTable'] = array (
|
||||
'graphs' => array('pcoip-net-packets'),
|
||||
'ds_rename' => array('pcoipGenStats' => ''),
|
||||
'oids' => array(
|
||||
'pcoipGenStatsPacketsSent' => array('numeric' => '2', 'index'=>'1', 'oid'=>'.1.3.6.1.4.1.25071.1.2.1.1.1.2', 'descr' => 'Packets sent'),
|
||||
'pcoipGenStatsBytesSent' => array('numeric' => '3', 'index'=>'1', 'oid'=>'.1.3.6.1.4.1.25071.1.2.1.1.1.3', 'descr' => 'Bytes sent'),
|
||||
'pcoipGenStatsPacketsReceived' => array('numeric' => '4', 'index'=>'1', 'oid'=>'.1.3.6.1.4.1.25071.1.2.1.1.1.4', 'descr' => 'Packets received'),
|
||||
'pcoipGenStatsBytesReceived' => array('numeric' => '5', 'index'=>'1', 'oid'=>'.1.3.6.1.4.1.25071.1.2.1.1.1.5', 'descr' => 'Bytes received'),
|
||||
'pcoipGenStatsTxPacketsLost' => array('numeric' => '6', 'index'=>'1', 'oid'=>'.1.3.6.1.4.1.25071.1.2.1.1.1.6', 'descr' => 'Packets lost', 'ds_type' => 'GAUGE')
|
||||
'pcoipGenStatsPacketsSent' => array('numeric' => '2', 'index'=>'1', 'oid'=>'.1.3.6.1.4.1.25071.1.2.1.1.1.2', 'descr' => 'Packets sent'),
|
||||
'pcoipGenStatsBytesSent' => array('numeric' => '3', 'index'=>'1', 'oid'=>'.1.3.6.1.4.1.25071.1.2.1.1.1.3', 'descr' => 'Bytes sent'),
|
||||
'pcoipGenStatsPacketsReceived' => array('numeric' => '4', 'index'=>'1', 'oid'=>'.1.3.6.1.4.1.25071.1.2.1.1.1.4', 'descr' => 'Packets received'),
|
||||
'pcoipGenStatsBytesReceived' => array('numeric' => '5', 'index'=>'1', 'oid'=>'.1.3.6.1.4.1.25071.1.2.1.1.1.5', 'descr' => 'Bytes received'),
|
||||
'pcoipGenStatsTxPacketsLost' => array('numeric' => '6', 'index'=>'1', 'oid'=>'.1.3.6.1.4.1.25071.1.2.1.1.1.6', 'descr' => 'Packets lost', 'ds_type' => 'GAUGE')
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage poller
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
@ -33,9 +33,19 @@ if ($ipmi['host'] = get_dev_attrib($device,'ipmi_hostname')) {
|
||||
$ipmi['interface'] = 'lan';
|
||||
}
|
||||
|
||||
$own_hostname = $config['own_hostname'] ?: get_localhost();
|
||||
$remote = '';
|
||||
if ($config['own_hostname'] !== $device['hostname'] && $ipmi['host'] !== 'localhost' && $ipmi['host'] !== '127.0.0.1') {
|
||||
$remote = " -I " . escapeshellarg($ipmi['interface']) . " -p " . $ipmi['port'] . " -H " . escapeshellarg($ipmi['host']) . " -L " . escapeshellarg($ipmi['userlevel']) . " -U " . escapeshellarg($ipmi['user']) . " -P " . escapeshellarg($ipmi['password']);
|
||||
if ($own_hostname !== $device['hostname'] &&
|
||||
!in_array($ipmi['host'], [ 'localhost', '127.0.0.1', '::1' ], TRUE)) {
|
||||
|
||||
$remote = " -I " . escapeshellarg($ipmi['interface']) . " -p " . $ipmi['port'] . " -H " .
|
||||
escapeshellarg($ipmi['host']) . " -L " . escapeshellarg($ipmi['userlevel']) .
|
||||
" -U " . escapeshellarg($ipmi['user']) . " -P " . escapeshellarg($ipmi['password']);
|
||||
}
|
||||
|
||||
if(is_numeric($device['ipmi_ciper']) && $device['ipmi_ciper'] == '17')
|
||||
{
|
||||
$remote .= " -C ".$device['ipmi_cipher'];
|
||||
}
|
||||
|
||||
$results = external_exec($config['ipmitool'] . $remote . " sensor 2>/dev/null");
|
||||
|
@ -1,13 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage poller
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
* @package observium
|
||||
* @subpackage poller
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
@ -64,7 +63,7 @@ foreach (dbFetchRows($query, array($device['device_id'])) as $lsp)
|
||||
foreach (array('uptime', 'total_uptime', 'primary_uptime') as $ds)
|
||||
{
|
||||
$rrd_ds .= "DS:" . $ds . ":GAUGE:600:0:U ";
|
||||
$uptime_values[] = $lsp["lsp_${ds}"];
|
||||
$uptime_values[] = $lsp["lsp_{$ds}"];
|
||||
}
|
||||
if (count($uptime_values))
|
||||
{
|
||||
@ -80,7 +79,7 @@ foreach (dbFetchRows($query, array($device['device_id'])) as $lsp)
|
||||
foreach (array('transitions', 'path_changes') as $ds)
|
||||
{
|
||||
$rrd_ds .= "DS:" . $ds . ":COUNTER:600:0:U ";
|
||||
$stats_values[] = $lsp["lsp_${ds}"];
|
||||
$stats_values[] = $lsp["lsp_{$ds}"];
|
||||
}
|
||||
if (count($stats_values))
|
||||
{
|
||||
@ -97,7 +96,7 @@ foreach (dbFetchRows($query, array($device['device_id'])) as $lsp)
|
||||
foreach (array('octets', 'packets') as $ds)
|
||||
{
|
||||
$rrd_ds .= "DS:" . $ds . ":COUNTER:600:0:" . $config['max_port_speed'] . ' ';
|
||||
$lsp_values[] = $lsp["lsp_${ds}"];
|
||||
$lsp_values[] = $lsp["lsp_{$ds}"];
|
||||
}
|
||||
if (count($lsp_values))
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
@ -7,7 +6,7 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage poller
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
@ -16,7 +15,10 @@
|
||||
// ALVARION-DOT11-WLAN-MIB::brzaccVLUnitType.0 = INTEGER: auSA(2)
|
||||
// ALVARION-DOT11-WLAN-TST-MIB::brzLighteOemProjectNameString.0 = STRING: "BreezeACCESS VL"
|
||||
|
||||
$unit_type = snmp_get($device, 'brzaccVLUnitType.0', '-OQv', 'ALVARION-DOT11-WLAN-MIB');
|
||||
$features = rewrite_breeze_type($unit_type);
|
||||
if ($unit_type = snmp_get_oid($device, 'brzaccVLUnitType.0', 'ALVARION-DOT11-WLAN-MIB')) {
|
||||
$features = rewrite_breeze_type($unit_type);
|
||||
}
|
||||
|
||||
unset($unit_type);
|
||||
|
||||
// EOF
|
||||
|
@ -6,16 +6,15 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage poller
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
if (is_device_mib($device, 'CISCO-CONFIG-MAN-MIB'))
|
||||
{
|
||||
if (is_device_mib($device, 'CISCO-CONFIG-MAN-MIB')) {
|
||||
// Check Cisco configuration age
|
||||
|
||||
$oids = 'sysUpTime.0 ccmHistoryRunningLastChanged.0 ccmHistoryRunningLastSaved.0 ccmHistoryStartupLastChanged.0';
|
||||
$data = snmp_get_multi_oid($device, $oids, array(), 'SNMPv2-MIB:CISCO-CONFIG-MAN-MIB', NULL, OBS_SNMP_ALL_TIMETICKS);
|
||||
$data = snmp_get_multi_oid($device, $oids, [], 'SNMPv2-MIB:CISCO-CONFIG-MAN-MIB', NULL, OBS_SNMP_ALL_TIMETICKS);
|
||||
$config_age = $data[0];
|
||||
|
||||
foreach ($config_age as $key => $val)
|
||||
@ -42,102 +41,92 @@ if (is_device_mib($device, 'CISCO-CONFIG-MAN-MIB'))
|
||||
|
||||
$sysDescr = preg_replace('/\s+/', ' ', $poll_device['sysDescr']); // Replace all spaces and newline to single space
|
||||
// Generic IOS/IOS-XE/IES/IOS-XR sysDescr
|
||||
if (preg_match('/^Cisco IOS Software(?: \[\S+?\])?, .+? Software \((?:[^\-]+-(\w+)-\w|\w+_IOSXE)\),.+?Version ([^,\s]+)/', $sysDescr, $matches))
|
||||
{
|
||||
//Cisco IOS Software, Catalyst 4500 L3 Switch Software (cat4500e-ENTSERVICESK9-M), Version 15.2(1)E3, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2014 by Cisco Systems, Inc. Compiled Mon 05-May-14 07:56 b
|
||||
//Cisco IOS Software, IOS-XE Software (PPC_LINUX_IOSD-IPBASEK9-M), Version 15.2(2)S, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2012 by Cisco Systems, Inc. Compiled Mon 26-Mar-12 15:23 by mcpre
|
||||
//Cisco IOS Software, IES Software (IES-LANBASEK9-M), Version 12.2(52)SE1, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2010 by Cisco Systems, Inc. Compiled Tue 09-Feb-10 03:17 by prod_rel_team
|
||||
//Cisco IOS Software [Gibraltar], Catalyst L3 Switch Software (CAT9K_IOSXE), Version 16.11.1, RELEASE SOFTWARE (fc3) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2019 by Cisco Systems, Inc. Compiled Thu 28-Mar-19 09:42 by mcpre
|
||||
//Cisco IOS Software [Fuji], Catalyst L3 Switch Software (CAT9K_IOSXE), Version 16.8.1a, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2018 by Cisco Systems, Inc. Compiled Tue 03-Apr-18 18:49 by mcpre
|
||||
$features = $matches[1];
|
||||
$version = $matches[2];
|
||||
}
|
||||
elseif (preg_match('/^Cisco Internetwork Operating System Software IOS \(tm\) [^ ]+ Software \([^\-]+-(\w+)-\w\),.+?Version ([^, ]+)/', $sysDescr, $matches))
|
||||
{
|
||||
//Cisco Internetwork Operating System Software IOS (tm) 7200 Software (UBR7200-IK8SU2-M), Version 12.3(17b)BC8, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2007 by cisco Systems, Inc. Compiled Fri 29-Ju
|
||||
//Cisco Internetwork Operating System Software IOS (tm) C1700 Software (C1700-Y-M), Version 12.2(4)YA2, EARLY DEPLOYMENT RELEASE SOFTWARE (fc1) Synched to technology version 12.2(5.4)T TAC Support: http://www.cisco.com/tac Copyright (c) 1986-2002 by ci
|
||||
$features = $matches[1];
|
||||
$version = $matches[2];
|
||||
}
|
||||
elseif (preg_match('/^Cisco IOS XR Software \(Cisco ([^\)]+)\), Version ([^\[]+)\[([^\]]+)\]/', $sysDescr, $matches))
|
||||
{
|
||||
//Cisco IOS XR Software (Cisco 12816/PRP), Version 4.3.2[Default] Copyright (c) 2014 by Cisco Systems, Inc.
|
||||
//Cisco IOS XR Software (Cisco 12404/PRP), Version 3.6.0[00] Copyright (c) 2007 by Cisco Systems, Inc.
|
||||
//Cisco IOS XR Software (Cisco ASR9K Series), Version 5.1.2[Default] Copyright (c) 2014 by Cisco Systems, Inc.
|
||||
//$hardware = $matches[1];
|
||||
$features = $matches[3];
|
||||
$version = $matches[2];
|
||||
}
|
||||
elseif (preg_match('/^Cisco NX-OS(?:\(tm\))? (?<hw1>\S+?), Software \((?<hw2>.+?)\),.+?Version (?<version>[^, ]+)/', $sysDescr, $matches))
|
||||
{
|
||||
//Cisco NX-OS(tm) n7000, Software (n7000-s2-dk9), Version 6.2(8b), RELEASE SOFTWARE Copyright (c) 2002-2013 by Cisco Systems, Inc.
|
||||
//Cisco NX-OS(tm) n1000v, Software (n1000v-dk9), Version 5.2(1)SV3(1.2), RELEASE SOFTWARE Copyright (c) 2002-2011 by Cisco Systems, Inc. Device Manager Version nms.sro not found, Compiled 11/11/2014 15:00:00
|
||||
//Cisco NX-OS(tm) n5000, Software (n5000-uk9), Version 6.0(2)N2(7), RELEASE SOFTWARE Copyright (c) 2002-2012 by Cisco Systems, Inc. Device Manager Version 6.2(1), Compiled 4/28/2015 5:00:00
|
||||
//Cisco NX-OS(tm) n7000, Software (n7000-s2-dk9), Version 6.2(8a), RELEASE SOFTWARE Copyright (c) 2002-2013 by Cisco Systems, Inc. Compiled 5/15/2014 20:00:00
|
||||
//Cisco NX-OS(tm) n3000, Software (n3000-uk9), Version 6.0(2)U2(2), RELEASE SOFTWARE Copyright (c) 2002-2012 by Cisco Systems, Inc. Device Manager Version nms.sro not found, Compiled 2/12/2014 8:00:00
|
||||
//Cisco NX-OS(tm) ucs, Software (ucs-6100-k9-system), Version 5.0(3)N2(3.13a), RELEASE SOFTWARE Copyright (c) 2002-2013 by Cisco Systems, Inc. Compiled 4/25/2017 7:00:00
|
||||
//Cisco NX-OS(tm) aci, Software (aci-n9000-system), Version 12.0(1q), RELEASE SOFTWARE Copyright (c) 2002-2015 by Cisco Systems, Inc. Compiled 2016/08/18 14:20:16
|
||||
//Cisco NX-OS(tm) nxos.9.2.3.bin, Software (nxos), Version 9.2(3), RELEASE SOFTWARE Copyright (c) 2002-2019 by Cisco Systems, Inc. Compiled 2/17/2019 4:00:00
|
||||
//Cisco NX-OS n6000, Software (n6000-uk9), Version 7.3(2)N1(1), RELEASE SOFTWARE Copyright (c) 2002-2012, 2016-2017 by Cisco Systems, Inc. Device Manager Version 6.0(2)N1(1),Compiled 5/12/2017 23:00:00
|
||||
list(, $features) = explode('-', $matches['hw2'], 2);
|
||||
$version = $matches['version'];
|
||||
}
|
||||
elseif (preg_match('/Software \(\w+-(?<features>\w+)-\w\),.+?Version (?<version>[^, ]+),(?:[\w ]+)? RELEASE SOFTWARE/', $sysDescr, $matches))
|
||||
{
|
||||
//C800 Software (C800-UNIVERSALK9-M), Version 15.2(2)T2, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Compiled Thu 02-Aug-12 02:09 by prod_rel_team
|
||||
//Cisco IOS Software, Catalyst 4500 L3 Switch Software (cat4500e-ENTSERVICESK9-M), Version 15.2(1)E3, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2014 by Cisco Systems, Inc. Compiled Mon 05-May-14 07:56 b
|
||||
//Cisco IOS Software, ASR900 Software (PPC_LINUX_IOSD-UNIVERSALK9_NPE-M), Version 15.5(1)S, RELEASE SOFTWARE (fc5) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2014 by Cisco Systems, Inc. Compiled Thu 20-Nov-14 18:16 by mcpre
|
||||
//Cisco IOS Software, IOS-XE Software (PPC_LINUX_IOSD-IPBASEK9-M), Version 15.2(2)S, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2012 by Cisco Systems, Inc. Compiled Mon 26-Mar-12 15:23 by mcpre
|
||||
//Cisco IOS Software, IES Software (IES-LANBASEK9-M), Version 12.2(52)SE1, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2010 by Cisco Systems, Inc. Compiled Tue 09-Feb-10 03:17 by prod_rel_team
|
||||
|
||||
//Cisco Internetwork Operating System Software IOS (tm) 7200 Software (UBR7200-IK8SU2-M), Version 12.3(17b)BC8, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2007 by cisco Systems, Inc. Compiled Fri 29-Ju
|
||||
//Cisco Internetwork Operating System Software IOS (tm) C1700 Software (C1700-Y-M), Version 12.2(4)YA2, EARLY DEPLOYMENT RELEASE SOFTWARE (fc1) Synched to technology version 12.2(5.4)T TAC Support: http://www.cisco.com/tac Copyright (c) 1986-2002 by ci
|
||||
if (preg_match('/^Cisco IOS Software(?: \[\S+?\])?, .+? Software \((?:[^\-]+\-(?<features>\w+)\-\w|\w+_IOSXE(?:\-\w+)?)\),.+?Version (?<version>[^,\s]+)/', $sysDescr, $matches)) {
|
||||
// Cisco IOS Software, Catalyst 4500 L3 Switch Software (cat4500e-ENTSERVICESK9-M), Version 15.2(1)E3, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2014 by Cisco Systems, Inc. Compiled Mon 05-May-14 07:56 b
|
||||
// Cisco IOS Software, IOS-XE Software (PPC_LINUX_IOSD-IPBASEK9-M), Version 15.2(2)S, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2012 by Cisco Systems, Inc. Compiled Mon 26-Mar-12 15:23 by mcpre
|
||||
// Cisco IOS Software, IES Software (IES-LANBASEK9-M), Version 12.2(52)SE1, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2010 by Cisco Systems, Inc. Compiled Tue 09-Feb-10 03:17 by prod_rel_team
|
||||
// Cisco IOS Software [Gibraltar], Catalyst L3 Switch Software (CAT9K_IOSXE), Version 16.11.1, RELEASE SOFTWARE (fc3) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2019 by Cisco Systems, Inc. Compiled Thu 28-Mar-19 09:42 by mcpre
|
||||
// Cisco IOS Software [Fuji], Catalyst L3 Switch Software (CAT9K_IOSXE), Version 16.8.1a, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2018 by Cisco Systems, Inc. Compiled Tue 03-Apr-18 18:49 by mcpre
|
||||
// Cisco IOS Software [Amsterdam], C9800 Software (C9800_IOSXE-K9), Version 17.3.5a, RELEASE SOFTWARE (fc2) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2022 by Cisco Systems, Inc. Compiled Mon 28-Feb-22 19:09 by mcpre
|
||||
|
||||
$features = $matches['features'];
|
||||
$version = $matches['version'];
|
||||
}
|
||||
elseif (preg_match('/Software, Version (?<version>\d[\d\.\(\)]+)/', $sysDescr, $matches))
|
||||
{
|
||||
//Cisco Systems WS-C6509-E Cisco Catalyst Operating System Software, Version 8.4(3) Copyright (c) 1995-2005 by Cisco Systems
|
||||
//Cisco Systems, Inc. WS-C2948 Cisco Catalyst Operating System Software, Version 4.5(9) Copyright (c) 1995-2000 by Cisco Systems, Inc.
|
||||
//Cisco Systems, Inc. WS-C2948G-GE-TX Cisco Catalyst Operating System Software, Version 8.4(5)GLX Copyright (c) 1995-2005 by Cisco Systems, Inc.
|
||||
//Cisco Systems, Inc. WS-C4912 Cisco Catalyst Operating System Software, Version 7.2(2) Copyright (c) 1995-2002 by Cisco Systems, Inc.
|
||||
} elseif (preg_match('/^Cisco Internetwork Operating System Software IOS \(tm\) [^ ]+ Software \([^\-]+\-(?<features>\w+)\-\w\),.+?Version (?<version>[^, ]+)/', $sysDescr, $matches)) {
|
||||
// Cisco Internetwork Operating System Software IOS (tm) 7200 Software (UBR7200-IK8SU2-M), Version 12.3(17b)BC8, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2007 by cisco Systems, Inc. Compiled Fri 29-Ju
|
||||
// Cisco Internetwork Operating System Software IOS (tm) C1700 Software (C1700-Y-M), Version 12.2(4)YA2, EARLY DEPLOYMENT RELEASE SOFTWARE (fc1) Synched to technology version 12.2(5.4)T TAC Support: http://www.cisco.com/tac Copyright (c) 1986-2002 by ci
|
||||
|
||||
$features = $matches['features'];
|
||||
$version = $matches['version'];
|
||||
} elseif (preg_match('/^Cisco IOS XR Software \(Cisco (?<hardware>[^\)]+)\), Version (?<version>[^\[]+)\[(?<features>[^\]]+)\]/', $sysDescr, $matches)) {
|
||||
// Cisco IOS XR Software (Cisco 12816/PRP), Version 4.3.2[Default] Copyright (c) 2014 by Cisco Systems, Inc.
|
||||
// Cisco IOS XR Software (Cisco 12404/PRP), Version 3.6.0[00] Copyright (c) 2007 by Cisco Systems, Inc.
|
||||
// Cisco IOS XR Software (Cisco ASR9K Series), Version 5.1.2[Default] Copyright (c) 2014 by Cisco Systems, Inc.
|
||||
|
||||
//$hardware = $matches['hardware'];
|
||||
$features = $matches['features'];
|
||||
$version = $matches['version'];
|
||||
} elseif (preg_match('/^Cisco NX-OS(?:\(tm\))? (?<hw1>\S+?)( (?<hardware>[\w\-]+) chassis)?, Software \((?<hw2>.+?)\),.+?Version (?<version>[^, ]+)/', $sysDescr, $matches)) {
|
||||
// Cisco NX-OS(tm) n7000, Software (n7000-s2-dk9), Version 6.2(8b), RELEASE SOFTWARE Copyright (c) 2002-2013 by Cisco Systems, Inc.
|
||||
// Cisco NX-OS(tm) n1000v, Software (n1000v-dk9), Version 5.2(1)SV3(1.2), RELEASE SOFTWARE Copyright (c) 2002-2011 by Cisco Systems, Inc. Device Manager Version nms.sro not found, Compiled 11/11/2014 15:00:00
|
||||
// Cisco NX-OS(tm) n5000, Software (n5000-uk9), Version 6.0(2)N2(7), RELEASE SOFTWARE Copyright (c) 2002-2012 by Cisco Systems, Inc. Device Manager Version 6.2(1), Compiled 4/28/2015 5:00:00
|
||||
// Cisco NX-OS(tm) n7000, Software (n7000-s2-dk9), Version 6.2(8a), RELEASE SOFTWARE Copyright (c) 2002-2013 by Cisco Systems, Inc. Compiled 5/15/2014 20:00:00
|
||||
// Cisco NX-OS(tm) n3000, Software (n3000-uk9), Version 6.0(2)U2(2), RELEASE SOFTWARE Copyright (c) 2002-2012 by Cisco Systems, Inc. Device Manager Version nms.sro not found, Compiled 2/12/2014 8:00:00
|
||||
// Cisco NX-OS(tm) ucs, Software (ucs-6100-k9-system), Version 5.0(3)N2(3.13a), RELEASE SOFTWARE Copyright (c) 2002-2013 by Cisco Systems, Inc. Compiled 4/25/2017 7:00:00
|
||||
// Cisco NX-OS(tm) aci, Software (aci-n9000-system), Version 12.0(1q), RELEASE SOFTWARE Copyright (c) 2002-2015 by Cisco Systems, Inc. Compiled 2016/08/18 14:20:16
|
||||
// Cisco NX-OS(tm) nxos.9.2.3.bin, Software (nxos), Version 9.2(3), RELEASE SOFTWARE Copyright (c) 2002-2019 by Cisco Systems, Inc. Compiled 2/17/2019 4:00:00
|
||||
// Cisco NX-OS n6000, Software (n6000-uk9), Version 7.3(2)N1(1), RELEASE SOFTWARE Copyright (c) 2002-2012, 2016-2017 by Cisco Systems, Inc. Device Manager Version 6.0(2)N1(1),Compiled 5/12/2017 23:00:00
|
||||
// Cisco NX-OS(tm) Nexus9000 C93180YC-EX chassis, Software (NXOS 32-bit), Version 9.3(9), RELEASE SOFTWARE Copyright (c) 2002-2022 by Cisco Systems, Inc. Compiled 2/4/2022 7:00:00
|
||||
|
||||
if (str_contains($matches['hw2'], ' ')) {
|
||||
// NXOS 32-bit -> 32-bit
|
||||
list(, $features) = explode(' ', $matches['hw2'], 2);
|
||||
} elseif (str_contains($matches['hw2'], '-')) {
|
||||
// n7000-s2-dk9 -> s2-dk9
|
||||
list(, $features) = explode('-', $matches['hw2'], 2);
|
||||
}
|
||||
$version = $matches['version'];
|
||||
} elseif (preg_match('/Software \(\w+-(?<features>\w+)-\w\),.+?Version (?<version>[^, ]+),(?:[\w ]+)? RELEASE SOFTWARE/', $sysDescr, $matches)) {
|
||||
// C800 Software (C800-UNIVERSALK9-M), Version 15.2(2)T2, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Compiled Thu 02-Aug-12 02:09 by prod_rel_team
|
||||
// Cisco IOS Software, Catalyst 4500 L3 Switch Software (cat4500e-ENTSERVICESK9-M), Version 15.2(1)E3, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2014 by Cisco Systems, Inc. Compiled Mon 05-May-14 07:56 b
|
||||
// Cisco IOS Software, ASR900 Software (PPC_LINUX_IOSD-UNIVERSALK9_NPE-M), Version 15.5(1)S, RELEASE SOFTWARE (fc5) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2014 by Cisco Systems, Inc. Compiled Thu 20-Nov-14 18:16 by mcpre
|
||||
// Cisco IOS Software, IOS-XE Software (PPC_LINUX_IOSD-IPBASEK9-M), Version 15.2(2)S, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2012 by Cisco Systems, Inc. Compiled Mon 26-Mar-12 15:23 by mcpre
|
||||
// Cisco IOS Software, IES Software (IES-LANBASEK9-M), Version 12.2(52)SE1, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2010 by Cisco Systems, Inc. Compiled Tue 09-Feb-10 03:17 by prod_rel_team
|
||||
|
||||
// Cisco Internetwork Operating System Software IOS (tm) 7200 Software (UBR7200-IK8SU2-M), Version 12.3(17b)BC8, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2007 by cisco Systems, Inc. Compiled Fri 29-Ju
|
||||
// Cisco Internetwork Operating System Software IOS (tm) C1700 Software (C1700-Y-M), Version 12.2(4)YA2, EARLY DEPLOYMENT RELEASE SOFTWARE (fc1) Synched to technology version 12.2(5.4)T TAC Support: http://www.cisco.com/tac Copyright (c) 1986-2002 by ci
|
||||
|
||||
$features = $matches['features'];
|
||||
$version = $matches['version'];
|
||||
} elseif (preg_match('/Software( \([\w\- ]+\))?, Version (?<version>\d[\w\.\(\)]+)/', $sysDescr, $matches)) {
|
||||
// Cisco Systems WS-C6509-E Cisco Catalyst Operating System Software, Version 8.4(3) Copyright (c) 1995-2005 by Cisco Systems
|
||||
// Cisco Systems, Inc. WS-C2948 Cisco Catalyst Operating System Software, Version 4.5(9) Copyright (c) 1995-2000 by Cisco Systems, Inc.
|
||||
// Cisco Systems, Inc. WS-C2948G-GE-TX Cisco Catalyst Operating System Software, Version 8.4(5)GLX Copyright (c) 1995-2005 by Cisco Systems, Inc.
|
||||
// Cisco Systems, Inc. WS-C4912 Cisco Catalyst Operating System Software, Version 7.2(2) Copyright (c) 1995-2002 by Cisco Systems, Inc.
|
||||
|
||||
//$features = $matches['features'];
|
||||
$version = $matches['version'];
|
||||
}
|
||||
|
||||
// All other Cisco devices
|
||||
if (is_array($entPhysical))
|
||||
{
|
||||
if (is_module_enabled($device, 'inventory', 'discovery'))
|
||||
{
|
||||
if ($entPhysical['entPhysicalClass'] === 'stack')
|
||||
{
|
||||
if (is_array($entPhysical)) {
|
||||
if (is_module_enabled($device, 'inventory', 'discovery')) {
|
||||
if ($entPhysical['entPhysicalClass'] === 'stack') {
|
||||
// If it's stacked device try get chassis instead
|
||||
$chassis = dbFetchRow('SELECT * FROM `entPhysical` WHERE `device_id` = ? AND `entPhysicalClass` = ? AND `entPhysicalContainedIn` = ? AND `deleted` IS NULL', array($device['device_id'], 'chassis', '1'));
|
||||
if ($chassis['entPhysicalModelName'])
|
||||
{
|
||||
if ($chassis['entPhysicalModelName']) {
|
||||
$entPhysical = $chassis;
|
||||
}
|
||||
}
|
||||
elseif (empty($entPhysical['entPhysicalModelName']) || $entPhysical['entPhysicalModelName'] === 'MIDPLANE')
|
||||
{
|
||||
} elseif ($entPhysical['entPhysicalModelName'] === 'MIDPLANE' || safe_empty($entPhysical['entPhysicalModelName'])) {
|
||||
// F.u. Cisco.. for some platforms (4948/4900M) they store correct model and version not in chassis
|
||||
$hw_module = dbFetchRow('SELECT * FROM `entPhysical` WHERE `device_id` = ? AND `entPhysicalClass` = ? AND `entPhysicalContainedIn` = ? AND `deleted` IS NULL', array($device['device_id'], 'module', '2'));
|
||||
if ($hw_module['entPhysicalModelName'])
|
||||
{
|
||||
if ($hw_module['entPhysicalModelName']) {
|
||||
$entPhysical = $hw_module;
|
||||
}
|
||||
}
|
||||
elseif (empty($entPhysical['entPhysicalSoftwareRev']))
|
||||
{
|
||||
} elseif (safe_empty($entPhysical['entPhysicalSoftwareRev'])) {
|
||||
// 720X, try again get correct serial/version
|
||||
$hw_module = dbFetchRow('SELECT * FROM `entPhysical` WHERE `device_id` = ? AND `entPhysicalClass` = ? AND `entPhysicalContainedIn` = ? AND `entPhysicalSerialNum` != ? AND `deleted` IS NULL', array($device['device_id'], 'module', '1', ''));
|
||||
if ($hw_module['entPhysicalSoftwareRev'])
|
||||
{
|
||||
if ($device['os'] === 'iosxe')
|
||||
{
|
||||
if ($hw_module['entPhysicalSoftwareRev']) {
|
||||
if ($device['os'] === 'iosxe') {
|
||||
// For IOS-XE fix only version
|
||||
$entPhysical['entPhysicalSoftwareRev'] = $hw_module['entPhysicalSoftwareRev'];
|
||||
} else {
|
||||
@ -147,14 +136,11 @@ if (is_array($entPhysical))
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array($entPhysical['entPhysicalContainedIn'], [ '0', '1', '2' ]) || $entPhysical['entPhysicalClass'] === 'chassis')
|
||||
{
|
||||
if ((empty($version) || $device['os'] === 'iosxe') && !empty($entPhysical['entPhysicalSoftwareRev']))
|
||||
{
|
||||
if ($entPhysical['entPhysicalClass'] === 'chassis' || in_array($entPhysical['entPhysicalContainedIn'], [ '0', '1', '2' ])) {
|
||||
if ((safe_empty($version) || $device['os'] === 'iosxe') && !empty($entPhysical['entPhysicalSoftwareRev'])) {
|
||||
$version = $entPhysical['entPhysicalSoftwareRev'];
|
||||
}
|
||||
if (!empty($entPhysical['entPhysicalModelName']))
|
||||
{
|
||||
if (!empty($entPhysical['entPhysicalModelName'])) {
|
||||
if (preg_match('/ (rev|dev)/', $entPhysical['entPhysicalModelName']) || // entPhysicalModelName = "73-7036-1 rev 80 dev 0"
|
||||
preg_match('/^\.+$/', $entPhysical['entPhysicalModelName'])) // entPhysicalModelName = "..."
|
||||
{
|
||||
@ -167,8 +153,7 @@ if (is_array($entPhysical))
|
||||
} else {
|
||||
$hardware = str_replace(' chassis', '', $entPhysical['entPhysicalName']);
|
||||
}
|
||||
if (!empty($entPhysical['entPhysicalSerialNum']))
|
||||
{
|
||||
if (!empty($entPhysical['entPhysicalSerialNum'])) {
|
||||
$serial = $entPhysical['entPhysicalSerialNum'];
|
||||
}
|
||||
}
|
||||
@ -182,20 +167,17 @@ if (is_array($entPhysical))
|
||||
// entPhysicalModelName: WS-C2960-48TC-S
|
||||
// sysObjectID [.1.3.6.1.4.1.9.1.1208]: cat29xxStack
|
||||
// entPhysicalModelName: WS-C2960S-F48TS-L
|
||||
if (empty($hardware) && $poll_device['sysObjectID'])
|
||||
{
|
||||
if (empty($hardware) && $poll_device['sysObjectID']) {
|
||||
// Try translate instead duplicate get sysObjectID
|
||||
$hardware = snmp_translate($poll_device['sysObjectID'], 'SNMPv2-MIB:CISCO-PRODUCTS-MIB:CISCO-ENTITY-VENDORTYPE-OID-MIB');
|
||||
}
|
||||
if (empty($hardware))
|
||||
{
|
||||
if (empty($hardware)) {
|
||||
// If translate false, try get sysObjectID again
|
||||
$hardware = snmp_get_oid($device, 'sysObjectID.0', 'SNMPv2-MIB:CISCO-PRODUCTS-MIB:CISCO-ENTITY-VENDORTYPE-OID-MIB');
|
||||
}
|
||||
|
||||
// Some cisco specific hardware rewrites
|
||||
if ($hardware)
|
||||
{
|
||||
if ($hardware) {
|
||||
$cisco_replace = [
|
||||
'/^[Cc]isco\s*(\d)/' => '\1', // Cisco 7604 -> 7604
|
||||
'/^cisco([a-z])/i' => '\1', // ciscoASR9010 -> ASR9010
|
||||
|
@ -1,34 +1,52 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @package observium
|
||||
* @subpackage poller
|
||||
* @copyright (C) 2006-2015 Adam Armstrong
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
# PowerWalker/BlueWalker UPS (Tested with BlueWalked VFI 2000 LCD (EPPC-MIB) sysDescr.0 = STRING: Network Management Card for UPS
|
||||
if (str_contains($poll_device['sysDescr'], 'Network Management Card for UPS')) {
|
||||
// EPPC-MIB::upsEIdentityManufacturer.0 = STRING: EPPC
|
||||
// EPPC-MIB::upsEIdentityModel.0 = STRING: ON-LINE
|
||||
// EPPC-MIB::upsEIdentityUPSFirmwareVerison.0 = STRING: 06.00
|
||||
// EPPC-MIB::upsEIndentityUPSSerialNumber.0 = STRING:
|
||||
// EPPC-MIB::upsEIdentityDescription.0 = STRING:
|
||||
// EPPC-MIB::upsEIdentityAgentSoftwareVerison.0 = STRING: 3.0.0.2
|
||||
// EPPC-MIB::upsEIdentityAttachedDevices.0 = STRING:
|
||||
if ($data = snmp_get_multi_oid($device, 'upsEIdentityManufacturer.0 upsESystemConfigOutputVA.0 upsEIdentityModel.0', [], 'EPPC-MIB')) {
|
||||
if ($data[0]['upsEIdentityManufacturer'] === 'EPPC') {
|
||||
// FIXME. Not sure, see: https://jira.observium.org/browse/OBS-4314
|
||||
$vendor = 'Eaton';
|
||||
//} elseif ($data[0]['upsEIdentityManufacturer']) {
|
||||
// $vendor = $data[0]['upsEIdentityManufacturer'];
|
||||
} else {
|
||||
$vendor = 'PowerWalker';
|
||||
}
|
||||
|
||||
if ($poll_device['sysObjectID'] == '.1.3.6.1.4.1.935.10.1') // BlueWalker
|
||||
{
|
||||
if ($poll_device['sysDescr'] == 'Network Management Card for UPS')
|
||||
{
|
||||
$hardware = snmp_get($device, 'upsEIdentityManufacturer.0', '-OQv', 'EPPC-MIB') . ' (' .
|
||||
snmp_get($device, 'upsESystemConfigOutputVA.0', '-OQv', 'EPPC-MIB') . 'VA ' . snmp_get($device, 'upsEIdentityModel.0', '-OQv', 'EPPC-MIB') . ')';
|
||||
$upsEIdentityDescription = snmp_get($device, 'upsEIdentityDescription.0', '-OQv', 'EPPC-MIB');
|
||||
$version = $upsEIdentityDescription + ' UPS: ' .
|
||||
snmp_get($device, 'upsEIdentityUPSFirmwareVerison.0', '-OQv', 'EPPC-MIB') . ' Firmware: ' . snmp_get($device, 'upsIdentAgentSoftwareVersion.0', '-OQv', 'EPPC-MIB');
|
||||
$status = snmp_get($device, 'upsESystemStatus.0', '-OQv', 'EPPC-MIB') . ' ' . snmp_get($device, 'upsEBatteryTestResult.0', '-OQv', 'EPPC-MIB');
|
||||
$hardware = $data[0]['upsEIdentityModel'];
|
||||
if ($data[0]['upsESystemConfigOutputVA'] > 0) {
|
||||
$hardware .= '('.$data[0]['upsESystemConfigOutputVA'].'VA)';
|
||||
}
|
||||
|
||||
$features = 'Status: ' . strtoupper($status);
|
||||
}
|
||||
else {
|
||||
$hardware = 'EPPC - Unknown NMC Card';
|
||||
|
||||
if ($data = snmp_get_multi_oid($device, 'upsEIdentityDescription.0 upsEIdentityUPSFirmwareVerison.0 upsIdentAgentSoftwareVersion.0', [], 'EPPC-MIB')) {
|
||||
$version = $data[0]['upsEIdentityDescription'] . ' UPS: ' .
|
||||
$data[0]['upsEIdentityUPSFirmwareVerison'] . ' Firmware: ' . $data[0]['upsIdentAgentSoftwareVersion'];
|
||||
|
||||
}
|
||||
|
||||
//if ($data = snmp_get_multi_oid($device, 'upsESystemStatus.0 upsEBatteryTestResult.0', [], 'EPPC-MIB')) {
|
||||
// $features = 'Status: ' . strtoupper($data[0]['upsESystemStatus'] . ' ' . $data[0]['upsEBatteryTestResult']);
|
||||
//}
|
||||
} else {
|
||||
$hardware = 'EPPC - Unknown NMC Card';
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
@ -7,18 +6,19 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage poller
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
if (!$hardware)
|
||||
{
|
||||
$hardware = rewrite_definition_hardware($device, $poll_device['sysObjectID']);
|
||||
if ($fn_hw = rewrite_definition_hardware($device, $poll_device['sysObjectID'])) {
|
||||
// Prefer defined hardware
|
||||
$hardware = $fn_hw;
|
||||
$fn_type = rewrite_definition_type($device, $poll_device['sysObjectID']);
|
||||
if (!empty($fn_type))
|
||||
{
|
||||
if (!empty($fn_type)) {
|
||||
$type = $fn_type;
|
||||
}
|
||||
} elseif (str_contains($hardware, 'WiFi')) {
|
||||
$type = 'wireless';
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
@ -6,22 +6,20 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage poller
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
switch ($device['os']) {
|
||||
case 'aix':
|
||||
list($hardware,,$os_detail,) = explode("\n", $poll_device['sysDescr']);
|
||||
if (preg_match('/: 0*(\d+\.)0*(\d+\.)0*(\d+\.)(\d+)/', $os_detail, $matches))
|
||||
{
|
||||
if (preg_match('/: 0*(\d+\.)0*(\d+\.)0*(\d+\.)(\d+)/', $os_detail, $matches)) {
|
||||
// Base Operating System Runtime AIX version: 05.03.0012.0001
|
||||
$version = $matches[1] . $matches[2] . $matches[3] . $matches[4];
|
||||
}
|
||||
|
||||
$hardware_model = snmp_get_oid($device, 'aixSeMachineType.0', 'IBM-AIX-MIB');
|
||||
if ($hardware_model)
|
||||
{
|
||||
if ($hardware_model) {
|
||||
list(,$hardware_model) = explode(',', $hardware_model);
|
||||
|
||||
$serial = snmp_get_oid($device, 'aixSeSerialNumber.0', 'IBM-AIX-MIB');
|
||||
@ -32,8 +30,9 @@ switch ($device['os']) {
|
||||
break;
|
||||
|
||||
case 'freebsd':
|
||||
preg_match('/FreeBSD ([\d\.]+\-[\w\-]+)/i', $poll_device['sysDescr'], $matches);
|
||||
$kernel = $matches[1];
|
||||
if (preg_match('/FreeBSD ([\d\.]+\-[\w\-]+)/i', $poll_device['sysDescr'], $matches)) {
|
||||
$kernel = $matches[1];
|
||||
}
|
||||
$hardware = rewrite_unix_hardware($poll_device['sysDescr']);
|
||||
break;
|
||||
|
||||
@ -58,7 +57,9 @@ switch ($device['os']) {
|
||||
|
||||
case 'monowall':
|
||||
case 'pfsense':
|
||||
list(,,$version,,, $kernel) = explode(' ', $poll_device['sysDescr']);
|
||||
if (safe_empty($kernel)) {
|
||||
list(, , $version, , , $kernel) = explode(' ', $poll_device['sysDescr']);
|
||||
}
|
||||
$distro = $device['os'];
|
||||
$hardware = rewrite_unix_hardware($poll_device['sysDescr']);
|
||||
break;
|
||||
@ -103,8 +104,7 @@ switch ($device['os']) {
|
||||
case 'ipso':
|
||||
// IPSO Bastion-1 6.2-GA039 releng 1 04.14.2010-225515 i386
|
||||
// IP530 rev 00, IPSO ruby.infinity-insurance.com 3.9-BUILD035 releng 1515 05.24.2005-013334 i386
|
||||
if (preg_match('/IPSO [^ ]+ ([^ ]+) /', $poll_device['sysDescr'], $matches))
|
||||
{
|
||||
if (preg_match('/IPSO [^ ]+ ([^ ]+) /', $poll_device['sysDescr'], $matches)) {
|
||||
$version = $matches[1];
|
||||
}
|
||||
|
||||
@ -121,8 +121,7 @@ switch ($device['os']) {
|
||||
// EMBEDDED-NGX-MIB::swLicenseProductName.0 = "Safe@Office 500, 25 nodes"
|
||||
// EMBEDDED-NGX-MIB::swFirmwareRunning.0 = "8.2.26x"
|
||||
$data = snmp_get_multi_oid($device, 'swHardwareVersion.0 swHardwareType.0 swLicenseProductName.0 swFirmwareRunning.0', array(), 'EMBEDDED-NGX-MIB');
|
||||
if (isset($data[0]))
|
||||
{
|
||||
if (isset($data[0])) {
|
||||
list($hw) = explode(',', $data[0]['swLicenseProductName']);
|
||||
$hardware = $hw . ' ' . $data[0]['swHardwareType'] . ' ' . $data[0]['swHardwareVersion'];
|
||||
$version = $data[0]['swFirmwareRunning'];
|
||||
@ -153,18 +152,13 @@ switch ($device['os']) {
|
||||
// zur: 3 first letter from the location / city name
|
||||
// acc: optional or sub-segment, like dns and mep
|
||||
// 1: Device number in the same clusters for High availability
|
||||
if (preg_match('/^Linux\ +\w+\-(?<hw>(?<hw1>[a-z]+)0*\d+)\-\w+\-\w+\-(?:(?<hw2>\w+)\-)?\d+/', $poll_device['sysDescr'], $matches))
|
||||
{
|
||||
switch ($matches['hw1'])
|
||||
{
|
||||
if (preg_match('/^Linux\ +\w+\-(?<hw>(?<hw1>[a-z]+)0*\d+)\-\w+\-\w+\-(?:(?<hw2>\w+)\-)?\d+/', $poll_device['sysDescr'], $matches)) {
|
||||
switch ($matches['hw1']) {
|
||||
case 'sg':
|
||||
if (isset($matches['hw2']) && $matches['hw2'] === 'dns')
|
||||
{
|
||||
if (isset($matches['hw2']) && $matches['hw2'] === 'dns') {
|
||||
$hw = 'DNS Server';
|
||||
$type = 'server';
|
||||
}
|
||||
elseif (isset($matches['hw2']) && $matches['hw2'] === 'mep')
|
||||
{
|
||||
} elseif (isset($matches['hw2']) && $matches['hw2'] === 'mep') {
|
||||
$hw = 'Mobile Entry Point';
|
||||
$type = 'network';
|
||||
} else {
|
||||
@ -240,14 +234,18 @@ switch ($device['os']) {
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($hw))
|
||||
{
|
||||
if (empty($hw)) {
|
||||
$hw = 'OSAG Hardware';
|
||||
}
|
||||
//$hardware = $hw . ' (' . strtoupper($matches['hw']) . ')';
|
||||
$hardware = rewrite_unix_hardware($poll_device['sysDescr'], $hw);
|
||||
break;
|
||||
|
||||
case 'unitrends-backup':
|
||||
// Prevent Distro/kernel/packages polling
|
||||
// But keep other unix group features
|
||||
return;
|
||||
|
||||
// case 'linux':
|
||||
// case 'endian':
|
||||
// case 'ddwrt':
|
||||
@ -345,148 +343,146 @@ if (isset($agent_data['distro']) && isset($agent_data['distro']['SCRIPTVER'])) {
|
||||
}
|
||||
|
||||
// Detect some distro by kernel strings
|
||||
if (!isset($distro) && $poll_device['sysObjectID'] === '.1.3.6.1.4.1.8072.3.2.10' &&
|
||||
str_starts($poll_device['sysDescr'], 'Linux ')) {
|
||||
// * Ubuntu (old):
|
||||
// Linux hostname 3.11.0-13-generic #20-Ubuntu SMP Wed Oct 23 07:38:26 UTC 2013 x86_64
|
||||
// * Ubuntu 16.04:
|
||||
// Linux hostname 4.4.0-77-generic #98-Ubuntu SMP Wed Apr 26 08:34:02 UTC 2017 x86_64
|
||||
// Linux hostname 4.4.0-201-generic #233-Ubuntu SMP Thu Jan 14 06:10:28 UTC 2021 x86_64
|
||||
// * Ubuntu 18.04:
|
||||
// Linux hostname 4.15.0-96-generic #97-Ubuntu SMP Wed Apr 1 03:25:46 UTC 2020 x86_64
|
||||
// Linux hostname 4.15.0-129-generic #132-Ubuntu SMP Thu Dec 10 14:02:26 UTC 2020 x86_64
|
||||
// * Ubuntu 20.04
|
||||
// Linux hostname 5.10.4-051004-generic #202012301142 SMP Wed Dec 30 11:44:55 UTC 2020 x86_64
|
||||
// Linux hostname 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 x86_64
|
||||
if (preg_match('/ \d[\.\d]+(\-\d+)?(\-[a-z]+)? #(\d+\-Ubuntu|\d{12}) /', $poll_device['sysDescr'])) {
|
||||
$distro = 'Ubuntu';
|
||||
}
|
||||
// * Debian 9
|
||||
// Linux hostname 4.9.0-6-amd64 #1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07) x86_64
|
||||
// Linux hostname 4.9.0-14-amd64 #1 SMP Debian 4.9.240-2 (2020-10-30) x86_64
|
||||
elseif (preg_match('/ Debian \d[\.\d]+(\-\d+)?([\+\-]\w+)? /', $poll_device['sysDescr'])) {
|
||||
$distro = 'Debian';
|
||||
}
|
||||
// * Proxmox (Debian)
|
||||
// Linux hostname 5.11.22-2-pve #1 SMP PVE 5.11.22-4 (Tue, 20 Jul 2021 21:40:02 +0200) x86_64
|
||||
// Linux hostname 5.4.78-2-pve #1 SMP PVE 5.4.78-2 (Thu, 03 Dec 2020 14:26:17 +0100) x86_64
|
||||
// Linux hostname 5.4.44-1-pve #1 SMP PVE 5.4.44-1 (Fri, 12 Jun 2020 08:18:46 +0200) x86_64
|
||||
// Linux hostname 5.0.21-5-pve #1 SMP PVE 5.0.21-10 (Wed, 13 Nov 2019 08:27:10 +0100) x86_64
|
||||
// Linux hostname 4.4.128-1-pve #1 SMP PVE 4.4.128-111 (Wed, 23 May 2018 14:00:02 +0000) x86_64
|
||||
// Linux hostname 4.4.8-1-pve #1 SMP Tue May 31 07:12:32 CEST 2016 x86_64
|
||||
elseif (preg_match('/\d\-pve | PVE /', $poll_device['sysDescr'])) {
|
||||
$distro = 'Debian';
|
||||
}
|
||||
// * Raspbian (Debian)
|
||||
// Linux hostname 5.10.17-v7+ #1403 SMP Mon Feb 22 11:29:51 GMT 2021 armv7l
|
||||
// Linux hostname 5.4.51-v7l+ #1333 SMP Mon Aug 10 16:51:40 BST 2020 armv7l
|
||||
// Linux hostname 4.19.66-v7+ #1253 SMP Thu Aug 15 11:49:46 BST 2019 armv7l
|
||||
// Linux hostname 4.14.43+ #1115 Fri May 25 13:54:20 BST 2018 armv6l
|
||||
// Linux hostname 4.9.35-v7+ #1014 SMP Fri Jun 30 14:47:43 BST 2017 armv7l
|
||||
// Linux hostname 3.12.33+ #724 PREEMPT Wed Nov 26 17:55:23 GMT 2014 armv6l
|
||||
elseif (preg_match('/ \d[\.\d]+(\-v\d+\w*)?\+ #\d+ .* arm/', $poll_device['sysDescr'])) {
|
||||
$distro = 'Raspbian';
|
||||
}
|
||||
// * Armbian (Ubuntu)
|
||||
// Linux hostname 5.10.60-sunxi #21.08.2 SMP Tue Sep 14 16:28:44 UTC 2021 armv7l
|
||||
elseif (preg_match('/^Linux \S+ \d\S+\d+(\-\w+)?\-sunxi #(?<distro_ver>\d+\.\d+(\.\d+)?) .* arm/', $poll_device['sysDescr'], $matches)) {
|
||||
$distro = 'Armbian';
|
||||
$distro_ver = $matches['distro_ver'];
|
||||
}
|
||||
// * Arch Linux
|
||||
// Linux hostname 2.6.37-ARCH #1 SMP PREEMPT Sat Jan 29 20:00:33 CET 2011 x86_64
|
||||
// Linux hostname 4.19.86-1-ARCH #1 SMP PREEMPT Sat Nov 30 18:56:30 UTC 2019 armv6l
|
||||
// Linux hostname 5.10.27-2-ARCH #1 SMP Fri Apr 9 21:08:37 UTC 2021 armv6l
|
||||
// Linux hostname 5.10.79-2-raspberrypi-ARCH #1 SMP Tue Nov 16 20:32:00 UTC 2021 armv6l GNU/Linux
|
||||
elseif (preg_match('/^Linux \S+ \d\S+\d+(\-\w+)?\-ARCH #\d/', $poll_device['sysDescr'])) {
|
||||
$distro = 'Arch Linux';
|
||||
}
|
||||
// * CentOS 5:
|
||||
// Linux hostname 2.6.18-274.12.1.el5 #1 SMP Tue Nov 29 13:37:46 EST 2011 x86_64
|
||||
// * OracleLinux 6:
|
||||
// Linux hostname 2.6.32-131.0.15.el6.x86_64 #1 SMP Fri May 20 15:04:03 EDT 2011 x86_64
|
||||
// * CentOS 7:
|
||||
// Linux hostname 3.10.0-327.4.5.el7.x86_64 #1 SMP Mon Jan 25 22:07:14 UTC 2016 x86_64
|
||||
// * RedHat EL:
|
||||
// Linux hostname 3.10.0-327.el7.x86_64 #1 SMP Thu Oct 29 17:29:29 EDT 2015 x86_64
|
||||
// Linux hostname 3.10.0-229.20.1.el7.x86_64 #1 SMP Thu Sep 24 12:23:56 EDT 2015 x86_64
|
||||
// Linux hostname 4.18.0-240.22.1.el8_3.x86_64 #1 SMP Thu Mar 25 14:36:04 EDT 2021 x86_64
|
||||
elseif (preg_match('/ \d[\.\d]+(\-\d+[\.\d]*\.el(?<distro_ver>\d+(_\d+)?))/', $poll_device['sysDescr'], $matches)) {
|
||||
// Detect distro by packages
|
||||
$distro_def = [
|
||||
// redhat-release-server-6Server-6.7.0.3.el6
|
||||
// redhat-release-8.3-1.0.el8
|
||||
[ 'name' => 'redhat-release', 'regex' => '/^redhat\-release[\-_](?<version>\d.*)/', 'distro' => 'RedHat',
|
||||
'transform' => [ [ 'action' => 'preg_replace', 'from' => '/^(\d+[\.\-]\d+).*/', 'to' => '$1' ],
|
||||
[ 'action' => 'replace', 'from' => '-', 'to' => '.' ] ] ],
|
||||
// centos-release-6-3.el6.centos.9
|
||||
// centos-release-6-9.el6.12.3
|
||||
// centos-release-7-6.1810.2.el7.centos
|
||||
[ 'name' => 'centos-release', 'regex' => '/^centos\-release[\-_](?<version>\d.*)/', 'distro' => 'CentOS',
|
||||
'transform' => [ [ 'action' => 'preg_replace', 'from' => '/^(\d+[\.\-]\d+).*/', 'to' => '$1' ],
|
||||
[ 'action' => 'replace', 'from' => '-', 'to' => '.' ] ] ],
|
||||
// rocky-release-8.5-3.el8
|
||||
[ 'name' => 'rocky-release', 'regex' => '/^rocky\-release[\-_](?<version>\d.*)/', 'distro' => 'Rocky',
|
||||
'transform' => [ [ 'action' => 'preg_replace', 'from' => '/^(\d+[\.\-]\d+).*/', 'to' => '$1' ],
|
||||
[ 'action' => 'replace', 'from' => '-', 'to' => '.' ] ] ],
|
||||
// oraclelinux-release-6Server-1.0.2
|
||||
// fixme. need more examples
|
||||
];
|
||||
$metatypes = [ 'distro', 'distro_ver' ];
|
||||
foreach (poll_device_unix_packages($device, $metatypes, $distro_def) as $metatype => $value) {
|
||||
$$metatype = $value;
|
||||
if (!isset($distro)) {
|
||||
if ($poll_device['sysObjectID'] === '.1.3.6.1.4.1.8072.3.2.10' && str_starts($poll_device['sysDescr'], 'Linux ')) {
|
||||
// * Ubuntu (old):
|
||||
// Linux hostname 3.11.0-13-generic #20-Ubuntu SMP Wed Oct 23 07:38:26 UTC 2013 x86_64
|
||||
// * Ubuntu 16.04:
|
||||
// Linux hostname 4.4.0-77-generic #98-Ubuntu SMP Wed Apr 26 08:34:02 UTC 2017 x86_64
|
||||
// Linux hostname 4.4.0-201-generic #233-Ubuntu SMP Thu Jan 14 06:10:28 UTC 2021 x86_64
|
||||
// * Ubuntu 18.04:
|
||||
// Linux hostname 4.15.0-96-generic #97-Ubuntu SMP Wed Apr 1 03:25:46 UTC 2020 x86_64
|
||||
// Linux hostname 4.15.0-129-generic #132-Ubuntu SMP Thu Dec 10 14:02:26 UTC 2020 x86_64
|
||||
// * Ubuntu 20.04
|
||||
// Linux hostname 5.10.4-051004-generic #202012301142 SMP Wed Dec 30 11:44:55 UTC 2020 x86_64
|
||||
// Linux hostname 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 x86_64
|
||||
if (preg_match('/ \d[\.\d]+(\-\d+)?(\-[a-z]+)? #(\d+\-Ubuntu|\d{12}) /', $poll_device['sysDescr'])) {
|
||||
$distro = 'Ubuntu';
|
||||
}
|
||||
if (safe_empty($distro)) {
|
||||
// there no way for split RedHat vs CentOS..
|
||||
//$distro = 'CentOS';
|
||||
$distro = 'RedHat'; // FIXME. no way for correctly detect redhat or centos, probably by packages?..
|
||||
$distro_ver = str_replace('_', '.', $matches['distro_ver']);
|
||||
// * Debian 9
|
||||
// Linux hostname 4.9.0-6-amd64 #1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07) x86_64
|
||||
// Linux hostname 4.9.0-14-amd64 #1 SMP Debian 4.9.240-2 (2020-10-30) x86_64
|
||||
elseif (preg_match('/ Debian \d[\.\d]+(\-\d+)?([\+\-]\w+)? /', $poll_device['sysDescr'])) {
|
||||
$distro = 'Debian';
|
||||
}
|
||||
// * Proxmox (Debian)
|
||||
// Linux hostname 5.11.22-2-pve #1 SMP PVE 5.11.22-4 (Tue, 20 Jul 2021 21:40:02 +0200) x86_64
|
||||
// Linux hostname 5.4.78-2-pve #1 SMP PVE 5.4.78-2 (Thu, 03 Dec 2020 14:26:17 +0100) x86_64
|
||||
// Linux hostname 5.4.44-1-pve #1 SMP PVE 5.4.44-1 (Fri, 12 Jun 2020 08:18:46 +0200) x86_64
|
||||
// Linux hostname 5.0.21-5-pve #1 SMP PVE 5.0.21-10 (Wed, 13 Nov 2019 08:27:10 +0100) x86_64
|
||||
// Linux hostname 4.4.128-1-pve #1 SMP PVE 4.4.128-111 (Wed, 23 May 2018 14:00:02 +0000) x86_64
|
||||
// Linux hostname 4.4.8-1-pve #1 SMP Tue May 31 07:12:32 CEST 2016 x86_64
|
||||
elseif (preg_match('/\d\-pve | PVE /', $poll_device['sysDescr'])) {
|
||||
$distro = 'Debian';
|
||||
}
|
||||
// * Raspbian (Debian)
|
||||
// Linux hostname 5.10.17-v7+ #1403 SMP Mon Feb 22 11:29:51 GMT 2021 armv7l
|
||||
// Linux hostname 5.4.51-v7l+ #1333 SMP Mon Aug 10 16:51:40 BST 2020 armv7l
|
||||
// Linux hostname 4.19.66-v7+ #1253 SMP Thu Aug 15 11:49:46 BST 2019 armv7l
|
||||
// Linux hostname 4.14.43+ #1115 Fri May 25 13:54:20 BST 2018 armv6l
|
||||
// Linux hostname 4.9.35-v7+ #1014 SMP Fri Jun 30 14:47:43 BST 2017 armv7l
|
||||
// Linux hostname 3.12.33+ #724 PREEMPT Wed Nov 26 17:55:23 GMT 2014 armv6l
|
||||
elseif (preg_match('/ \d[\.\d]+(\-v\d+\w*)?\+ #\d+ .* arm/', $poll_device['sysDescr'])) {
|
||||
$distro = 'Raspbian';
|
||||
}
|
||||
// * Armbian (Ubuntu)
|
||||
// Linux hostname 5.10.60-sunxi #21.08.2 SMP Tue Sep 14 16:28:44 UTC 2021 armv7l
|
||||
elseif (preg_match('/^Linux \S+ \d\S+\d+(\-\w+)?\-sunxi #(?<distro_ver>\d+\.\d+(\.\d+)?) .* arm/', $poll_device['sysDescr'], $matches)) {
|
||||
$distro = 'Armbian';
|
||||
$distro_ver = $matches['distro_ver'];
|
||||
}
|
||||
// * Arch Linux
|
||||
// Linux hostname 2.6.37-ARCH #1 SMP PREEMPT Sat Jan 29 20:00:33 CET 2011 x86_64
|
||||
// Linux hostname 4.19.86-1-ARCH #1 SMP PREEMPT Sat Nov 30 18:56:30 UTC 2019 armv6l
|
||||
// Linux hostname 5.10.27-2-ARCH #1 SMP Fri Apr 9 21:08:37 UTC 2021 armv6l
|
||||
// Linux hostname 5.10.79-2-raspberrypi-ARCH #1 SMP Tue Nov 16 20:32:00 UTC 2021 armv6l GNU/Linux
|
||||
elseif (preg_match('/^Linux \S+ \d\S+\d+(\-\w+)?\-ARCH #\d/', $poll_device['sysDescr'])) {
|
||||
$distro = 'Arch Linux';
|
||||
}
|
||||
// * CentOS 5:
|
||||
// Linux hostname 2.6.18-274.12.1.el5 #1 SMP Tue Nov 29 13:37:46 EST 2011 x86_64
|
||||
// * OracleLinux 6:
|
||||
// Linux hostname 2.6.32-131.0.15.el6.x86_64 #1 SMP Fri May 20 15:04:03 EDT 2011 x86_64
|
||||
// * CentOS 7:
|
||||
// Linux hostname 3.10.0-327.4.5.el7.x86_64 #1 SMP Mon Jan 25 22:07:14 UTC 2016 x86_64
|
||||
// * RedHat EL:
|
||||
// Linux hostname 3.10.0-327.el7.x86_64 #1 SMP Thu Oct 29 17:29:29 EDT 2015 x86_64
|
||||
// Linux hostname 3.10.0-229.20.1.el7.x86_64 #1 SMP Thu Sep 24 12:23:56 EDT 2015 x86_64
|
||||
// Linux hostname 4.18.0-240.22.1.el8_3.x86_64 #1 SMP Thu Mar 25 14:36:04 EDT 2021 x86_64
|
||||
elseif (preg_match('/ \d[\.\d]+(\-\d+[\.\d]*\.el(?<distro_ver>\d+(_\d+)?))/', $poll_device['sysDescr'], $matches)) {
|
||||
// Detect distro by packages
|
||||
$distro_def = [
|
||||
// redhat-release-server-6Server-6.7.0.3.el6
|
||||
// redhat-release-8.3-1.0.el8
|
||||
[ 'name' => 'redhat-release', 'regex' => '/^redhat\-release[\-_](?<version>\d.*)/', 'distro' => 'RedHat',
|
||||
'transform' => [ [ 'action' => 'preg_replace', 'from' => '/^(\d+[\.\-]\d+).*/', 'to' => '$1' ],
|
||||
[ 'action' => 'replace', 'from' => '-', 'to' => '.' ] ] ],
|
||||
// centos-release-6-3.el6.centos.9
|
||||
// centos-release-6-9.el6.12.3
|
||||
// centos-release-7-6.1810.2.el7.centos
|
||||
[ 'name' => 'centos-release', 'regex' => '/^centos\-release[\-_](?<version>\d.*)/', 'distro' => 'CentOS',
|
||||
'transform' => [ [ 'action' => 'preg_replace', 'from' => '/^(\d+[\.\-]\d+).*/', 'to' => '$1' ],
|
||||
[ 'action' => 'replace', 'from' => '-', 'to' => '.' ] ] ],
|
||||
// rocky-release-8.5-3.el8
|
||||
[ 'name' => 'rocky-release', 'regex' => '/^rocky\-release[\-_](?<version>\d.*)/', 'distro' => 'Rocky',
|
||||
'transform' => [ [ 'action' => 'preg_replace', 'from' => '/^(\d+[\.\-]\d+).*/', 'to' => '$1' ],
|
||||
[ 'action' => 'replace', 'from' => '-', 'to' => '.' ] ] ],
|
||||
// oraclelinux-release-6Server-1.0.2
|
||||
// fixme. need more examples
|
||||
];
|
||||
$metatypes = [ 'distro', 'distro_ver' ];
|
||||
foreach (poll_device_unix_packages($device, $metatypes, $distro_def) as $metatype => $value) {
|
||||
$$metatype = $value;
|
||||
}
|
||||
if (safe_empty($distro)) {
|
||||
// there no way for split RedHat vs CentOS..
|
||||
//$distro = 'CentOS';
|
||||
$distro = 'RedHat'; // FIXME. no way for correctly detect redhat or centos, probably by packages?..
|
||||
$distro_ver = str_replace('_', '.', $matches['distro_ver']);
|
||||
}
|
||||
}
|
||||
// * Slackware:
|
||||
// Linux hostname 2.6.21.5-smp #2 SMP Tue Jun 19 14:58:11 CDT 2007 i686
|
||||
} elseif ($poll_device['sysObjectID'] === '.1.3.6.1.4.1.8072.3.2.8' && str_starts($poll_device['sysDescr'], 'FreeBSD ')) {
|
||||
// * HardenedBSD
|
||||
if (preg_match('/\-HBSD /', $poll_device['sysDescr'], $matches)) {
|
||||
$distro = 'HardenedBSD';
|
||||
}
|
||||
}
|
||||
// * Slackware:
|
||||
// Linux hostname 2.6.21.5-smp #2 SMP Tue Jun 19 14:58:11 CDT 2007 i686
|
||||
if (isset($distro)) {
|
||||
print_debug("Linux Distro was set by sysDescr string.");
|
||||
}
|
||||
}
|
||||
|
||||
// Hardware/vendor "extend" support
|
||||
if (is_device_mib($device, 'UCD-SNMP-MIB'))
|
||||
{
|
||||
if (is_device_mib($device, 'UCD-SNMP-MIB')) {
|
||||
$hw = snmp_get_oid($device, '.1.3.6.1.4.1.2021.7890.2.3.1.1.8.104.97.114.100.119.97.114.101', 'UCD-SNMP-MIB');
|
||||
if (strlen($hw))
|
||||
{
|
||||
if (strlen($hw)) {
|
||||
$hardware = rewrite_unix_hardware($poll_device['sysDescr'], $hw);
|
||||
$vendor = snmp_get_oid($device, '.1.3.6.1.4.1.2021.7890.3.3.1.1.6.118.101.110.100.111.114', 'UCD-SNMP-MIB');
|
||||
if (!snmp_status())
|
||||
{
|
||||
if (!snmp_status()) {
|
||||
// Alternative with manufacturer
|
||||
$vendor = snmp_get_oid($device, '.1.3.6.1.4.1.2021.7890.3.3.1.1.12.109.97.110.117.102.97.99.116.117.114.101.114', 'UCD-SNMP-MIB');
|
||||
}
|
||||
$serial = snmp_get_oid($device, '.1.3.6.1.4.1.2021.7890.4.3.1.1.6.115.101.114.105.97.108', 'UCD-SNMP-MIB');
|
||||
//if (str_contains_array($serial, 'denied') || str_starts($serial, [ '0123456789', '..', 'Not Specified' ]))
|
||||
if (!is_valid_param($serial, 'serial'))
|
||||
{
|
||||
if (!is_valid_param($serial, 'serial')) {
|
||||
unset($serial);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Use 'os' script virt output, if virt-what agent is not used
|
||||
if (!isset($agent_data['virt']['what']) && isset($virt))
|
||||
{
|
||||
if (!isset($agent_data['virt']['what']) && isset($virt)) {
|
||||
$agent_data['virt']['what'] = $virt;
|
||||
}
|
||||
|
||||
// Use agent virt-what data if available
|
||||
if (isset($agent_data['virt']['what']))
|
||||
{
|
||||
if (isset($agent_data['virt']['what'])) {
|
||||
// We cycle through every line here, the previous one is overwritten.
|
||||
// This is OK, as virt-what prints general-to-specific order and we want most specific.
|
||||
foreach (explode("\n", $agent_data['virt']['what']) as $virtwhat)
|
||||
{
|
||||
if (isset($config['virt-what'][$virtwhat]))
|
||||
{
|
||||
foreach (explode("\n", $agent_data['virt']['what']) as $virtwhat) {
|
||||
if (isset($config['virt-what'][$virtwhat])) {
|
||||
//$hardware = $config['virt-what'][$virtwhat];
|
||||
$hardware = rewrite_unix_hardware($poll_device['sysDescr'], $config['virt-what'][$virtwhat]);
|
||||
$vendor = ''; // Always reset vendor for VMs, while this doesn't make sense
|
||||
@ -494,8 +490,7 @@ if (isset($agent_data['virt']['what']))
|
||||
}
|
||||
}
|
||||
|
||||
if (!$features && isset($distro))
|
||||
{
|
||||
if (!$features && isset($distro)) {
|
||||
$features = trim("$distro $distro_ver");
|
||||
}
|
||||
|
||||
|
27
includes/polling/os/wisi-tangram.inc.php
Normal file
27
includes/polling/os/wisi-tangram.inc.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage poller
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
// WISI-GTMODULES-MIB::gtThisModuleSlot.0 = 7
|
||||
|
||||
$gtThisModuleSlot = snmp_get_oid($device, 'gtThisModuleSlot.0', 'WISI-GTMODULES-MIB');
|
||||
|
||||
if (!safe_empty($gtThisModuleSlot)) {
|
||||
$data = snmp_get_multi_oid($device, [ 'gtModuleFWID.'.$gtThisModuleSlot, 'gtModuleSerNo.'.$gtThisModuleSlot, 'gtModuleName.'.$gtThisModuleSlot ], [], 'WISI-GTMODULES-MIB');
|
||||
|
||||
$version = $data[$gtThisModuleSlot]['gtModuleFWID'];
|
||||
$serial = $data[$gtThisModuleSlot]['gtModuleSerNo'];
|
||||
$hardware = $data[$gtThisModuleSlot]['gtModuleName'];
|
||||
}
|
||||
|
||||
unset($gtThisModuleSlot, $data);
|
||||
|
||||
// EOF
|
@ -6,404 +6,50 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage poller
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
/// FIXME. Rewrite (clean), clean stale entries (after disable)
|
||||
// Pre-polling checks
|
||||
if (!$config['enable_ospf'] || !is_device_mib($device, 'OSPF-MIB'))
|
||||
{
|
||||
// OSPF not enabled or MIB excluded
|
||||
if (!$config['enable_ospf']) {
|
||||
// OSPF not enabled
|
||||
return;
|
||||
}
|
||||
/*
|
||||
OSPF-MIB::ospfRouterId.0 = IpAddress: 1.185.1.113
|
||||
OSPF-MIB::ospfAdminStat.0 = INTEGER: enabled(1)
|
||||
OSPF-MIB::ospfVersionNumber.0 = INTEGER: version2(2)
|
||||
OSPF-MIB::ospfAreaBdrRtrStatus.0 = INTEGER: false(2)
|
||||
OSPF-MIB::ospfASBdrRtrStatus.0 = INTEGER: true(1)
|
||||
OSPF-MIB::ospfExternLsaCount.0 = Gauge32: 104
|
||||
OSPF-MIB::ospfExternLsaCksumSum.0 = INTEGER: 3322892
|
||||
OSPF-MIB::ospfTOSSupport.0 = INTEGER: false(2)
|
||||
OSPF-MIB::ospfOriginateNewLsas.0 = Counter32: 11993
|
||||
OSPF-MIB::ospfRxNewLsas.0 = Counter32: 553365
|
||||
OSPF-MIB::ospfExtLsdbLimit.0 = INTEGER: -1
|
||||
OSPF-MIB::ospfMulticastExtensions.0 = INTEGER: 0
|
||||
OSPF-MIB::ospfExitOverflowInterval.0 = INTEGER: 0
|
||||
OSPF-MIB::ospfDemandExtensions.0 = INTEGER: false(2)
|
||||
*/
|
||||
|
||||
$ospf_instance_count = 0;
|
||||
$ospf_port_count = 0;
|
||||
$ospf_area_count = 0;
|
||||
$ospf_nbr_count = 0;
|
||||
$ospf_stats = [
|
||||
'instances' => 0,
|
||||
'ports' => 0,
|
||||
'areas' => 0,
|
||||
'neighbours' => 0
|
||||
];
|
||||
|
||||
$set_ospf = FALSE;
|
||||
// This module not have discovery (only mibs discovery)
|
||||
$mib_exist = FALSE;
|
||||
foreach ([ 'OSPF-MIB', 'OSPFV3-MIB' ] as $mib) {
|
||||
if (is_device_mib($device, $mib)) {
|
||||
$ospf_enabled = FALSE; // TRUE, when ospf enabled
|
||||
|
||||
$ospf_oids_db = array('ospfRouterId', 'ospfAdminStat', 'ospfVersionNumber', 'ospfAreaBdrRtrStatus', 'ospfASBdrRtrStatus',
|
||||
'ospfExternLsaCount', 'ospfExternLsaCksumSum', 'ospfTOSSupport', 'ospfOriginateNewLsas', 'ospfRxNewLsas',
|
||||
'ospfExtLsdbLimit', 'ospfMulticastExtensions', 'ospfExitOverflowInterval', 'ospfDemandExtensions');
|
||||
|
||||
// Build array of existing entries
|
||||
$ospf_instance_db = dbFetchRow('SELECT * FROM `ospf_instances` WHERE `device_id` = ?', array($device['device_id']));
|
||||
|
||||
// Pull data from device
|
||||
$ospf_instance_poll = snmpwalk_cache_oid($device, 'ospfGeneralGroup', array(), 'OSPF-MIB');
|
||||
if (is_array($ospf_instance_poll[0]))
|
||||
{
|
||||
$ospf_instance_poll = $ospf_instance_poll[0];
|
||||
|
||||
// Don't bother polling everything if we have no enabled or non-defaulted router ids.
|
||||
if ($ospf_instance_poll['ospfRouterId'] != '0.0.0.0' ||
|
||||
$ospf_instance_poll['ospfAdminStat'] != 'disabled')
|
||||
{
|
||||
$set_ospf = TRUE;
|
||||
include $config['install_dir'] . '/includes/polling/ospf/'.strtolower($mib).'.inc.php';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$ospf_areas_poll = array();
|
||||
$ospf_ports_poll = array();
|
||||
$ospf_nbrs_poll = array();
|
||||
|
||||
if ($set_ospf)
|
||||
{
|
||||
$ospf_areas_poll = snmpwalk_cache_oid($device, 'ospfAreaEntry', $ospf_areas_poll, 'OSPF-MIB');
|
||||
$ospf_ports_poll = snmpwalk_cache_oid($device, 'ospfIfEntry', $ospf_ports_poll, 'OSPF-MIB');
|
||||
$ospf_nbrs_poll = snmpwalk_cache_oid($device, 'ospfNbrEntry', $ospf_nbrs_poll, 'OSPF-MIB');
|
||||
if (!$mib_exist) {
|
||||
// OSPF MIBs excluded
|
||||
unset($mib_exist, $ospf_enabled, $ospf_stats);
|
||||
return;
|
||||
}
|
||||
|
||||
print_cli_data_field('Processes', 2);
|
||||
// Create device-wide statistics RRD
|
||||
rrdtool_update_ng($device, 'ospf-statistics', [
|
||||
'instances' => $ospf_stats['instances'],
|
||||
'areas' => $ospf_stats['areas'],
|
||||
'ports' => $ospf_stats['ports'],
|
||||
'neighbours' => $ospf_stats['neighbours'],
|
||||
]);
|
||||
|
||||
if (empty($ospf_instance_db) && !empty($ospf_instance_poll))
|
||||
{
|
||||
dbInsert(array('device_id' => $device['device_id']), 'ospf_instances');
|
||||
$ospf_instance_db = dbFetchRow('SELECT * FROM `ospf_instances` WHERE `device_id` = ?', array($device['device_id']));
|
||||
echo('+');
|
||||
}
|
||||
else if (!empty($ospf_instance_db) && empty($ospf_instance_poll))
|
||||
{
|
||||
dbDelete('ospf_instances', '`device_id` = ?', array($device['device_id']));
|
||||
echo('-');
|
||||
}
|
||||
|
||||
if (OBS_DEBUG && $set_ospf)
|
||||
{
|
||||
echo("\nPolled: ");
|
||||
print_vars($ospf_instance_poll);
|
||||
echo('Database: ');
|
||||
print_vars($ospf_instance_db);
|
||||
echo("\n");
|
||||
}
|
||||
|
||||
// Loop array of entries and update
|
||||
if (is_array($ospf_instance_db))
|
||||
{
|
||||
$ospf_instance_id = $ospf_instance_db['ospf_instance_id'];
|
||||
$ospf_instance_update = array();
|
||||
foreach ($ospf_oids_db as $oid)
|
||||
{ // Loop the OIDs
|
||||
if ($ospf_instance_db[$oid] != $ospf_instance_poll[$oid])
|
||||
{ // If data has changed, build a query
|
||||
$ospf_instance_update[$oid] = $ospf_instance_poll[$oid];
|
||||
// log_event("$oid -> ".$this_port[$oid], $device, 'ospf', $port['port_id']); // FIXME
|
||||
}
|
||||
}
|
||||
|
||||
if ($ospf_instance_update)
|
||||
{
|
||||
dbUpdate($ospf_instance_update, 'ospf_instances', '`device_id` = ? AND `ospf_instance_id` = ?', array($device['device_id'], $ospf_instance_id));
|
||||
echo('U');
|
||||
unset($ospf_instance_update);
|
||||
} else {
|
||||
echo('.');
|
||||
}
|
||||
|
||||
$ospf_instance_count++; // Really in OSPF-MIB always only 1 instance (process)
|
||||
}
|
||||
|
||||
unset($ospf_instance_poll);
|
||||
unset($ospf_instance_db);
|
||||
|
||||
echo(PHP_EOL);
|
||||
|
||||
print_cli_data_field('Areas', 2);
|
||||
|
||||
$ospf_area_oids = array('ospfAuthType', 'ospfImportAsExtern', 'ospfSpfRuns', 'ospfAreaBdrRtrCount', 'ospfAsBdrRtrCount',
|
||||
'ospfAreaLsaCount', 'ospfAreaLsaCksumSum', 'ospfAreaSummary', 'ospfAreaStatus');
|
||||
|
||||
// Build array of existing entries
|
||||
foreach (dbFetchRows('SELECT * FROM `ospf_areas` WHERE `device_id` = ?', array($device['device_id'])) as $entry)
|
||||
{
|
||||
$ospf_areas_db[$entry['ospfAreaId']] = $entry;
|
||||
}
|
||||
|
||||
foreach ($ospf_areas_poll as $ospf_area_id => $ospf_area)
|
||||
{
|
||||
// If the entry doesn't already exist in the prebuilt array, insert into the database and put into the array
|
||||
if (!isset($ospf_areas_db[$ospf_area_id]))
|
||||
{
|
||||
$insert = array();
|
||||
$insert['device_id'] = $device['device_id'];
|
||||
$insert['ospfAreaId'] = $ospf_area_id;
|
||||
|
||||
foreach ($ospf_area_oids as $oid)
|
||||
{ // Loop the OIDs
|
||||
$insert[$oid] = $ospf_area[$oid];
|
||||
}
|
||||
|
||||
dbInsert($insert, 'ospf_areas');
|
||||
echo('+');
|
||||
$ospf_areas_db[$ospf_area_id] = dbFetchRow('SELECT * FROM `ospf_areas` WHERE `device_id` = ? AND `ospfAreaId` = ?', array($device['device_id'], $ospf_area_id));
|
||||
unset($insert);
|
||||
}
|
||||
}
|
||||
|
||||
if (OBS_DEBUG && $set_ospf)
|
||||
{
|
||||
echo("\nPolled: ");
|
||||
print_vars($ospf_areas_poll);
|
||||
echo('Database: ');
|
||||
print_vars($ospf_areas_db);
|
||||
echo("\n");
|
||||
}
|
||||
|
||||
// Loop array of entries and update
|
||||
if (is_array($ospf_areas_db))
|
||||
{
|
||||
foreach ($ospf_areas_db as $ospf_area_id => $ospf_area_db)
|
||||
{
|
||||
|
||||
if (is_array($ospf_areas_poll[$ospf_area_id]))
|
||||
{
|
||||
$ospf_area_poll = $ospf_areas_poll[$ospf_area_db['ospfAreaId']];
|
||||
foreach ($ospf_area_oids as $oid)
|
||||
{ // Loop the OIDs
|
||||
if ($ospf_area_db[$oid] != $ospf_area_poll[$oid])
|
||||
{ // If data has changed, build a query
|
||||
$ospf_area_update[$oid] = $ospf_area_poll[$oid];
|
||||
// log_event("$oid -> ".$this_port[$oid], $device, 'port', $port['port_id']); // FIXME
|
||||
} else {
|
||||
// echo($ospf_area_db[$oid] . '=' . $ospf_area_poll[$oid]);
|
||||
}
|
||||
}
|
||||
if ($ospf_area_update)
|
||||
{
|
||||
dbUpdate($ospf_area_update, 'ospf_areas', '`device_id` = ? AND `ospfAreaId` = ?', array($device['device_id'], $ospf_area_id));
|
||||
echo('U');
|
||||
unset($ospf_area_update);
|
||||
} else {
|
||||
echo('.');
|
||||
}
|
||||
|
||||
$ospf_area_count++;
|
||||
} else {
|
||||
dbDelete('ospf_areas', '`device_id` = ? AND `ospfAreaId` = ?', array($device['device_id'], $ospf_area_db['ospfAreaId']));
|
||||
echo '-';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($ospf_areas_db);
|
||||
unset($ospf_areas_poll);
|
||||
|
||||
echo PHP_EOL;
|
||||
|
||||
print_cli_data_field('Ports', 2);
|
||||
|
||||
$ospf_port_oids = array('ospfIfIpAddress','port_id','ospfAddressLessIf','ospfIfAreaId','ospfIfType','ospfIfAdminStat','ospfIfRtrPriority','ospfIfTransitDelay','ospfIfRetransInterval','ospfIfHelloInterval','ospfIfRtrDeadInterval','ospfIfPollInterval','ospfIfState','ospfIfDesignatedRouter','ospfIfBackupDesignatedRouter','ospfIfEvents','ospfIfAuthKey','ospfIfStatus','ospfIfMulticastForwarding','ospfIfDemand','ospfIfAuthType');
|
||||
|
||||
// Build array of existing entries
|
||||
foreach (dbFetchRows('SELECT * FROM `ospf_ports` WHERE `device_id` = ?', array($device['device_id'])) as $entry)
|
||||
{
|
||||
$ospf_ports_db[$entry['ospf_port_id']] = $entry;
|
||||
}
|
||||
|
||||
foreach ($ospf_ports_poll as $ospf_port_id => $ospf_port)
|
||||
{
|
||||
// If the entry doesn't already exist in the prebuilt array, insert into the database and put into the array
|
||||
if (!isset($ospf_ports_db[$ospf_port_id]))
|
||||
{
|
||||
dbInsert(array('device_id' => $device['device_id'], 'ospf_port_id' => $ospf_port_id), 'ospf_ports');
|
||||
echo('+');
|
||||
$ospf_ports_db[$entry['ospf_port_id']] = dbFetchRow('SELECT * FROM `ospf_ports` WHERE `device_id` = ? AND `ospf_port_id` = ?', array($device['device_id'], $ospf_port_id));
|
||||
}
|
||||
}
|
||||
|
||||
if (OBS_DEBUG && $set_ospf)
|
||||
{
|
||||
echo("\nPolled: ");
|
||||
print_vars($ospf_ports_poll);
|
||||
echo('Database: ');
|
||||
print_vars($ospf_ports_db);
|
||||
echo("\n");
|
||||
}
|
||||
|
||||
// Loop array of entries and update
|
||||
if (is_array($ospf_ports_db))
|
||||
{
|
||||
foreach ($ospf_ports_db as $ospf_port_id => $ospf_port_db)
|
||||
{
|
||||
if (is_array($ospf_ports_poll[$ospf_port_db['ospf_port_id']]))
|
||||
{
|
||||
$ospf_port_poll = $ospf_ports_poll[$ospf_port_db['ospf_port_id']];
|
||||
|
||||
if ($ospf_port_poll['ospfAddressLessIf']) {
|
||||
$ospf_port_poll['port_id'] = @dbFetchCell('SELECT `port_id` FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?', array($device['device_id'], $ospf_port_poll['ospfAddressLessIf']));
|
||||
} else {
|
||||
//$ospf_port_poll['port_id'] = @dbFetchCell('SELECT A.`port_id` FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND I.device_id = ?', array($ospf_port_poll['ospfIfIpAddress'], $device['device_id']));
|
||||
$ids = get_entity_ids_ip_by_network('port', $ospf_port_poll['ospfIfIpAddress'], generate_query_values($device['device_id'], 'device_id'));
|
||||
if (safe_count($ids)) {
|
||||
$ospf_port_poll['port_id'] = current($ids);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($ospf_port_oids as $oid)
|
||||
{ // Loop the OIDs
|
||||
if ($ospf_port_db[$oid] != $ospf_port_poll[$oid])
|
||||
{ // If data has changed, build a query
|
||||
$ospf_port_update[$oid] = $ospf_port_poll[$oid];
|
||||
// log_event("$oid -> ".$this_port[$oid], $device, 'ospf', $port['port_id']); // FIXME
|
||||
}
|
||||
}
|
||||
if ($ospf_port_update)
|
||||
{
|
||||
dbUpdate($ospf_port_update, 'ospf_ports', '`device_id` = ? AND `ospf_port_id` = ?', array($device['device_id'], $ospf_port_id));
|
||||
echo('U');
|
||||
unset($ospf_port_update);
|
||||
} else {
|
||||
echo('.');
|
||||
}
|
||||
unset($ospf_port_poll);
|
||||
unset($ospf_port_db);
|
||||
$ospf_port_count++;
|
||||
} else {
|
||||
dbDelete('ospf_ports', '`device_id` = ? AND `ospf_port_id` = ?', array($device['device_id'], $ospf_port_db['ospf_port_id']));
|
||||
echo('-');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo PHP_EOL;
|
||||
|
||||
// OSPF-MIB::ospfNbrIpAddr.172.22.203.98.0 172.22.203.98
|
||||
// OSPF-MIB::ospfNbrAddressLessIndex.172.22.203.98.0 0
|
||||
// OSPF-MIB::ospfNbrRtrId.172.22.203.98.0 172.22.203.128
|
||||
// OSPF-MIB::ospfNbrOptions.172.22.203.98.0 2
|
||||
// OSPF-MIB::ospfNbrPriority.172.22.203.98.0 0
|
||||
// OSPF-MIB::ospfNbrState.172.22.203.98.0 full
|
||||
// OSPF-MIB::ospfNbrEvents.172.22.203.98.0 6
|
||||
// OSPF-MIB::ospfNbrLsRetransQLen.172.22.203.98.0 1
|
||||
// OSPF-MIB::ospfNbmaNbrStatus.172.22.203.98.0 active
|
||||
// OSPF-MIB::ospfNbmaNbrPermanence.172.22.203.98.0 dynamic
|
||||
// OSPF-MIB::ospfNbrHelloSuppressed.172.22.203.98.0 false
|
||||
|
||||
print_cli_data_field('Neighbours',2);
|
||||
|
||||
$ospf_nbr_oids_db = array('ospfNbrIpAddr', 'ospfNbrAddressLessIndex', 'ospfNbrRtrId', 'ospfNbrOptions', 'ospfNbrPriority', 'ospfNbrState', 'ospfNbrEvents', 'ospfNbrLsRetransQLen', 'ospfNbmaNbrStatus', 'ospfNbmaNbrPermanence', 'ospfNbrHelloSuppressed');
|
||||
$ospf_nbr_oids_rrd = array();
|
||||
$ospf_nbr_oids = array_merge($ospf_nbr_oids_db, $ospf_nbr_oids_rrd);
|
||||
|
||||
// Build array of existing entries
|
||||
foreach (dbFetchRows('SELECT * FROM `ospf_nbrs` WHERE `device_id` = ?', array($device['device_id'])) as $nbr_entry)
|
||||
{
|
||||
$ospf_nbrs_db[$nbr_entry['ospf_nbr_id']] = $nbr_entry;
|
||||
}
|
||||
|
||||
foreach ($ospf_nbrs_poll as $ospf_nbr_id => $ospf_nbr)
|
||||
{
|
||||
// If the entry doesn't already exist in the prebuilt array, insert into the database and put into the array
|
||||
if (!isset($ospf_nbrs_db[$ospf_nbr_id]))
|
||||
{
|
||||
dbInsert(array('device_id' => $device['device_id'], 'ospf_nbr_id' => $ospf_nbr_id), 'ospf_nbrs');
|
||||
echo('+');
|
||||
$entry = dbFetchRow('SELECT * FROM `ospf_nbrs` WHERE `device_id` = ? AND `ospf_nbr_id` = ?', array($device['device_id'], $ospf_nbr_id));
|
||||
$ospf_nbrs_db[$entry['ospf_nbr_id']] = $entry;
|
||||
}
|
||||
}
|
||||
|
||||
if (OBS_DEBUG && $set_ospf)
|
||||
{
|
||||
echo("\nPolled: ");
|
||||
print_vars($ospf_nbrs_poll);
|
||||
echo('Database: ');
|
||||
print_vars($ospf_nbrs_db);
|
||||
echo("\n");
|
||||
}
|
||||
|
||||
// Loop array of entries and update
|
||||
if (is_array($ospf_nbrs_db))
|
||||
{
|
||||
foreach ($ospf_nbrs_db as $ospf_nbr_id => $ospf_nbr_db)
|
||||
{
|
||||
if (is_array($ospf_nbrs_poll[$ospf_nbr_db['ospf_nbr_id']]))
|
||||
{
|
||||
$ospf_nbr_poll = $ospf_nbrs_poll[$ospf_nbr_db['ospf_nbr_id']];
|
||||
|
||||
//$ospf_nbr_poll['port_id'] = @dbFetchCell('SELECT A.`port_id` FROM `ipv4_addresses` AS A, `ospf_nbrs` AS I WHERE A.`ipv4_address` = ? AND I.`port_id` = A.`port_id` AND I.`device_id` = ?', array($ospf_nbr_poll['ospfNbrIpAddr'], $device['device_id']));
|
||||
$ids = get_entity_ids_ip_by_network('port', $ospf_nbr_poll['ospfNbrIpAddr'], generate_query_values($device['device_id'], 'device_id'));
|
||||
if (safe_count($ids)) {
|
||||
$ospf_nbr_poll['port_id'] = current($ids);
|
||||
} else {
|
||||
$ospf_nbr_poll['port_id'] = NULL;
|
||||
}
|
||||
|
||||
if ($ospf_nbr_db['port_id'] != $ospf_nbr_poll['port_id']) {
|
||||
if ($ospf_nbr_poll['port_id']) {
|
||||
$ospf_nbr_update = array('port_id' => $ospf_nbr_poll['port_id']);
|
||||
} else {
|
||||
$ospf_nbr_update = array('port_id' => array('NULL'));
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($ospf_nbr_oids as $oid)
|
||||
{ // Loop the OIDs
|
||||
print_debug($ospf_nbr_db[$oid].'|'.$ospf_nbr_poll[$oid]);
|
||||
if ($ospf_nbr_db[$oid] != $ospf_nbr_poll[$oid])
|
||||
{ // If data has changed, build a query
|
||||
$ospf_nbr_update[$oid] = $ospf_nbr_poll[$oid];
|
||||
// log_event("$oid -> ".$this_nbr[$oid], $device, 'ospf', $nbr['port_id']); // FIXME
|
||||
}
|
||||
}
|
||||
if ($ospf_nbr_update)
|
||||
{
|
||||
dbUpdate($ospf_nbr_update, 'ospf_nbrs', '`device_id` = ? AND `ospf_nbr_id` = ?', array($device['device_id'], $ospf_nbr_id));
|
||||
echo('U');
|
||||
unset($ospf_nbr_update);
|
||||
} else {
|
||||
echo('.');
|
||||
}
|
||||
|
||||
unset($ospf_nbr_poll);
|
||||
unset($ospf_nbr_db);
|
||||
$ospf_nbr_count++;
|
||||
} else {
|
||||
dbDelete('ospf_nbrs', '`device_id` = ? AND `ospf_nbr_id` = ?', array($device['device_id'], $ospf_nbr_db['ospf_nbr_id']));
|
||||
echo('-');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo PHP_EOL;
|
||||
|
||||
if ($set_ospf)
|
||||
{
|
||||
// Create device-wide statistics RRD
|
||||
rrdtool_update_ng($device, 'ospf-statistics', array(
|
||||
'instances' => $ospf_instance_count,
|
||||
'areas' => $ospf_area_count,
|
||||
'ports' => $ospf_port_count,
|
||||
'neighbours' => $ospf_nbr_count,
|
||||
));
|
||||
|
||||
$graphs['ospf_neighbours'] = TRUE;
|
||||
$graphs['ospf_areas'] = TRUE;
|
||||
$graphs['ospf_ports'] = TRUE;
|
||||
|
||||
}
|
||||
|
||||
unset($ospf_ports_db);
|
||||
unset($ospf_ports_poll);
|
||||
$graphs['ospf_neighbours'] = TRUE;
|
||||
$graphs['ospf_areas'] = TRUE;
|
||||
$graphs['ospf_ports'] = TRUE;
|
||||
|
||||
// EOF
|
||||
|
447
includes/polling/ospf/ospf-mib.inc.php
Normal file
447
includes/polling/ospf/ospf-mib.inc.php
Normal file
@ -0,0 +1,447 @@
|
||||
<?php
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage poller
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
print_cli_data_field($mib . ' Processes', 2);
|
||||
|
||||
/*
|
||||
OSPF-MIB::ospfRouterId.0 = IpAddress: 1.185.1.113
|
||||
OSPF-MIB::ospfAdminStat.0 = INTEGER: enabled(1)
|
||||
OSPF-MIB::ospfVersionNumber.0 = INTEGER: version2(2)
|
||||
OSPF-MIB::ospfAreaBdrRtrStatus.0 = INTEGER: false(2)
|
||||
OSPF-MIB::ospfASBdrRtrStatus.0 = INTEGER: true(1)
|
||||
OSPF-MIB::ospfExternLsaCount.0 = Gauge32: 104
|
||||
OSPF-MIB::ospfExternLsaCksumSum.0 = INTEGER: 3322892
|
||||
OSPF-MIB::ospfTOSSupport.0 = INTEGER: false(2)
|
||||
OSPF-MIB::ospfOriginateNewLsas.0 = Counter32: 11993
|
||||
OSPF-MIB::ospfRxNewLsas.0 = Counter32: 553365
|
||||
OSPF-MIB::ospfExtLsdbLimit.0 = INTEGER: -1
|
||||
OSPF-MIB::ospfMulticastExtensions.0 = INTEGER: 0
|
||||
OSPF-MIB::ospfExitOverflowInterval.0 = INTEGER: 0
|
||||
OSPF-MIB::ospfDemandExtensions.0 = INTEGER: false(2)
|
||||
*/
|
||||
|
||||
// Pull data from device
|
||||
if ($ospf_instance_poll = snmpwalk_cache_oid($device, 'ospfGeneralGroup', [], 'OSPF-MIB')) {
|
||||
$ospf_instance_poll = $ospf_instance_poll[0];
|
||||
|
||||
// Don't bother polling everything if we have no enabled or non-defaulted router ids.
|
||||
if ($ospf_instance_poll['ospfRouterId'] !== '0.0.0.0' ||
|
||||
$ospf_instance_poll['ospfAdminStat'] === 'enabled') {
|
||||
$ospf_enabled = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// Build array of existing entries
|
||||
$ospf_instance_db = dbFetchRow('SELECT * FROM `ospf_instances` WHERE `device_id` = ? AND `ospfVersionNumber` = ?', [ $device['device_id'], 'version2' ]);
|
||||
|
||||
if ($ospf_enabled && empty($ospf_instance_db)) {
|
||||
$ospf_instance_id = dbInsert([ 'device_id' => $device['device_id'], 'ospfVersionNumber' => 'version2' ], 'ospf_instances');
|
||||
$ospf_instance_db = dbFetchRow('SELECT * FROM `ospf_instances` WHERE `ospf_instance_id` = ?', [ $ospf_instance_id ]);
|
||||
echo('+');
|
||||
} elseif (!$ospf_enabled && !empty($ospf_instance_db)) {
|
||||
dbDelete('ospf_instances', '`ospf_instance_id` = ?', [ $ospf_instance_db['instance_id'] ]);
|
||||
echo('-');
|
||||
}
|
||||
|
||||
if (!$ospf_enabled) {
|
||||
// OSPF instance not enabled
|
||||
return;
|
||||
} elseif (OBS_DEBUG) {
|
||||
echo("\nPolled: ");
|
||||
print_vars($ospf_instance_poll);
|
||||
echo('Database: ');
|
||||
print_vars($ospf_instance_db);
|
||||
echo("\n");
|
||||
}
|
||||
|
||||
$ospf_oids_db = [ 'ospfRouterId', 'ospfAdminStat', 'ospfVersionNumber', 'ospfAreaBdrRtrStatus', 'ospfASBdrRtrStatus',
|
||||
'ospfExternLsaCount', 'ospfExternLsaCksumSum', 'ospfTOSSupport', 'ospfOriginateNewLsas', 'ospfRxNewLsas',
|
||||
'ospfExtLsdbLimit', 'ospfMulticastExtensions', 'ospfExitOverflowInterval', 'ospfDemandExtensions' ];
|
||||
|
||||
// Loop array of entries and update
|
||||
$ospf_instance_id = $ospf_instance_db['ospf_instance_id'];
|
||||
|
||||
if ($ospf_instance_poll['ospfAdminStat'] !== 'enabled') {
|
||||
$ospf_instance_poll['ospfAdminStat'] = 'disabled';
|
||||
}
|
||||
if ($ospf_instance_poll['ospfVersionNumber'] !== 'version2') {
|
||||
$ospf_instance_poll['ospfVersionNumber'] = 'version2';
|
||||
}
|
||||
|
||||
$ospf_instance_update = [];
|
||||
foreach ($ospf_oids_db as $oid) {
|
||||
if (in_array($oid, [ 'ospfAreaBdrRtrStatus', 'ospfASBdrRtrStatus', 'ospfTOSSupport', 'ospfDemandExtensions' ]) &&
|
||||
!in_array($ospf_instance_poll[$oid], [ 'true', 'false' ])) {
|
||||
// FIX invalid values
|
||||
$ospf_instance_poll[$oid] = 'false';
|
||||
}
|
||||
// Loop the OIDs
|
||||
if ($ospf_instance_db[$oid] != $ospf_instance_poll[$oid]) {
|
||||
// If data has changed, build a query
|
||||
$ospf_instance_update[$oid] = $ospf_instance_poll[$oid];
|
||||
// log_event("$oid -> ".$this_port[$oid], $device, 'ospf', $port['port_id']); // FIXME
|
||||
}
|
||||
}
|
||||
|
||||
if ($ospf_instance_update) {
|
||||
dbUpdate($ospf_instance_update, 'ospf_instances', '`ospf_instance_id` = ?', [ $ospf_instance_id ]);
|
||||
echo('U');
|
||||
} else {
|
||||
echo('.');
|
||||
}
|
||||
$ospf_stats['instances']++; // Really in OSPF-MIB always only 1 instance (process)
|
||||
|
||||
unset($ospf_instance_poll, $ospf_instance_db, $ospf_instance_update);
|
||||
|
||||
echo(PHP_EOL);
|
||||
|
||||
print_cli_data_field($mib.' Areas', 2);
|
||||
|
||||
/*
|
||||
OSPF-MIB::ospfAreaId.0.0.0.0 = IpAddress: 0.0.0.0
|
||||
OSPF-MIB::ospfAuthType.0.0.0.0 = INTEGER: none(0)
|
||||
OSPF-MIB::ospfImportAsExtern.0.0.0.0 = INTEGER: importExternal(1)
|
||||
OSPF-MIB::ospfSpfRuns.0.0.0.0 = Counter32: 5
|
||||
OSPF-MIB::ospfAreaBdrRtrCount.0.0.0.0 = Gauge32: 0
|
||||
OSPF-MIB::ospfAsBdrRtrCount.0.0.0.0 = Gauge32: 3
|
||||
OSPF-MIB::ospfAreaLsaCount.0.0.0.0 = Gauge32: 8
|
||||
OSPF-MIB::ospfAreaLsaCksumSum.0.0.0.0 = INTEGER: 0
|
||||
OSPF-MIB::ospfAreaSummary.0.0.0.0 = INTEGER: sendAreaSummary(2)
|
||||
OSPF-MIB::ospfAreaStatus.0.0.0.0 = INTEGER: active(1)
|
||||
*/
|
||||
$ospf_areas_poll = snmpwalk_cache_oid($device, 'ospfAreaEntry', [], 'OSPF-MIB');
|
||||
|
||||
$ospf_area_oids = [ 'ospfAuthType', 'ospfImportAsExtern', 'ospfSpfRuns', 'ospfAreaBdrRtrCount', 'ospfAsBdrRtrCount',
|
||||
'ospfAreaLsaCount', 'ospfAreaLsaCksumSum', 'ospfAreaSummary', 'ospfAreaStatus' ];
|
||||
|
||||
// Build array of existing entries
|
||||
$ospf_areas_db = [];
|
||||
if (get_db_version() < 477) {
|
||||
// CLEANME. Remove after CE 23.xx
|
||||
$sql = 'SELECT * FROM `ospf_areas` WHERE `device_id` = ?';
|
||||
$params = [ $device['device_id'] ];
|
||||
} else {
|
||||
$sql = 'SELECT * FROM `ospf_areas` WHERE `device_id` = ? AND `ospfVersionNumber` = ?';
|
||||
$params = [ $device['device_id'], 'version2' ];
|
||||
|
||||
}
|
||||
foreach (dbFetchRows($sql, $params) as $entry) {
|
||||
// Skip OSPFV3-MIB entries
|
||||
if (isset($entry['ospfVersionNumber']) && $entry['ospfVersionNumber'] === 'version3') { continue; }
|
||||
|
||||
$ospf_areas_db[$entry['ospfAreaId']] = $entry;
|
||||
}
|
||||
|
||||
if (OBS_DEBUG) {
|
||||
echo("\nPolled: ");
|
||||
print_vars($ospf_areas_poll);
|
||||
echo('Database: ');
|
||||
print_vars($ospf_areas_db);
|
||||
echo("\n");
|
||||
}
|
||||
|
||||
foreach ($ospf_areas_poll as $ospf_area_index => $ospf_area_poll) {
|
||||
// If the entry doesn't already exist in the prebuilt array, insert into the database and put into the array
|
||||
$insert = [];
|
||||
if (!isset($ospf_areas_db[$ospf_area_index])) {
|
||||
$insert['device_id'] = $device['device_id'];
|
||||
$insert['ospfAreaId'] = $ospf_area_index;
|
||||
$insert['ospfVersionNumber'] = 'version2';
|
||||
|
||||
foreach ($ospf_area_oids as $oid) {
|
||||
// Loop the OIDs
|
||||
$insert[$oid] = $ospf_area_poll[$oid];
|
||||
}
|
||||
|
||||
dbInsertRowMulti($insert, 'ospf_areas');
|
||||
// $ospf_area_id = dbInsert($insert, 'ospf_areas');
|
||||
echo('+');
|
||||
// $ospf_areas_db[$ospf_area_index] = dbFetchRow('SELECT * FROM `ospf_areas` WHERE `device_id` = ? AND `ospfAreaId` = ?', [ $device['device_id'], $ospf_area_index ]);
|
||||
} else {
|
||||
$ospf_area_db = $ospf_areas_db[$ospf_area_index];
|
||||
$db_update = FALSE;
|
||||
|
||||
$insert['ospf_area_id'] = $ospf_area_db['ospf_area_id'];
|
||||
foreach ($ospf_area_oids as $oid) {
|
||||
// Loop the OIDs
|
||||
$insert[$oid] = $ospf_area_poll[$oid];
|
||||
if ($ospf_area_db[$oid] != $ospf_area_poll[$oid]) {
|
||||
$db_update = TRUE;
|
||||
}
|
||||
}
|
||||
if ($db_update) {
|
||||
$insert['ospfVersionNumber'] = 'version2';
|
||||
dbUpdateRowMulti($insert, 'ospf_areas', 'ospf_area_id');
|
||||
echo('U');
|
||||
} else {
|
||||
echo('.');
|
||||
}
|
||||
unset($ospf_areas_db[$ospf_area_index]);
|
||||
}
|
||||
$ospf_stats['areas']++;
|
||||
unset($insert);
|
||||
}
|
||||
|
||||
// Multi Insert/Update
|
||||
dbProcessMulti('ospf_areas');
|
||||
|
||||
// Clean
|
||||
$db_delete = [];
|
||||
foreach ($ospf_areas_db as $ospf_area_db) {
|
||||
$db_delete[] = $ospf_area_db['ospf_area_id'];
|
||||
echo '-';
|
||||
}
|
||||
// Multi Delete
|
||||
if (!safe_empty($db_delete)) {
|
||||
dbDelete('ospf_areas', generate_query_values_ng($db_delete, 'ospf_area_id'));
|
||||
}
|
||||
|
||||
unset($ospf_areas_db, $ospf_areas_poll, $db_delete);
|
||||
|
||||
echo PHP_EOL;
|
||||
|
||||
print_cli_data_field($mib .' Ports', 2);
|
||||
|
||||
/*
|
||||
OSPF-MIB::ospfIfIpAddress.95.130.232.140.0 = IpAddress: 95.130.232.140
|
||||
OSPF-MIB::ospfAddressLessIf.95.130.232.140.0 = INTEGER: 0
|
||||
OSPF-MIB::ospfIfAreaId.95.130.232.140.0 = IpAddress: 0.0.0.0
|
||||
OSPF-MIB::ospfIfType.95.130.232.140.0 = INTEGER: broadcast(1)
|
||||
OSPF-MIB::ospfIfAdminStat.95.130.232.140.0 = INTEGER: enabled(1)
|
||||
OSPF-MIB::ospfIfRtrPriority.95.130.232.140.0 = INTEGER: 10
|
||||
OSPF-MIB::ospfIfTransitDelay.95.130.232.140.0 = INTEGER: 1 seconds
|
||||
OSPF-MIB::ospfIfRetransInterval.95.130.232.140.0 = INTEGER: 5 seconds
|
||||
OSPF-MIB::ospfIfHelloInterval.95.130.232.140.0 = INTEGER: 10 seconds
|
||||
OSPF-MIB::ospfIfRtrDeadInterval.95.130.232.140.0 = INTEGER: 40 seconds
|
||||
OSPF-MIB::ospfIfPollInterval.95.130.232.140.0 = INTEGER: 60 seconds
|
||||
OSPF-MIB::ospfIfState.95.130.232.140.0 = INTEGER: otherDesignatedRouter(7)
|
||||
OSPF-MIB::ospfIfDesignatedRouter.95.130.232.140.0 = IpAddress: 95.130.232.130
|
||||
OSPF-MIB::ospfIfBackupDesignatedRouter.95.130.232.140.0 = IpAddress: 95.130.232.190
|
||||
OSPF-MIB::ospfIfEvents.95.130.232.140.0 = Counter32: 2
|
||||
OSPF-MIB::ospfIfAuthKey.95.130.232.140.0 = ""
|
||||
OSPF-MIB::ospfIfStatus.95.130.232.140.0 = INTEGER: active(1)
|
||||
OSPF-MIB::ospfIfMulticastForwarding.95.130.232.140.0 = INTEGER: blocked(1)
|
||||
OSPF-MIB::ospfIfDemand.95.130.232.140.0 = INTEGER: false(2)
|
||||
OSPF-MIB::ospfIfAuthType.95.130.232.140.0 = INTEGER: none(0)
|
||||
*/
|
||||
$ospf_ports_poll = snmpwalk_cache_oid($device, 'ospfIfEntry', [], 'OSPF-MIB');
|
||||
|
||||
$ospf_port_oids = [ 'ospfIfIpAddress', 'ospfAddressLessIf', 'ospfIfAreaId', 'ospfIfType',
|
||||
'ospfIfAdminStat', 'ospfIfRtrPriority', 'ospfIfTransitDelay', 'ospfIfRetransInterval',
|
||||
'ospfIfHelloInterval', 'ospfIfRtrDeadInterval', 'ospfIfPollInterval', 'ospfIfState',
|
||||
'ospfIfDesignatedRouter', 'ospfIfBackupDesignatedRouter', 'ospfIfEvents', 'ospfIfAuthKey',
|
||||
'ospfIfStatus', 'ospfIfMulticastForwarding', 'ospfIfDemand', 'ospfIfAuthType' ];
|
||||
|
||||
// Build array of existing entries
|
||||
// V2 always have 5 part index, ie: 95.130.232.140.0
|
||||
foreach (dbFetchRows('SELECT * FROM `ospf_ports` WHERE `device_id` = ? AND `ospf_port_id` REGEXP ?',
|
||||
[ $device['device_id'], '^[[:digit:]]+(\.[[:digit:]]+){4}$' ]) as $entry) {
|
||||
$ospf_ports_db[$entry['ospf_port_id']] = $entry;
|
||||
}
|
||||
|
||||
if (OBS_DEBUG) {
|
||||
echo("\nPolled: ");
|
||||
print_vars($ospf_ports_poll);
|
||||
echo('Database: ');
|
||||
print_vars($ospf_ports_db);
|
||||
echo("\n");
|
||||
}
|
||||
|
||||
foreach ($ospf_ports_poll as $ospf_port_index => $ospf_port_poll) {
|
||||
$insert = [];
|
||||
|
||||
// Get associated port
|
||||
$insert['port_id'] = 0; // Unknown
|
||||
if ($ospf_port_poll['ospfAddressLessIf']) {
|
||||
//$ospf_port_poll['port_id'] = @dbFetchCell('SELECT `port_id` FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?', [ $device['device_id'], $ospf_port_poll['ospfAddressLessIf'] ]);
|
||||
if ($port = get_port_by_index_cache($device, $ospf_port_poll['ospfAddressLessIf'])) {
|
||||
$insert['port_id'] = $port['port_id'];
|
||||
}
|
||||
} else {
|
||||
$ids = get_entity_ids_ip_by_network('port', $ospf_port_poll['ospfIfIpAddress'], generate_query_values_and($device['device_id'], 'device_id'));
|
||||
if (safe_count($ids)) {
|
||||
$insert['port_id'] = current($ids);
|
||||
}
|
||||
}
|
||||
|
||||
// If the entry doesn't already exist in the prebuilt array, insert into the database and put into the array
|
||||
if (!isset($ospf_ports_db[$ospf_port_index])) {
|
||||
$insert['device_id'] = $device['device_id'];
|
||||
$insert['ospf_port_id'] = $ospf_port_index;
|
||||
|
||||
foreach ($ospf_port_oids as $oid) {
|
||||
// Loop the OIDs
|
||||
$insert[$oid] = $ospf_port_poll[$oid];
|
||||
}
|
||||
|
||||
dbInsertRowMulti($insert, 'ospf_ports');
|
||||
echo('+');
|
||||
} else {
|
||||
$ospf_port_db = $ospf_ports_db[$ospf_port_index];
|
||||
$db_update = FALSE;
|
||||
|
||||
$insert['ospf_ports_id'] = $ospf_port_db['ospf_ports_id'];
|
||||
foreach ($ospf_port_oids as $oid) {
|
||||
// Loop the OIDs
|
||||
$insert[$oid] = $ospf_port_poll[$oid];
|
||||
if ($ospf_port_db[$oid] != $ospf_port_poll[$oid]) {
|
||||
$db_update = TRUE;
|
||||
}
|
||||
}
|
||||
if ($db_update) {
|
||||
dbUpdateRowMulti($insert, 'ospf_ports', 'ospf_ports_id');
|
||||
echo('U');
|
||||
} else {
|
||||
echo('.');
|
||||
}
|
||||
unset($ospf_ports_db[$ospf_port_index]);
|
||||
}
|
||||
$ospf_stats['ports']++;
|
||||
unset($insert);
|
||||
}
|
||||
|
||||
// Multi Insert/Update
|
||||
dbProcessMulti('ospf_ports');
|
||||
|
||||
// Clean
|
||||
$db_delete = [];
|
||||
foreach ($ospf_ports_db as $ospf_port_db) {
|
||||
$db_delete[] = $ospf_port_db['ospf_ports_id'];
|
||||
echo '-';
|
||||
}
|
||||
// Multi Delete
|
||||
if (!safe_empty($db_delete)) {
|
||||
dbDelete('ospf_ports', generate_query_values_ng($db_delete, 'ospf_ports_id'));
|
||||
}
|
||||
|
||||
unset($ospf_ports_db, $ospf_ports_poll, $db_delete);
|
||||
|
||||
echo PHP_EOL;
|
||||
|
||||
print_cli_data_field($mib . ' Neighbours', 2);
|
||||
|
||||
/*
|
||||
OSPF-MIB::ospfNbrIpAddr.95.130.232.130.0 = IpAddress: 95.130.232.130
|
||||
OSPF-MIB::ospfNbrAddressLessIndex.95.130.232.130.0 = INTEGER: 0
|
||||
OSPF-MIB::ospfNbrRtrId.95.130.232.130.0 = IpAddress: 185.100.140.1
|
||||
OSPF-MIB::ospfNbrOptions.95.130.232.130.0 = INTEGER: 2
|
||||
OSPF-MIB::ospfNbrPriority.95.130.232.130.0 = INTEGER: 10
|
||||
OSPF-MIB::ospfNbrState.95.130.232.130.0 = INTEGER: full(8)
|
||||
OSPF-MIB::ospfNbrEvents.95.130.232.130.0 = Counter32: 6
|
||||
OSPF-MIB::ospfNbrLsRetransQLen.95.130.232.130.0 = Gauge32: 0
|
||||
OSPF-MIB::ospfNbmaNbrStatus.95.130.232.130.0 = INTEGER: active(1)
|
||||
OSPF-MIB::ospfNbmaNbrPermanence.95.130.232.130.0 = INTEGER: permanent(2)
|
||||
OSPF-MIB::ospfNbrHelloSuppressed.95.130.232.130.0 = INTEGER: false(2)
|
||||
*/
|
||||
$ospf_nbrs_poll = snmpwalk_cache_oid($device, 'ospfNbrEntry', [], 'OSPF-MIB');
|
||||
|
||||
$ospf_nbr_oids = [ 'ospfNbrIpAddr', 'ospfNbrAddressLessIndex', 'ospfNbrRtrId', 'ospfNbrOptions', 'ospfNbrPriority',
|
||||
'ospfNbrState', 'ospfNbrEvents', 'ospfNbrLsRetransQLen', 'ospfNbmaNbrStatus',
|
||||
'ospfNbmaNbrPermanence', 'ospfNbrHelloSuppressed' ];
|
||||
|
||||
// Build array of existing entries
|
||||
// V2 always have 5 part index, ie: .95.130.232.130.0
|
||||
foreach (dbFetchRows('SELECT * FROM `ospf_nbrs` WHERE `device_id` = ? AND `ospf_nbr_id` REGEXP ?',
|
||||
[ $device['device_id'], '^[[:digit:]]+(\.[[:digit:]]+){4}$' ]) as $entry) {
|
||||
$ospf_nbrs_db[$entry['ospf_nbr_id']] = $entry;
|
||||
}
|
||||
|
||||
if (OBS_DEBUG) {
|
||||
echo("\nPolled: ");
|
||||
print_vars($ospf_nbrs_poll);
|
||||
echo('Database: ');
|
||||
print_vars($ospf_nbrs_db);
|
||||
echo("\n");
|
||||
}
|
||||
|
||||
foreach ($ospf_nbrs_poll as $ospf_nbr_index => $ospf_nbr_poll) {
|
||||
// If the entry doesn't already exist in the prebuilt array, insert into the database and put into the array
|
||||
$insert = [];
|
||||
|
||||
// Get associated port
|
||||
$insert['port_id'] = NULL; // Unknown
|
||||
if ($ospf_nbr_poll['ospfNbrAddressLessIndex']) {
|
||||
if ($port = get_port_by_index_cache($device, $ospf_nbr_poll['ospfNbrAddressLessIndex'])) {
|
||||
$insert['port_id'] = $port['port_id'];
|
||||
}
|
||||
} else {
|
||||
// FIXME. This is incorrect, need search port by network range:
|
||||
// 95.130.232.130 -> 95.130.232.140/26 -> port
|
||||
$ids = get_entity_ids_ip_by_network('port', $ospf_nbr_poll['ospfNbrIpAddr'], generate_query_values_and($device['device_id'], 'device_id'));
|
||||
if (safe_count($ids)) {
|
||||
$insert['port_id'] = current($ids);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($ospf_nbrs_db[$ospf_nbr_index])) {
|
||||
$insert['device_id'] = $device['device_id'];
|
||||
$insert['ospf_nbr_id'] = $ospf_nbr_index;
|
||||
|
||||
if (is_null($insert['port_id'])) {
|
||||
$insert['port_id'] = [ 'NULL' ];
|
||||
}
|
||||
foreach ($ospf_nbr_oids as $oid) {
|
||||
// Loop the OIDs
|
||||
$insert[$oid] = $ospf_nbr_poll[$oid];
|
||||
}
|
||||
|
||||
dbInsertRowMulti($insert, 'ospf_nbrs');
|
||||
echo('+');
|
||||
} else {
|
||||
$ospf_nbr_db = $ospf_nbrs_db[$ospf_nbr_index];
|
||||
$db_update = FALSE;
|
||||
|
||||
$insert['ospf_nbrs_id'] = $ospf_nbr_db['ospf_nbrs_id'];
|
||||
foreach ($ospf_nbr_oids as $oid) {
|
||||
// Loop the OIDs
|
||||
$insert[$oid] = $ospf_nbr_poll[$oid];
|
||||
if ($ospf_nbr_db[$oid] != $ospf_nbr_poll[$oid]) {
|
||||
$db_update = TRUE;
|
||||
}
|
||||
}
|
||||
if ($ospf_nbr_db['port_id'] != $insert['port_id']) {
|
||||
$db_update = TRUE;
|
||||
}
|
||||
if ($db_update) {
|
||||
if (is_null($insert['port_id'])) {
|
||||
$insert['port_id'] = [ 'NULL' ];
|
||||
}
|
||||
dbUpdateRowMulti($insert, 'ospf_nbrs', 'ospf_nbrs_id');
|
||||
echo('U');
|
||||
} else {
|
||||
echo('.');
|
||||
}
|
||||
unset($ospf_nbrs_db[$ospf_nbr_index]);
|
||||
}
|
||||
$ospf_stats['neighbours']++;
|
||||
unset($insert);
|
||||
}
|
||||
|
||||
// Multi Insert/Update
|
||||
dbProcessMulti('ospf_nbrs');
|
||||
|
||||
// Clean
|
||||
$db_delete = [];
|
||||
foreach ($ospf_nbrs_db as $ospf_nbr_db) {
|
||||
$db_delete[] = $ospf_nbr_db['ospf_nbrs_id'];
|
||||
echo '-';
|
||||
}
|
||||
// Multi Delete
|
||||
if (!safe_empty($db_delete)) {
|
||||
dbDelete('ospf_nbrs', generate_query_values_ng($db_delete, 'ospf_nbrs_id'));
|
||||
}
|
||||
|
||||
unset($ospf_nbrs_db, $ospf_nbrs_poll, $db_delete);
|
||||
|
||||
echo PHP_EOL;
|
||||
|
||||
// EOF
|
462
includes/polling/ospf/ospfv3-mib.inc.php
Normal file
462
includes/polling/ospf/ospfv3-mib.inc.php
Normal file
@ -0,0 +1,462 @@
|
||||
<?php
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage poller
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
// CLEANME. Remove after CE 23.xx
|
||||
if (get_db_version() < 477) {
|
||||
print_warning("DB schema not updated. OSPFV3-MIB not polled until update.");
|
||||
return;
|
||||
}
|
||||
|
||||
print_cli_data_field($mib . ' Processes', 2);
|
||||
|
||||
/*
|
||||
OSPFV3-MIB::ospfv3RouterId.0 = Gauge32: 1602414732
|
||||
OSPFV3-MIB::ospfv3AdminStatus.0 = INTEGER: enabled(1)
|
||||
OSPFV3-MIB::ospfv3VersionNumber.0 = INTEGER: version3(3)
|
||||
OSPFV3-MIB::ospfv3AreaBdrRtrStatus.0 = INTEGER: false(2)
|
||||
OSPFV3-MIB::ospfv3ASBdrRtrStatus.0 = INTEGER: false(2)
|
||||
OSPFV3-MIB::ospfv3AsScopeLsaCount.0 = Gauge32: 2
|
||||
OSPFV3-MIB::ospfv3AsScopeLsaCksumSum.0 = Gauge32: 11269
|
||||
OSPFV3-MIB::ospfv3OriginateNewLsas.0 = Counter32: 0
|
||||
OSPFV3-MIB::ospfv3RxNewLsas.0 = Counter32: 0
|
||||
OSPFV3-MIB::ospfv3ExtLsaCount.0 = Gauge32: 2
|
||||
OSPFV3-MIB::ospfv3ExtAreaLsdbLimit.0 = INTEGER: -1
|
||||
OSPFV3-MIB::ospfv3ExitOverflowInterval.0 = Gauge32: 0 seconds
|
||||
OSPFV3-MIB::ospfv3DemandExtensions.0 = INTEGER: 0
|
||||
*/
|
||||
|
||||
// Pull data from device
|
||||
if ($ospf_instance_poll = snmpwalk_cache_oid($device, 'ospfv3GeneralGroup', [], 'OSPFV3-MIB')) {
|
||||
$ospf_instance_poll = $ospf_instance_poll[0];
|
||||
|
||||
// Don't bother polling everything if we have no enabled or non-defaulted router ids.
|
||||
if ($ospf_instance_poll['ospfv3RouterId'] !== '0' ||
|
||||
$ospf_instance_poll['ospfv3AdminStatus'] === 'enabled') {
|
||||
$ospf_enabled = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// Build array of existing entries
|
||||
$ospf_instance_db = dbFetchRow('SELECT * FROM `ospf_instances` WHERE `device_id` = ? AND `ospfVersionNumber` = ?', [ $device['device_id'], 'version3' ]);
|
||||
|
||||
if ($ospf_enabled && empty($ospf_instance_db)) {
|
||||
$ospf_instance_id = dbInsert([ 'device_id' => $device['device_id'], 'ospfVersionNumber' => 'version3' ], 'ospf_instances');
|
||||
$ospf_instance_db = dbFetchRow('SELECT * FROM `ospf_instances` WHERE `ospf_instance_id` = ?', [ $ospf_instance_id ]);
|
||||
echo('+');
|
||||
} elseif (!$ospf_enabled && !empty($ospf_instance_db)) {
|
||||
dbDelete('ospf_instances', '`ospf_instance_id` = ?', [ $ospf_instance_db['instance_id'] ]);
|
||||
echo('-');
|
||||
}
|
||||
|
||||
if (!$ospf_enabled) {
|
||||
// OSPF instance not enabled
|
||||
return;
|
||||
} elseif (OBS_DEBUG) {
|
||||
echo("\nPolled: ");
|
||||
print_vars($ospf_instance_poll);
|
||||
echo('Database: ');
|
||||
print_vars($ospf_instance_db);
|
||||
echo("\n");
|
||||
}
|
||||
|
||||
$ospf_oids_db = [ 'ospfRouterId' => 'ospfv3RouterId', 'ospfAdminStat' => 'ospfv3AdminStatus',
|
||||
'ospfVersionNumber' => 'ospfv3VersionNumber', 'ospfAreaBdrRtrStatus' => 'ospfv3AreaBdrRtrStatus',
|
||||
'ospfASBdrRtrStatus' => 'ospfv3ASBdrRtrStatus', 'ospfExternLsaCount' => 'ospfv3ExtLsaCount',
|
||||
'ospfExternLsaCksumSum' => '', 'ospfTOSSupport' => '',
|
||||
'ospfOriginateNewLsas' => 'ospfv3OriginateNewLsas', 'ospfRxNewLsas' => 'ospfv3RxNewLsas',
|
||||
'ospfExtLsdbLimit' => 'ospfv3ExtAreaLsdbLimit', 'ospfMulticastExtensions' => '',
|
||||
'ospfExitOverflowInterval' => 'ospfv3ExitOverflowInterval', 'ospfDemandExtensions' => 'ospfv3DemandExtensions' ];
|
||||
|
||||
// Loop array of entries and update
|
||||
$ospf_instance_id = $ospf_instance_db['ospf_instance_id'];
|
||||
|
||||
if ($ospf_instance_poll['ospfv3AdminStatus'] !== 'enabled') {
|
||||
$ospf_instance_poll['ospfv3AdminStatus'] = 'disabled';
|
||||
}
|
||||
if ($ospf_instance_poll['ospfv3VersionNumber'] !== 'version3') {
|
||||
$ospf_instance_poll['ospfv3VersionNumber'] = 'version3';
|
||||
}
|
||||
// Not exist in version3:
|
||||
$ospf_instance_poll['ospfExternLsaCksumSum'] = '0';
|
||||
$ospf_instance_poll['ospfTOSSupport'] = 'false';
|
||||
$ospf_instance_poll['ospfMulticastExtensions'] = '0';
|
||||
|
||||
$ospf_instance_update = [];
|
||||
foreach ($ospf_oids_db as $field => $oid) {
|
||||
if (in_array($field, [ 'ospfAreaBdrRtrStatus', 'ospfASBdrRtrStatus', 'ospfDemandExtensions' ]) &&
|
||||
!in_array($ospf_instance_poll[$oid], [ 'true', 'false' ])) {
|
||||
// FIX invalid values
|
||||
$ospf_instance_poll[$oid] = 'false';
|
||||
}
|
||||
// Loop the OIDs
|
||||
if (empty($oid)) {
|
||||
// not exist oids in version3
|
||||
if ($ospf_instance_db[$field] != $ospf_instance_poll[$field]) {
|
||||
$ospf_instance_update[$field] = $ospf_instance_poll[$field];
|
||||
}
|
||||
} elseif ($ospf_instance_db[$field] != $ospf_instance_poll[$oid]) {
|
||||
// If data has changed, build a query
|
||||
$ospf_instance_update[$field] = $ospf_instance_poll[$oid];
|
||||
// log_event("$oid -> ".$this_port[$oid], $device, 'ospf', $port['port_id']); // FIXME
|
||||
}
|
||||
}
|
||||
|
||||
if ($ospf_instance_update) {
|
||||
dbUpdate($ospf_instance_update, 'ospf_instances', '`ospf_instance_id` = ?', [ $ospf_instance_id ]);
|
||||
echo('U');
|
||||
} else {
|
||||
echo('.');
|
||||
}
|
||||
$ospf_stats['instances']++; // Really in OSPF-MIB always only 1 instance (process)
|
||||
|
||||
unset($ospf_instance_poll, $ospf_instance_db, $ospf_instance_update);
|
||||
|
||||
echo(PHP_EOL);
|
||||
|
||||
print_cli_data_field($mib.' Areas', 2);
|
||||
|
||||
/*
|
||||
OSPFV3-MIB::ospfv3AreaImportAsExtern.0 = INTEGER: importExternal(1)
|
||||
OSPFV3-MIB::ospfv3AreaSpfRuns.0 = Counter32: 5
|
||||
OSPFV3-MIB::ospfv3AreaBdrRtrCount.0 = Gauge32: 0
|
||||
OSPFV3-MIB::ospfv3AreaAsBdrRtrCount.0 = Gauge32: 2
|
||||
OSPFV3-MIB::ospfv3AreaScopeLsaCount.0 = Gauge32: 16
|
||||
OSPFV3-MIB::ospfv3AreaScopeLsaCksumSum.0 = Gauge32: 92
|
||||
OSPFV3-MIB::ospfv3AreaSummary.0 = INTEGER: sendAreaSummary(2)
|
||||
OSPFV3-MIB::ospfv3AreaRowStatus.0 = INTEGER: active(1)
|
||||
*/
|
||||
$ospf_areas_poll = snmpwalk_cache_oid($device, 'ospfv3AreaEntry', [], 'OSPFV3-MIB');
|
||||
|
||||
$ospf_area_oids = [ /* 'ospfAuthType' => '', */ 'ospfImportAsExtern' => 'ospfv3AreaImportAsExtern',
|
||||
'ospfSpfRuns' => 'ospfv3AreaSpfRuns', 'ospfAreaBdrRtrCount' => 'ospfv3AreaBdrRtrCount',
|
||||
'ospfAsBdrRtrCount' => 'ospfv3AreaAsBdrRtrCount', 'ospfAreaLsaCount' => 'ospfv3AreaScopeLsaCount',
|
||||
'ospfAreaLsaCksumSum' => 'ospfv3AreaScopeLsaCksumSum', 'ospfAreaSummary' => 'ospfv3AreaSummary',
|
||||
'ospfAreaStatus' => 'ospfv3AreaRowStatus' ];
|
||||
|
||||
// Build array of existing entries
|
||||
$ospf_areas_db = [];
|
||||
foreach (dbFetchRows('SELECT * FROM `ospf_areas` WHERE `device_id` = ? AND `ospfVersionNumber` = ?', [ $device['device_id'], 'version3' ]) as $entry) {
|
||||
$ospf_areas_db[$entry['ospfAreaId']] = $entry;
|
||||
}
|
||||
|
||||
if (OBS_DEBUG) {
|
||||
echo("\nPolled: ");
|
||||
print_vars($ospf_areas_poll);
|
||||
echo('Database: ');
|
||||
print_vars($ospf_areas_db);
|
||||
echo("\n");
|
||||
}
|
||||
|
||||
foreach ($ospf_areas_poll as $ospf_area_index => $ospf_area_poll) {
|
||||
// If the entry doesn't already exist in the prebuilt array, insert into the database and put into the array
|
||||
$insert = [];
|
||||
if (!isset($ospf_areas_db[$ospf_area_index])) {
|
||||
$insert['device_id'] = $device['device_id'];
|
||||
$insert['ospfAreaId'] = $ospf_area_index;
|
||||
$insert['ospfVersionNumber'] = 'version3';
|
||||
|
||||
foreach ($ospf_area_oids as $field => $oid) {
|
||||
// Loop the OIDs
|
||||
$insert[$field] = $ospf_area_poll[$oid];
|
||||
}
|
||||
|
||||
dbInsertRowMulti($insert, 'ospf_areas');
|
||||
echo('+');
|
||||
} else {
|
||||
$ospf_area_db = $ospf_areas_db[$ospf_area_index];
|
||||
$db_update = FALSE;
|
||||
|
||||
$insert['ospf_area_id'] = $ospf_area_db['ospf_area_id'];
|
||||
foreach ($ospf_area_oids as $field => $oid) {
|
||||
// Loop the OIDs
|
||||
$insert[$field] = $ospf_area_poll[$oid];
|
||||
if ($ospf_area_db[$field] != $ospf_area_poll[$oid]) {
|
||||
$db_update = TRUE;
|
||||
}
|
||||
}
|
||||
if ($db_update) {
|
||||
$insert['ospfVersionNumber'] = 'version3';
|
||||
dbUpdateRowMulti($insert, 'ospf_areas', 'ospf_area_id');
|
||||
echo('U');
|
||||
} else {
|
||||
echo('.');
|
||||
}
|
||||
unset($ospf_areas_db[$ospf_area_index]);
|
||||
}
|
||||
$ospf_stats['areas']++;
|
||||
unset($insert);
|
||||
}
|
||||
|
||||
// Multi Insert/Update
|
||||
dbProcessMulti('ospf_areas');
|
||||
|
||||
// Clean
|
||||
$db_delete = [];
|
||||
foreach ($ospf_areas_db as $ospf_area_db) {
|
||||
$db_delete[] = $ospf_area_db['ospf_area_id'];
|
||||
echo '-';
|
||||
}
|
||||
// Multi Delete
|
||||
if (!safe_empty($db_delete)) {
|
||||
dbDelete('ospf_areas', generate_query_values_ng($db_delete, 'ospf_area_id'));
|
||||
}
|
||||
|
||||
unset($ospf_areas_db, $ospf_areas_poll, $db_delete);
|
||||
|
||||
echo PHP_EOL;
|
||||
|
||||
print_cli_data_field($mib .' Ports', 2);
|
||||
|
||||
/*
|
||||
OSPFV3-MIB::ospfv3IfAreaId.6.0 = Gauge32: 0
|
||||
OSPFV3-MIB::ospfv3IfType.6.0 = INTEGER: broadcast(1)
|
||||
OSPFV3-MIB::ospfv3IfAdminStatus.6.0 = INTEGER: enabled(1)
|
||||
OSPFV3-MIB::ospfv3IfRtrPriority.6.0 = INTEGER: 1
|
||||
OSPFV3-MIB::ospfv3IfTransitDelay.6.0 = Gauge32: 1 seconds
|
||||
OSPFV3-MIB::ospfv3IfRetransInterval.6.0 = Gauge32: 5 seconds
|
||||
OSPFV3-MIB::ospfv3IfHelloInterval.6.0 = INTEGER: 10 seconds
|
||||
OSPFV3-MIB::ospfv3IfRtrDeadInterval.6.0 = Gauge32: 40 seconds
|
||||
OSPFV3-MIB::ospfv3IfState.6.0 = INTEGER: otherDesignatedRouter(7)
|
||||
OSPFV3-MIB::ospfv3IfDesignatedRouter.6.0 = Gauge32: 1602414732
|
||||
OSPFV3-MIB::ospfv3IfBackupDesignatedRouter.6.0 = Gauge32: 0
|
||||
OSPFV3-MIB::ospfv3IfEvents.6.0 = Counter32: 4
|
||||
OSPFV3-MIB::ospfv3IfRowStatus.6.0 = INTEGER: active(1)
|
||||
OSPFV3-MIB::ospfv3IfDemand.6.0 = INTEGER: false(2)
|
||||
OSPFV3-MIB::ospfv3IfMetricValue.6.0 = INTEGER: 200
|
||||
OSPFV3-MIB::ospfv3IfLinkScopeLsaCount.6.0 = Gauge32: 1
|
||||
OSPFV3-MIB::ospfv3IfLinkLsaCksumSum.6.0 = Gauge32: 40843
|
||||
*/
|
||||
$ospf_ports_poll = snmpwalk_cache_oid($device, 'ospfv3IfEntry', [], 'OSPFV3-MIB');
|
||||
|
||||
$ospf_port_oids = [ 'ospfIfIpAddress' => 'ospfIfIpAddress', 'ospfAddressLessIf' => 'ospfAddressLessIf', // not really exist
|
||||
'ospfIfAreaId' => 'ospfv3IfAreaId', 'ospfIfType' => 'ospfv3IfType',
|
||||
'ospfIfAdminStat' => 'ospfv3IfAdminStatus', 'ospfIfRtrPriority' => 'ospfv3IfRtrPriority',
|
||||
'ospfIfTransitDelay' => 'ospfv3IfTransitDelay', 'ospfIfRetransInterval' => 'ospfv3IfRetransInterval',
|
||||
'ospfIfHelloInterval' => 'ospfv3IfHelloInterval', 'ospfIfRtrDeadInterval' => 'ospfv3IfRtrDeadInterval',
|
||||
'ospfIfState' => 'ospfv3IfState', 'ospfIfDesignatedRouter' => 'ospfv3IfDesignatedRouter',
|
||||
'ospfIfBackupDesignatedRouter' => 'ospfv3IfBackupDesignatedRouter', 'ospfIfEvents' => 'ospfv3IfEvents',
|
||||
'ospfIfStatus' => 'ospfv3IfRowStatus', 'ospfIfDemand' => 'ospfv3IfDemand',
|
||||
/* 'ospfIfPollInterval', 'ospfIfAuthKey', 'ospfIfMulticastForwarding', 'ospfIfAuthType' */ ];
|
||||
|
||||
// Build array of existing entries
|
||||
// V3 always have 2 part index, ie: 6.0
|
||||
foreach (dbFetchRows('SELECT * FROM `ospf_ports` WHERE `device_id` = ? AND `ospf_port_id` REGEXP ?',
|
||||
[ $device['device_id'], '^[[:digit:]]+\.[[:digit:]]+$' ]) as $entry) {
|
||||
$ospf_ports_db[$entry['ospf_port_id']] = $entry;
|
||||
}
|
||||
|
||||
if (OBS_DEBUG) {
|
||||
echo("\nPolled: ");
|
||||
print_vars($ospf_ports_poll);
|
||||
echo('Database: ');
|
||||
print_vars($ospf_ports_db);
|
||||
echo("\n");
|
||||
}
|
||||
|
||||
foreach ($ospf_ports_poll as $ospf_port_index => $ospf_port_poll) {
|
||||
$insert = [];
|
||||
|
||||
// Get associated port
|
||||
list($ospf_ifIndex, $ospf_inst) = explode('.', $ospf_port_index);
|
||||
$ospf_port_poll['ospfAddressLessIf'] = $ospf_ifIndex;
|
||||
$ospf_port_poll['ospfIfIpAddress'] = '::';
|
||||
$insert['port_id'] = 0; // Unknown
|
||||
if ($ospf_port_poll['ospfAddressLessIf'] &&
|
||||
$port = get_port_by_index_cache($device, $ospf_port_poll['ospfAddressLessIf'])) {
|
||||
$insert['port_id'] = $port['port_id'];
|
||||
|
||||
// Get IPv6 address when possible
|
||||
if ($ospf_ip = dbFetchCell('SELECT `ipv6_address` FROM `ipv6_addresses` WHERE `port_id` = ?', [ $port['port_id'] ])) {
|
||||
$ospf_port_poll['ospfIfIpAddress'] = $ospf_ip;
|
||||
}
|
||||
}
|
||||
|
||||
// If the entry doesn't already exist in the prebuilt array, insert into the database and put into the array
|
||||
if (!isset($ospf_ports_db[$ospf_port_index])) {
|
||||
$insert['device_id'] = $device['device_id'];
|
||||
$insert['ospf_port_id'] = $ospf_port_index;
|
||||
|
||||
foreach ($ospf_port_oids as $field => $oid) {
|
||||
// Loop the OIDs
|
||||
$insert[$field] = $ospf_port_poll[$oid];
|
||||
}
|
||||
|
||||
dbInsertRowMulti($insert, 'ospf_ports');
|
||||
echo('+');
|
||||
} else {
|
||||
$ospf_port_db = $ospf_ports_db[$ospf_port_index];
|
||||
$db_update = FALSE;
|
||||
|
||||
$insert['ospf_ports_id'] = $ospf_port_db['ospf_ports_id'];
|
||||
foreach ($ospf_port_oids as $field => $oid) {
|
||||
// Loop the OIDs
|
||||
$insert[$field] = $ospf_port_poll[$oid];
|
||||
if ($ospf_port_db[$field] != $ospf_port_poll[$oid]) {
|
||||
$db_update = TRUE;
|
||||
}
|
||||
}
|
||||
if ($db_update) {
|
||||
dbUpdateRowMulti($insert, 'ospf_ports', 'ospf_ports_id');
|
||||
echo('U');
|
||||
} else {
|
||||
echo('.');
|
||||
}
|
||||
unset($ospf_ports_db[$ospf_port_index]);
|
||||
}
|
||||
$ospf_stats['ports']++;
|
||||
unset($insert);
|
||||
}
|
||||
|
||||
// Multi Insert/Update
|
||||
dbProcessMulti('ospf_ports');
|
||||
|
||||
// Clean
|
||||
$db_delete = [];
|
||||
foreach ($ospf_ports_db as $ospf_port_db) {
|
||||
$db_delete[] = $ospf_port_db['ospf_ports_id'];
|
||||
echo '-';
|
||||
}
|
||||
// Multi Delete
|
||||
if (!safe_empty($db_delete)) {
|
||||
dbDelete('ospf_ports', generate_query_values_ng($db_delete, 'ospf_ports_id'));
|
||||
}
|
||||
|
||||
unset($ospf_ports_db, $ospf_ports_poll, $db_delete);
|
||||
|
||||
echo PHP_EOL;
|
||||
|
||||
print_cli_data_field($mib . ' Neighbours', 2);
|
||||
|
||||
/*
|
||||
OSPFV3-MIB::ospfv3NbrAddressType.4.0.1602414725 = INTEGER: ipv6(2)
|
||||
OSPFV3-MIB::ospfv3NbrAddress.4.0.1602414725 = Hex-STRING: FE 80 00 00 00 00 00 00 0E C4 7A FF FE BC 32 9B
|
||||
OSPFV3-MIB::ospfv3NbrOptions.4.0.1602414725 = INTEGER: 0
|
||||
OSPFV3-MIB::ospfv3NbrPriority.4.0.1602414725 = INTEGER: 10
|
||||
OSPFV3-MIB::ospfv3NbrState.4.0.1602414725 = INTEGER: twoWay(4)
|
||||
OSPFV3-MIB::ospfv3NbrEvents.4.0.1602414725 = Counter32: 2
|
||||
OSPFV3-MIB::ospfv3NbrLsRetransQLen.4.0.1602414725 = Gauge32: 0
|
||||
OSPFV3-MIB::ospfv3NbrHelloSuppressed.4.0.1602414725 = INTEGER: false(2)
|
||||
OSPFV3-MIB::ospfv3NbrIfId.4.0.1602414725 = INTEGER: 4
|
||||
*/
|
||||
$ospf_nbrs_poll = snmpwalk_cache_oid($device, 'ospfv3NbrEntry', [], 'OSPFV3-MIB');
|
||||
|
||||
$ospf_nbr_oids = [ 'ospfNbrIpAddr' => 'ospfv3NbrAddress', 'ospfNbrAddressLessIndex' => 'ospfv3NbrIfId',
|
||||
'ospfNbrRtrId' => 'ospfv3NbrRtrId',
|
||||
'ospfNbrOptions' => 'ospfv3NbrOptions', 'ospfNbrPriority' => 'ospfv3NbrPriority',
|
||||
'ospfNbrState' => 'ospfv3NbrState', 'ospfNbrEvents' => 'ospfv3NbrEvents',
|
||||
'ospfNbrLsRetransQLen' => 'ospfv3NbrLsRetransQLen',
|
||||
/* 'ospfNbmaNbrStatus', 'ospfNbmaNbrPermanence', */
|
||||
'ospfNbrHelloSuppressed' => 'ospfv3NbrHelloSuppressed' ];
|
||||
|
||||
// Build array of existing entries
|
||||
// V3 always have 3 part index, ie: .4.0.1602414725
|
||||
foreach (dbFetchRows('SELECT * FROM `ospf_nbrs` WHERE `device_id` = ? AND `ospf_nbr_id` REGEXP ?',
|
||||
[ $device['device_id'], '^[[:digit:]]+(\.[[:digit:]]+){2}$' ]) as $entry) {
|
||||
$ospf_nbrs_db[$entry['ospf_nbr_id']] = $entry;
|
||||
}
|
||||
|
||||
if (OBS_DEBUG) {
|
||||
echo("\nPolled: ");
|
||||
print_vars($ospf_nbrs_poll);
|
||||
echo('Database: ');
|
||||
print_vars($ospf_nbrs_db);
|
||||
echo("\n");
|
||||
}
|
||||
|
||||
foreach ($ospf_nbrs_poll as $ospf_nbr_index => $ospf_nbr_poll) {
|
||||
// If the entry doesn't already exist in the prebuilt array, insert into the database and put into the array
|
||||
$insert = [];
|
||||
|
||||
// Get associated port
|
||||
list($ospf_ifIndex, $ospf_inst, $ospf_rtr) = explode('.', $ospf_nbr_index);
|
||||
$ospf_nbr_poll['ospfv3NbrRtrId'] = $ospf_rtr;
|
||||
$ospf_nbr_poll['ospfv3NbrAddress'] = hex2ip($ospf_nbr_poll['ospfv3NbrAddress']);
|
||||
|
||||
$insert['port_id'] = NULL; // Unknown
|
||||
if ($ospf_nbr_poll['ospfv3NbrIfId']) {
|
||||
if ($port = get_port_by_index_cache($device, $ospf_nbr_poll['ospfv3NbrIfId'])) {
|
||||
$insert['port_id'] = $port['port_id'];
|
||||
}
|
||||
} elseif ($ospf_ifIndex) {
|
||||
if ($port = get_port_by_index_cache($device, $ospf_ifIndex)) {
|
||||
$insert['port_id'] = $port['port_id'];
|
||||
}
|
||||
} else {
|
||||
$ids = get_entity_ids_ip_by_network('port', $ospf_nbr_poll['ospfv3NbrAddress'], generate_query_values_and($device['device_id'], 'device_id'));
|
||||
if (safe_count($ids)) {
|
||||
$insert['port_id'] = current($ids);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($ospf_nbrs_db[$ospf_nbr_index])) {
|
||||
$insert['device_id'] = $device['device_id'];
|
||||
$insert['ospf_nbr_id'] = $ospf_nbr_index;
|
||||
|
||||
if (is_null($insert['port_id'])) {
|
||||
$insert['port_id'] = [ 'NULL' ];
|
||||
}
|
||||
foreach ($ospf_nbr_oids as $field => $oid) {
|
||||
// Loop the OIDs
|
||||
$insert[$field] = $ospf_nbr_poll[$oid];
|
||||
}
|
||||
|
||||
dbInsertRowMulti($insert, 'ospf_nbrs');
|
||||
echo('+');
|
||||
} else {
|
||||
$ospf_nbr_db = $ospf_nbrs_db[$ospf_nbr_index];
|
||||
$db_update = FALSE;
|
||||
|
||||
$insert['ospf_nbrs_id'] = $ospf_nbr_db['ospf_nbrs_id'];
|
||||
foreach ($ospf_nbr_oids as $field => $oid) {
|
||||
// Loop the OIDs
|
||||
$insert[$field] = $ospf_nbr_poll[$oid];
|
||||
if ($ospf_nbr_db[$field] != $ospf_nbr_poll[$oid]) {
|
||||
$db_update = TRUE;
|
||||
}
|
||||
}
|
||||
if ($ospf_nbr_db['port_id'] != $insert['port_id']) {
|
||||
$db_update = TRUE;
|
||||
}
|
||||
if ($db_update) {
|
||||
if (is_null($insert['port_id'])) {
|
||||
$insert['port_id'] = [ 'NULL' ];
|
||||
}
|
||||
dbUpdateRowMulti($insert, 'ospf_nbrs', 'ospf_nbrs_id');
|
||||
echo('U');
|
||||
} else {
|
||||
echo('.');
|
||||
}
|
||||
unset($ospf_nbrs_db[$ospf_nbr_index]);
|
||||
}
|
||||
$ospf_stats['neighbours']++;
|
||||
unset($insert);
|
||||
}
|
||||
|
||||
// Multi Insert/Update
|
||||
dbProcessMulti('ospf_nbrs');
|
||||
|
||||
// Clean
|
||||
$db_delete = [];
|
||||
foreach ($ospf_nbrs_db as $ospf_nbr_db) {
|
||||
$db_delete[] = $ospf_nbr_db['ospf_nbrs_id'];
|
||||
echo '-';
|
||||
}
|
||||
// Multi Delete
|
||||
if (!safe_empty($db_delete)) {
|
||||
dbDelete('ospf_nbrs', generate_query_values_ng($db_delete, 'ospf_nbrs_id'));
|
||||
}
|
||||
|
||||
unset($ospf_nbrs_db, $ospf_nbrs_poll, $db_delete);
|
||||
|
||||
echo PHP_EOL;
|
||||
|
||||
// EOF
|
166
includes/polling/ports/coriant-groove-mib.inc.php
Normal file
166
includes/polling/ports/coriant-groove-mib.inc.php
Normal file
@ -0,0 +1,166 @@
|
||||
<?php
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage poller
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
// this is eth100g only, note that fc8gTable, fc16gTable, eth10gTable, eth40gTable, eth400gtable all exist too!
|
||||
|
||||
/*
|
||||
.1.3.6.1.4.1.42229.1.2.4.1.9 - eth100gTable for a single port (1/1/6)
|
||||
|
||||
CORIANT-GROOVE-MIB::eth100gEthFecType.1.1.0.6.0 = INTEGER: auto(3)
|
||||
CORIANT-GROOVE-MIB::eth100gEthFecTypeState.1.1.0.6.0 = INTEGER: disabled(2)
|
||||
CORIANT-GROOVE-MIB::eth100gTransmitInterpacketgap.1.1.0.6.0 = Gauge32: 8
|
||||
CORIANT-GROOVE-MIB::eth100gGfpPayloadFcs.1.1.0.6.0 = INTEGER: disabled(2)
|
||||
CORIANT-GROOVE-MIB::eth100gMappingMode.1.1.0.6.0 = INTEGER: gmp(1)
|
||||
CORIANT-GROOVE-MIB::eth100gAdminStatus.1.1.0.6.0 = INTEGER: up(1)
|
||||
CORIANT-GROOVE-MIB::eth100gOperStatus.1.1.0.6.0 = INTEGER: down(2)
|
||||
CORIANT-GROOVE-MIB::eth100gAvailStatus.1.1.0.6.0 = BITS: 10 00 00 00 lowerLayerDown(3)
|
||||
CORIANT-GROOVE-MIB::eth100gAliasName.1.1.0.6.0 = STRING: "100gbe-1/1/6"
|
||||
CORIANT-GROOVE-MIB::eth100gClientShutdown.1.1.0.6.0 = INTEGER: no(2)
|
||||
CORIANT-GROOVE-MIB::eth100gClientShutdownHoldoffTimer.1.1.0.6.0 = Gauge32: 0
|
||||
CORIANT-GROOVE-MIB::eth100gNearEndAls.1.1.0.6.0 = INTEGER: no(2)
|
||||
CORIANT-GROOVE-MIB::eth100gAlsDegradeMode.1.1.0.6.0 = INTEGER: disabled(2)
|
||||
CORIANT-GROOVE-MIB::eth100gLoopbackEnable.1.1.0.6.0 = INTEGER: disabled(2)
|
||||
CORIANT-GROOVE-MIB::eth100gLoopbackType.1.1.0.6.0 = INTEGER: none(0)
|
||||
CORIANT-GROOVE-MIB::eth100gTestSignalType.1.1.0.6.0 = INTEGER: none(0)
|
||||
CORIANT-GROOVE-MIB::eth100gTestSignalEnable.1.1.0.6.0 = INTEGER: none(0)
|
||||
CORIANT-GROOVE-MIB::eth100gServiceLabel.1.1.0.6.0 = ""
|
||||
CORIANT-GROOVE-MIB::eth100gLldpStatusIf.1.1.0.6.0 = INTEGER: disabled(4)
|
||||
CORIANT-GROOVE-MIB::eth100gHoldoffSignal.1.1.0.6.0 = INTEGER: no(2)
|
||||
CORIANT-GROOVE-MIB::eth100gManagedBy.1.1.0.6.0 = INTEGER: system(1)
|
||||
|
||||
.1.3.6.1.4.1.42229.1.2.4.1.9 - eth100gStatisticsTable for a single port (1/1/6)
|
||||
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryLastClear.1.1.0.6.0 = STRING: "0000-01-01T00:00:00.000Z"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryLossOfSignalSeconds.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryBitErrorFec.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryUncorrectedBlockErrorFec.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryInSymbolErrors.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryInDropEvents.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryInOctets.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryInPackets.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryInBroadcastPackets.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryInMulticastPackets.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryInCrcAlignErrors.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryInUndersizePackets.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryInOversizePackets.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryInFragments.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryInJabbers.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryInPackets64octets.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryInPackets65to127octets.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryInPackets128to255octets.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryInPackets256to511octets.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryInPackets512to1023octets.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryInPackets1024to1518octets.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryOutSymbolErrors.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryOutDropEvents.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryOutOctets.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryOutPackets.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryOutBroadcastPackets.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryOutMulticastPackets.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryOutCrcAlignErrors.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryOutUndersizePackets.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryOutOversizePackets.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryOutFragments.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryOutJabbers.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryOutPackets64octets.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryOutPackets65to127octets.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryOutPackets128to255octets.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryOutPackets256to511octets.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryOutPackets512to1023octets.1.1.0.6.0 = STRING: "0"
|
||||
CORIANT-GROOVE-MIB::eth100gStatisticsEntryOutPackets1024to1518octets.1.1.0.6.0 = STRING: "0"
|
||||
|
||||
*/
|
||||
|
||||
$mib = 'CORIANT-GROOVE-MIB';
|
||||
|
||||
// eth100gTable
|
||||
$entries = [];
|
||||
$entries = snmpwalk_cache_oid($device, 'eth100gTable', $entries, $mib);
|
||||
$entries = snmpwalk_cache_oid($device, 'eth100gStatisticsTable', $entries, $mib);
|
||||
|
||||
print_debug_vars($entries);
|
||||
|
||||
foreach ($entries as $port_oid_suffix => $port) {
|
||||
$ifIndex = $port_oid_suffix;
|
||||
$entry = isset($entries[$ifIndex]) ? $entries[$ifIndex] : [];
|
||||
|
||||
// basics
|
||||
$port_stats[$ifIndex]['ifDescr'] = $entry['eth100gAliasName'];
|
||||
$port_stats[$ifIndex]['ifName'] = $entry['eth100gAliasName'];
|
||||
$port_stats[$ifIndex]['ifAlias'] = $entry['eth100gServiceLabel'];
|
||||
$port_stats[$ifIndex]['ifOperStatus'] = $entry['eth100gOperStatus'];
|
||||
$port_stats[$ifIndex]['ifAdminStatus'] = $entry['eth100gAdminStatus'];
|
||||
$port_stats[$ifIndex]['ifType'] = 'ethernetCsmacd'; // can we do better than hard coding?
|
||||
|
||||
// stats
|
||||
$port_stats[$ifIndex]['ifInOctets'] = $entry['eth100gStatisticsEntryInOctets'];
|
||||
$port_stats[$ifIndex]['ifOutOctets'] = $entry['eth100gStatisticsEntryOutOctets'];
|
||||
|
||||
$port_stats[$ifIndex]['ifInUcastPkts'] = $entry['eth100gStatisticsEntryInPackets'];
|
||||
$port_stats[$ifIndex]['ifOutUcastPkts'] = $entry['eth100gStatisticsEntryOutPackets'];
|
||||
|
||||
$port_stats[$ifIndex]['ifInBroadcastPkts'] = $entry['eth100gStatisticsEntryInBroadcastPackets'];
|
||||
$port_stats[$ifIndex]['ifOutBroadcastPkts'] = $entry['eth100gStatisticsEntryOutBroadcastPackets'];
|
||||
|
||||
$port_stats[$ifIndex]['ifInMulticastPkts'] = $entry['eth100gStatisticsEntryInMulticastPackets'];
|
||||
$port_stats[$ifIndex]['ifOutMulticastPkts'] = $entry['eth100gStatisticsEntryOutMulticastPackets'];
|
||||
|
||||
$port_stats[$ifIndex]['ifInDiscards'] = $entry['eth100gStatisticsEntryInDropEvents'];
|
||||
$port_stats[$ifIndex]['ifOutDiscards'] = $entry['eth100gStatisticsEntryOutDropEvents'];
|
||||
|
||||
$port_stats[$ifIndex]['ifInErrors'] = $entry['eth100gStatisticsEntryInCrcAlignErrors'];
|
||||
$port_stats[$ifIndex]['ifOutErrors'] = $entry['eth100gStatisticsEntryOutCrcAlignErrors'];
|
||||
|
||||
}
|
||||
|
||||
|
||||
// eth400gTable
|
||||
$entries = [];
|
||||
$entries = snmpwalk_cache_oid($device, 'eth400gTable', $entries, $mib);
|
||||
$entries = snmpwalk_cache_oid($device, 'eth400gStatisticsTable', $entries, $mib);
|
||||
|
||||
print_debug_vars($entries);
|
||||
|
||||
foreach ($entries as $port_oid_suffix => $port) {
|
||||
$ifIndex = $port_oid_suffix;
|
||||
$entry = isset($entries[$ifIndex]) ? $entries[$ifIndex] : [];
|
||||
|
||||
// basics
|
||||
$port_stats[$ifIndex]['ifDescr'] = $entry['eth400gAliasName'];
|
||||
$port_stats[$ifIndex]['ifName'] = $entry['eth400gAliasName'];
|
||||
$port_stats[$ifIndex]['ifAlias'] = $entry['eth400gServiceLabel'];
|
||||
$port_stats[$ifIndex]['ifOperStatus'] = $entry['eth400gOperStatus'];
|
||||
$port_stats[$ifIndex]['ifAdminStatus'] = $entry['eth400gAdminStatus'];
|
||||
$port_stats[$ifIndex]['ifType'] = 'ethernetCsmacd'; // can we do better than hard coding?
|
||||
|
||||
// stats
|
||||
$port_stats[$ifIndex]['ifInOctets'] = $entry['eth400gStatisticsEntryInOctets'];
|
||||
$port_stats[$ifIndex]['ifOutOctets'] = $entry['eth400gStatisticsEntryOutOctets'];
|
||||
|
||||
$port_stats[$ifIndex]['ifInUcastPkts'] = $entry['eth400gStatisticsEntryInPackets'];
|
||||
$port_stats[$ifIndex]['ifOutUcastPkts'] = $entry['eth400gStatisticsEntryOutPackets'];
|
||||
|
||||
$port_stats[$ifIndex]['ifInBroadcastPkts'] = $entry['eth400gStatisticsEntryInBroadcastPackets'];
|
||||
$port_stats[$ifIndex]['ifOutBroadcastPkts'] = $entry['eth400gStatisticsEntryOutBroadcastPackets'];
|
||||
|
||||
$port_stats[$ifIndex]['ifInMulticastPkts'] = $entry['eth400gStatisticsEntryInMulticastPackets'];
|
||||
$port_stats[$ifIndex]['ifOutMulticastPkts'] = $entry['eth400gStatisticsEntryOutMulticastPackets'];
|
||||
|
||||
$port_stats[$ifIndex]['ifInDiscards'] = $entry['eth400gStatisticsEntryInDropEvents'];
|
||||
$port_stats[$ifIndex]['ifOutDiscards'] = $entry['eth400gStatisticsEntryOutDropEvents'];
|
||||
|
||||
$port_stats[$ifIndex]['ifInErrors'] = $entry['eth400gStatisticsEntryInCrcAlignErrors'];
|
||||
$port_stats[$ifIndex]['ifOutErrors'] = $entry['eth400gStatisticsEntryOutCrcAlignErrors'];
|
||||
|
||||
}
|
||||
|
||||
// EOF
|
@ -6,14 +6,14 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage poller
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
global $graphs;
|
||||
|
||||
$query = 'SELECT DISTINCT `sensor_class` FROM `sensors` WHERE `device_id` = ? AND `sensor_deleted` = ?';
|
||||
$query .= generate_query_values(array_keys($config['sensor_types']), 'sensor_class'); // Limit by known classes
|
||||
$query .= generate_query_values_and(array_keys($config['sensor_types']), 'sensor_class'); // Limit by known classes
|
||||
|
||||
$sensor_classes = dbFetchColumn($query, array($device['device_id'], '0'));
|
||||
//$count = dbFetchCell('SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ? AND `sensor_deleted` = ?;', array($device['device_id'], '0'));
|
||||
|
@ -6,115 +6,68 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage poller
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$table_rows = array();
|
||||
$table_rows = [];
|
||||
|
||||
if (!isset($cache_storage)) { $cache_storage = array(); } // This cache used also in storage module
|
||||
if (!isset($cache_storage)) { $cache_storage = []; } // This cache used also in storage module
|
||||
|
||||
$sql = "SELECT `storage`.*";
|
||||
$sql .= " FROM `storage`";
|
||||
//$sql .= " LEFT JOIN `storage-state` ON `storage`.storage_id = `storage-state`.storage_id";
|
||||
$sql .= " WHERE `device_id` = ?";
|
||||
// Cache snmpwalk by definitions
|
||||
poll_cache_storage($device, $cache_storage);
|
||||
|
||||
foreach (dbFetchRows($sql, array($device['device_id'])) as $storage)
|
||||
{
|
||||
// CLEANME. Compatibility with old (incorrect) field
|
||||
$object_field = get_db_version() > 468 ? 'storage_object' : 'storage_type';
|
||||
|
||||
$sql = "SELECT * FROM `storage` WHERE `device_id` = ?";
|
||||
foreach (dbFetchRows($sql, [ $device['device_id'] ]) as $storage) {
|
||||
$storage_size = $storage['storage_size']; // Memo old size
|
||||
$file = $config['install_dir']."/includes/polling/storage/".strtolower($storage['storage_mib']).".inc.php";
|
||||
if (is_file($file))
|
||||
{
|
||||
if (is_file($file)) {
|
||||
// File based include
|
||||
include($file);
|
||||
} else {
|
||||
// Check if we can poll the device ourselves with generic code using definitions.
|
||||
// Table is always set when definitions add storage.
|
||||
if ($storage['storage_type'] != '' && is_array($config['mibs'][$storage['storage_mib']]['storage'][$storage['storage_type']]))
|
||||
{
|
||||
$table_def = $config['mibs'][$storage['storage_mib']]['storage'][$storage['storage_type']];
|
||||
// Definition based storage poller
|
||||
// Table is always set when definitions add storage.
|
||||
if (safe_empty($storage[$object_field]) || !is_array($config['mibs'][$storage['storage_mib']]['storage'][$storage[$object_field]])) {
|
||||
// Unknown, so force rediscovery as there's a broken storage
|
||||
force_discovery($device, 'storage');
|
||||
|
||||
print_r($config['mibs'][$storage['storage_mib']]['storage']);
|
||||
// CLEANME. Compat, clean after 2022/09
|
||||
if ($storage['storage_mib'] === 'NETAPP-MIB') {
|
||||
$storage['storage_object'] = 'dfEntry';
|
||||
}
|
||||
}
|
||||
|
||||
if ($table_def['type'] == 'static')
|
||||
{
|
||||
|
||||
if (isset($table_def['oid_perc_num'])) { $storage['perc'] = snmp_get_oid($device, $table_def['oid_perc_num']); }
|
||||
else if (isset($table_def['oid_perc'])) { $storage['perc'] = snmp_get_oid($device, $table_def['oid_perc'], $storage['storage_mib']); }
|
||||
|
||||
if (isset($table_def['oid_free_num'])) { $storage['free'] = snmp_get_oid($device, $table_def['oid_free_num']); }
|
||||
else if (isset($table_def['oid_free'])) { $storage['free'] = snmp_get_oid($device, $table_def['oid_free'], $storage['storage_mib']); }
|
||||
|
||||
if (isset($table_def['oid_used_num'])) { $storage['used'] = snmp_get_oid($device, $table_def['oid_used_num']); }
|
||||
else if (isset($table_def['oid_used'])) { $storage['used'] = snmp_get_oid($device, $table_def['oid_used'], $storage['storage_mib']); }
|
||||
|
||||
if (isset($table_def['total'])) { $storage['total'] = $table_def['total']; }
|
||||
else if (isset($table_def['oid_total_num'])) { $storage['total'] = snmp_get_oid($device, $table_def['oid_total_num']); }
|
||||
else if (isset($table_def['oid_total'])) { $storage['total'] = snmp_get_oid($device, $table_def['oid_total'], $storage['storage_mib']); }
|
||||
|
||||
} else {
|
||||
|
||||
if (isset($table_def['oid_perc_num'])) { $storage['perc'] = snmp_get_oid($device, $table_def['oid_perc_num'].'.'.$storage['storage_index']); }
|
||||
else if (isset($table_def['oid_perc'])) { $storage['perc'] = snmp_get_oid($device, $table_def['oid_perc'].'.'.$storage['storage_index'], $storage['storage_mib']); }
|
||||
|
||||
if (isset($table_def['oid_free_num'])) { $storage['free'] = snmp_get_oid($device, $table_def['oid_free_num'].'.'.$storage['storage_index']); }
|
||||
else if (isset($table_def['oid_free'])) { $storage['free'] = snmp_get_oid($device, $table_def['oid_free'].'.'.$storage['storage_index'], $storage['storage_mib']); }
|
||||
|
||||
if (isset($table_def['oid_used_num'])) { $storage['used'] = snmp_get_oid($device, $table_def['oid_used_num'].'.'.$storage['storage_index']); }
|
||||
else if (isset($table_def['oid_used'])) { $storage['used'] = snmp_get_oid($device, $table_def['oid_used'].'.'.$storage['storage_index'], $storage['storage_mib']); }
|
||||
|
||||
if (isset($table_def['total'])) { $storage['total'] = $table_def['total']; }
|
||||
else if (isset($table_def['oid_total_num'])) { $storage['total'] = snmp_get_oid($device, $table_def['oid_total_num'].'.'.$storage['storage_index']); }
|
||||
else if (isset($table_def['oid_total'])) { $storage['total'] = snmp_get_oid($device, $table_def['oid_total'].'.'.$storage['storage_index'], $storage['storage_mib']); }
|
||||
|
||||
}
|
||||
// Clean not numeric symbols from snmp output
|
||||
foreach (array('perc', 'free', 'used', 'total') as $param)
|
||||
{
|
||||
if (isset($storage[$param]))
|
||||
{
|
||||
// Convert strings '3.40 TB' to value
|
||||
// See QNAP NAS-MIB or HIK-DEVICE-MIB
|
||||
$unit = ($param != 'perc' && isset($table_def['unit'])) ? $table_def['unit'] : NULL;
|
||||
|
||||
$storage[$param] = snmp_fix_numeric($storage[$param], $unit);
|
||||
}
|
||||
}
|
||||
|
||||
// Merge calculated used/total/free/perc array keys into $storage variable (with additional options)
|
||||
$storage = array_merge($storage, calculate_mempool_properties($storage['storage_units'], $storage['used'], $storage['total'], $storage['free'], $storage['perc'], $table_def));
|
||||
$storage['size'] = $storage['total'];
|
||||
} else {
|
||||
// Unknown, so force rediscovery as there's a broken storage
|
||||
force_discovery($device, 'storage');
|
||||
}
|
||||
poll_storage_definition($device, $config['mibs'][$storage['storage_mib']]['storage'][$storage[$object_field]], $storage, $cache_storage);
|
||||
}
|
||||
|
||||
print_debug_vars($storage);
|
||||
|
||||
if (is_numeric($storage['used']) && $storage['size']) {
|
||||
if (is_numeric($storage['perc'])) {
|
||||
$percent = $storage['perc'];
|
||||
} elseif (is_numeric($storage['used']) && $storage['size']) {
|
||||
$percent = round(float_div($storage['used'], $storage['size']) * 100, 2);
|
||||
} else {
|
||||
$percent = 0;
|
||||
}
|
||||
|
||||
if (!isset($storage['units']))
|
||||
{
|
||||
if (!isset($storage['units'])) {
|
||||
$storage['units'] = $storage['storage_units'];
|
||||
}
|
||||
|
||||
$hc = ($storage['storage_hc'] ? ' (HC)' : '');
|
||||
|
||||
// Update StatsD/Carbon
|
||||
if ($config['statsd']['enable'] == TRUE)
|
||||
{
|
||||
if ($config['statsd']['enable'] == TRUE) {
|
||||
StatsD::gauge(str_replace(".", "_", $device['hostname']).'.'.'storage'.'.' .$storage['storage_mib'] . "-" . safename($storage['storage_descr']).".used", $storage['used']);
|
||||
StatsD::gauge(str_replace(".", "_", $device['hostname']).'.'.'storage'.'.' .$storage['storage_mib'] . "-" . safename($storage['storage_descr']).".free", $storage['free']);
|
||||
}
|
||||
|
||||
// Update RRD
|
||||
|
||||
|
||||
rrdtool_update_ng($device, 'storage', array('used' => $storage['used'], 'free' => $storage['free']), strtolower($storage['storage_mib']) . "-" . $storage['storage_descr']);
|
||||
rrdtool_update_ng($device, 'storage', [ 'used' => $storage['used'], 'free' => $storage['free'] ], strtolower($storage['storage_mib']) . "-" . $storage['storage_descr']);
|
||||
|
||||
//if (!is_numeric($storage['storage_polled']))
|
||||
//{
|
||||
@ -126,15 +79,14 @@ foreach (dbFetchRows($sql, array($device['device_id'])) as $storage)
|
||||
// 'storage_units' => $storage['units'],
|
||||
// 'storage_perc' => $percent), 'storage-state');
|
||||
//} else {
|
||||
$update = dbUpdate(array('storage_polled' => time(),
|
||||
'storage_used' => $storage['used'],
|
||||
'storage_free' => $storage['free'],
|
||||
'storage_size' => $storage['size'],
|
||||
'storage_units' => $storage['units'],
|
||||
'storage_perc' => $percent), 'storage', '`storage_id` = ?', array($storage['storage_id']));
|
||||
if (formatStorage($storage_size) != formatStorage($storage['size']))
|
||||
$update = dbUpdate([ 'storage_polled' => time(),
|
||||
'storage_used' => $storage['used'],
|
||||
'storage_free' => $storage['free'],
|
||||
'storage_size' => $storage['size'],
|
||||
'storage_units' => $storage['units'],
|
||||
'storage_perc' => $percent ], 'storage', '`storage_id` = ?', [ $storage['storage_id'] ]);
|
||||
if (formatStorage($storage_size) != formatStorage($storage['size'])) {
|
||||
//&& (abs($storage_size - $storage['size']) / max($storage_size, $storage['size'])) > 0.0001 ) // Log only if size diff more than 0.01%
|
||||
{
|
||||
log_event('Storage size changed: '.formatStorage($storage_size).' -> '.formatStorage($storage['size']).' ('.$storage['storage_descr'].')', $device, 'storage', $storage['storage_id']);
|
||||
}
|
||||
//}
|
||||
@ -156,7 +108,7 @@ foreach (dbFetchRows($sql, array($device['device_id'])) as $storage)
|
||||
|
||||
}
|
||||
|
||||
$headers = array('%WLabel%n', '%WType%n', '%WIndex%n', '%WTotal%n', '%WUsed%n', '%WFree%n', '%WPerc%n');
|
||||
$headers = array('%WLabel%n', '%MIB%n', '%WIndex%n', '%WTotal%n', '%WUsed%n', '%WFree%n', '%WPerc%n');
|
||||
print_cli_table($table_rows, $headers);
|
||||
|
||||
unset($storage, $table, $table_row, $table_rows, $unit);
|
||||
|
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage poller
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
// EMBEDDED-NGX-MIB
|
||||
|
||||
if (!is_array($cache_storage['embedded-ngx-mib']))
|
||||
{
|
||||
$cache_storage['embedded-ngx-mib'] = snmpwalk_cache_oid($device, "swStorage", NULL, "EMBEDDED-NGX-MIB");
|
||||
if (OBS_DEBUG && count($cache_storage['embedded-ngx-mib'])) { print_vars($cache_storage['embedded-ngx-mib']); }
|
||||
}
|
||||
|
||||
$entry = $cache_storage['embedded-ngx-mib'][$storage['storage_index']];
|
||||
|
||||
$storage['units'] = 1024;
|
||||
$storage['size'] = $entry['swStorageConfigTotal'] * $storage['units'];
|
||||
$storage['free'] = $entry['swStorageConfigFree'] * $storage['units'];
|
||||
|
||||
$storage['used'] = $storage['size'] - $storage['free'];
|
||||
|
||||
// EOF
|
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage poller
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
echo(' GPFS-MIB: ');
|
||||
|
||||
$index = $storage['storage_index'];
|
||||
|
||||
if (!is_array($cache_storage['gpfs-mib']))
|
||||
{
|
||||
foreach (array('gpfsFileSystemTotalSpaceL', 'gpfsFileSystemTotalSpaceH', 'gpfsFileSystemFreeSpaceL', 'gpfsFileSystemFreeSpaceH') as $param)
|
||||
{
|
||||
$cache_storage['gpfs-mib'] = snmpwalk_cache_oid($device, $param, $cache_storage['gpfs-mib'], 'GPFS-MIB');
|
||||
}
|
||||
if (OBS_DEBUG && count($cache_storage['gpfs-mib'])) { print_vars($cache_storage['gpfs-mib']); }
|
||||
}
|
||||
|
||||
|
||||
$entry = $cache_storage['gpfs-mib'][$index];
|
||||
|
||||
$storage['units'] = 1024; // Hardcode units.
|
||||
$storage['size'] = snmp_size64_high_low($entry['gpfsFileSystemTotalSpaceH'], $entry['gpfsFileSystemTotalSpaceL']) * 1024;
|
||||
$storage['free'] = snmp_size64_high_low($entry['gpfsFileSystemFreeSpaceH'], $entry['gpfsFileSystemFreeSpaceL']) * 1024;
|
||||
$storage['used'] = $storage['size'] - $storage['free'];
|
||||
|
||||
unset($index, $entry);
|
||||
|
||||
// EOF
|
@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage poller
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
// EMBEDDED-NGX-MIB
|
||||
|
||||
if (!is_array($cache_storage['ISILON-MIB']))
|
||||
{
|
||||
$cache_storage['ISILON-MIB'] = snmp_get_multi_oid($device, 'ifsTotalBytes.0 ifsUsedBytes.0', array(), 'ISILON-MIB');
|
||||
}
|
||||
|
||||
$entry = $cache_storage['ISILON-MIB'][$storage['storage_index']];
|
||||
|
||||
$storage['units'] = 1;
|
||||
$storage['size'] = $entry['ifsTotalBytes'];
|
||||
$storage['used'] = $entry['ifsUsedBytes'];
|
||||
|
||||
$storage['free'] = $storage['size'] - $storage['used'];
|
||||
|
||||
// EOF
|
@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage poller
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
// NETAPP-MIB
|
||||
//echo(' NETAPP-MIB: ');
|
||||
|
||||
$index = $storage['storage_index'];
|
||||
|
||||
if ($storage['storage_hc'])
|
||||
{
|
||||
$netapp_oids = array('size' => 'df64TotalKBytes', 'used' => 'df64UsedKBytes', 'free' => 'df64AvailKBytes');
|
||||
|
||||
if (!is_array($cache_storage['netapp-mib-hc']))
|
||||
{
|
||||
foreach (array('size', 'used', 'free') as $param)
|
||||
{
|
||||
$oid = $netapp_oids[$param];
|
||||
$cache_storage['netapp-mib-hc'] = snmpwalk_cache_oid($device, $oid, $cache_storage['netapp-mib-hc'], 'NETAPP-MIB');
|
||||
}
|
||||
if (OBS_DEBUG && count($cache_storage['netapp-mib-hc'])) { print_vars($cache_storage['netapp-mib-hc']); }
|
||||
}
|
||||
$entry = $cache_storage['netapp-mib-hc'][$index];
|
||||
} else {
|
||||
$netapp_oids = array('size' => 'dfKBytesTotal', 'used' => 'dfKBytesUsed', 'free' => 'dfKBytesAvail');
|
||||
|
||||
if (!is_array($cache_storage['netapp-mib']))
|
||||
{
|
||||
foreach (array('size', 'used', 'free') as $param)
|
||||
{
|
||||
$oid = $netapp_oids[$param];
|
||||
$cache_storage['netapp-mib'] = snmpwalk_cache_oid($device, $oid, $cache_storage['netapp-mib'], 'NETAPP-MIB');
|
||||
}
|
||||
if (OBS_DEBUG && count($cache_storage['netapp-mib'])) { print_vars($cache_storage['netapp-mib']); }
|
||||
}
|
||||
$entry = $cache_storage['netapp-mib-hc'][$index];
|
||||
}
|
||||
|
||||
$storage['units'] = 1024; // Hardcode units.
|
||||
foreach (array('size', 'used', 'free') as $param)
|
||||
{
|
||||
$oid = $netapp_oids[$param];
|
||||
$storage[$param] = $entry[$oid] * $storage['units'];
|
||||
}
|
||||
|
||||
unset($index, $entry, $param, $netapp_oids);
|
||||
|
||||
// EOF
|
@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage poller
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$index = $storage['storage_index'];
|
||||
|
||||
if (!is_array($cache_storage['NIMBLE-MIB']))
|
||||
{
|
||||
foreach (array('volSizeLow', 'volSizeHigh', 'volUsageLow', 'volUsageHigh', 'volOnline') as $param)
|
||||
{
|
||||
$cache_storage['NIMBLE-MIB'] = snmpwalk_cache_oid($device, $param, $cache_storage['NIMBLE-MIB'], 'NIMBLE-MIB');
|
||||
}
|
||||
if (OBS_DEBUG > 1 && count($cache_storage['NIMBLE-MIB'])) { print_vars($cache_storage['NIMBLE-MIB']); }
|
||||
}
|
||||
|
||||
$entry = $cache_storage['NIMBLE-MIB'][$index];
|
||||
|
||||
// FIXME, probably need additional field for storages like OperStatus up/down
|
||||
$ignore = in_array($entry['volOnline'], array('0', 'false')) ? 1 : 0;
|
||||
if ($storage['storage_ignore'] != $ignore)
|
||||
{
|
||||
force_discovery($device, 'storage');
|
||||
}
|
||||
|
||||
$storage['units'] = 1048576; // Hardcode units. In MIB is written that bytes, but really Mbytes
|
||||
$storage['size'] = snmp_size64_high_low($entry['volSizeHigh'], $entry['volSizeLow']) * $storage['units'];
|
||||
$storage['used'] = snmp_size64_high_low($entry['volUsageHigh'], $entry['volUsageLow']) * $storage['units'];
|
||||
$storage['free'] = $storage['size'] - $storage['used'];
|
||||
|
||||
unset($index, $entry, $ignore);
|
||||
|
||||
// EOF
|
@ -45,9 +45,9 @@ if (!isset($polled)) {
|
||||
|
||||
if (isset($agent_data['uptime'])) {
|
||||
list($agent_data['uptime']) = explode(' ', $agent_data['uptime']);
|
||||
$uptimes['unix-agent'] = round($agent_data['uptime']);
|
||||
$uptimes['unix-agent'] = round((float)$agent_data['uptime']);
|
||||
} elseif (isset($wmi['uptime'])) {
|
||||
$uptimes['wmi'] = round($wmi['uptime']);
|
||||
$uptimes['wmi'] = round((float)$wmi['uptime']);
|
||||
}
|
||||
|
||||
if (is_numeric($agent_data['uptime']) && $agent_data['uptime'] > 0) {
|
||||
@ -61,9 +61,9 @@ if (is_numeric($agent_data['uptime']) && $agent_data['uptime'] > 0) {
|
||||
} elseif (isset($poll_device['device_uptime']) && is_numeric($poll_device['device_uptime']) && $poll_device['device_uptime'] > 0) {
|
||||
// 2. Uptime from os specific OID, see in includes/polling/system MIB specific
|
||||
// Get uptime by some custom way in device os poller, see example in wowza-engine os poller
|
||||
$uptimes['device_uptime'] = round($poll_device['device_uptime']);
|
||||
$uptimes['device_uptime'] = round((float)$poll_device['device_uptime']);
|
||||
$uptimes['use'] = 'device_uptime';
|
||||
$uptimes['message'] = ($uptimes['message']) ? $uptimes['message'] : 'Using device MIB poller Uptime';
|
||||
$uptimes['message'] = $uptimes['message'] ?: 'Using device MIB poller Uptime';
|
||||
} else {
|
||||
// 3. Uptime from hrSystemUptime (only in snmp v2c/v3)
|
||||
// NOTE, about windows uptime,
|
||||
@ -76,46 +76,39 @@ if (is_numeric($agent_data['uptime']) && $agent_data['uptime'] > 0) {
|
||||
$hrSystemUptime = snmp_get_oid($device, 'hrSystemUptime.0', 'HOST-RESOURCES-MIB');
|
||||
$uptimes['hrSystemUptime'] = timeticks_to_sec($hrSystemUptime);
|
||||
|
||||
if (is_numeric($uptimes['hrSystemUptime']) && $uptimes['hrSystemUptime'] > 0)
|
||||
{
|
||||
if (is_numeric($uptimes['hrSystemUptime']) && $uptimes['hrSystemUptime'] > 0) {
|
||||
// hrSystemUptime always prefer if not zero
|
||||
$uptimes['use'] = 'hrSystemUptime';
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Uptime from snmpEngineTime (only in snmp v2c/v3)
|
||||
if ($device['snmp_version'] !== 'v1' && is_device_mib($device, 'SNMP-FRAMEWORK-MIB'))
|
||||
{
|
||||
if ($device['snmp_version'] !== 'v1' && is_device_mib($device, 'SNMP-FRAMEWORK-MIB')) {
|
||||
$snmpEngineTime = snmp_get_oid($device, 'snmpEngineTime.0', 'SNMP-FRAMEWORK-MIB');
|
||||
|
||||
if (is_numeric($snmpEngineTime) && $snmpEngineTime > 0)
|
||||
{
|
||||
if ($device['os'] === 'aos' && strlen($snmpEngineTime) > 8)
|
||||
{
|
||||
if (is_numeric($snmpEngineTime) && $snmpEngineTime > 0) {
|
||||
if ($device['os'] === 'aos' && strlen($snmpEngineTime) > 8) {
|
||||
// Some Alcatel have bug with snmpEngineTime
|
||||
// See: http://jira.observium.org/browse/OBSERVIUM-763
|
||||
$snmpEngineTime = 0;
|
||||
}
|
||||
elseif ($device['os'] === 'ironware')
|
||||
{
|
||||
} elseif ($device['os'] === 'ironware') {
|
||||
// Check if version correct like "07.4.00fT7f3"
|
||||
$ironware_version = explode('.', $device['version']);
|
||||
if (count($ironware_version) > 2 && $ironware_version[0] > 0 && version_compare($device['version'], '5.1.0') === -1)
|
||||
{
|
||||
if (count($ironware_version) > 2 && $ironware_version[0] > 0 &&
|
||||
version_compare($device['version'], '5.1.0') === -1) {
|
||||
// IronWare before Release 05.1.00b have bug (firmware returning snmpEngineTime * 10)
|
||||
// See: http://jira.observium.org/browse/OBSERVIUM-1199
|
||||
$snmpEngineTime /= 10;
|
||||
}
|
||||
}
|
||||
$uptimes['snmpEngineTime'] = intval($snmpEngineTime);
|
||||
$uptimes['snmpEngineTime'] = (int)$snmpEngineTime;
|
||||
|
||||
if ($uptimes['use'] === 'hrSystemUptime')
|
||||
{
|
||||
if ($uptimes['use'] === 'hrSystemUptime') {
|
||||
// Prefer snmpEngineTime only if more than hrSystemUptime
|
||||
if ($uptimes['snmpEngineTime'] > $uptimes['hrSystemUptime']) { $uptimes['use'] = 'snmpEngineTime'; }
|
||||
}
|
||||
elseif ($uptimes['snmpEngineTime'] >= $uptimes['sysUpTime'])
|
||||
{
|
||||
if ($uptimes['snmpEngineTime'] > $uptimes['hrSystemUptime']) {
|
||||
$uptimes['use'] = 'snmpEngineTime';
|
||||
}
|
||||
} elseif ($uptimes['snmpEngineTime'] >= $uptimes['sysUpTime']) {
|
||||
// in other cases prefer if more than sysUpTime
|
||||
$uptimes['use'] = 'snmpEngineTime';
|
||||
}
|
||||
@ -378,14 +371,16 @@ if ($poll_empty_count >= 2) {
|
||||
|
||||
// Check if both (sysObjectID and sysDescr) changed, force full device rediscovery
|
||||
if (!$force_discovery && // Check if not already forced
|
||||
isset($update_array['sysObjectID']) && isset($update_array['sysDescr']) &&
|
||||
isset($update_array['sysObjectID'], $update_array['sysDescr']) &&
|
||||
strlen($poll_device['sysObjectID']) && strlen($device['sysObjectID']) &&
|
||||
strlen($poll_device['sysDescr']) && strlen($device['sysDescr']))
|
||||
{
|
||||
strlen($poll_device['sysDescr']) && strlen($device['sysDescr'])) {
|
||||
log_event('sysObjectID and sysDescr changed: seems the device was replaced. The device will be rediscovered.', $device, 'device', $device['device_id'], 4);
|
||||
force_discovery($device);
|
||||
}
|
||||
|
||||
if (!empty($device['snmpable'])) {
|
||||
print_cli_data('SNMPable OID', $device['snmpable'], 2);
|
||||
}
|
||||
print_cli_data('sysObjectID', $poll_device['sysObjectID'], 2);
|
||||
print_cli_data('snmpEngineID', $poll_device['snmpEngineID'], 2);
|
||||
print_cli_data('sysDescr', $poll_device['sysDescr'], 2);
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
@ -7,68 +6,63 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage poller
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
global $agent_sensors;
|
||||
|
||||
if ($agent_data['nvidia']['smi'] != '')
|
||||
{
|
||||
if (!safe_empty($agent_data['nvidia']['smi'])) {
|
||||
|
||||
$invalid = [ '[Not Supported]', 'N/A', '[N/A]' ];
|
||||
$nvidia = parse_csv($agent_data['nvidia']['smi']);
|
||||
if (count($nvidia))
|
||||
{
|
||||
if (safe_count($nvidia)) {
|
||||
|
||||
print_cli_heading("nvidia-smi", 3);
|
||||
foreach ($nvidia as $card)
|
||||
{
|
||||
foreach ($nvidia as $card) {
|
||||
|
||||
$descr_card = "Nvidia Card ".($card['index']+1).": ".$card['name'];
|
||||
print_cli_heading($descr_card, 4);
|
||||
|
||||
if (!in_array($card['temperature.gpu'], ['[Not Supported]', 'N/A', '[N/A]']))
|
||||
{
|
||||
if (!in_array($card['temperature.gpu'], $invalid)) {
|
||||
$index = 'temperature.gpu.'.$card['index'];
|
||||
$descr = $descr_card;
|
||||
discover_sensor('temperature', $device, '', $index, 'nvidia-smi', $descr, 1, $card['temperature.gpu'], ['limit_high' => 100], 'agent');
|
||||
$agent_sensors['temperature']['nvidia-smi'][$index] = array('description' => $descr, 'current' => $card['temperature.gpu'], 'index' => $index);
|
||||
discover_sensor('temperature', $device, '', $index, 'nvidia-smi', $descr, 1, $card['temperature.gpu'], [ 'limit_high' => 100 ], 'agent');
|
||||
$agent_sensors['temperature']['nvidia-smi'][$index] = [ 'description' => $descr, 'current' => $card['temperature.gpu'], 'index' => $index ];
|
||||
print_cli_data("temperature.gpu", $card['temperature.gpu']."C");
|
||||
|
||||
}
|
||||
|
||||
if (!in_array($card['power.draw [W]'], ['[Not Supported]', 'N/A', '[N/A]']))
|
||||
{
|
||||
if (!in_array($card['power.draw [W]'], $invalid)) {
|
||||
$index = 'power.draw.'.$card['index'];
|
||||
$descr = $descr_card;
|
||||
discover_sensor('power', $device, '', $index, 'nvidia-smi', $descr, 1, $card['power.draw [W]'], array(), 'agent');
|
||||
$agent_sensors['power']['nvidia-smi'][$index] = array('description' => $descr, 'current' => $card['power.draw [W]'], 'index' => $index);
|
||||
discover_sensor('power', $device, '', $index, 'nvidia-smi', $descr, 1, $card['power.draw [W]'], [], 'agent');
|
||||
$agent_sensors['power']['nvidia-smi'][$index] = [ 'description' => $descr, 'current' => $card['power.draw [W]'], 'index' => $index ];
|
||||
print_cli_data("power.draw", $card['power.draw [W]']."W");
|
||||
}
|
||||
|
||||
if (!in_array($card['fan.speed [%]'], ['[Not Supported]', 'N/A', '[N/A]']))
|
||||
{
|
||||
if (!in_array($card['fan.speed [%]'], $invalid)) {
|
||||
$index = 'fan.speed.'.$card['index'];
|
||||
$descr = $descr_card . " Fan Load";
|
||||
discover_sensor('load', $device, '', $index, 'nvidia-smi', $descr, 1, $card['fan.speed [%]'], ['limit_high' => 100, 'limit_low' => 0], 'agent');
|
||||
$agent_sensors['load']['nvidia-smi'][$index] = array('description' => $descr, 'current' => $card['fan.speed [%]'], 'index' => $index);
|
||||
discover_sensor('load', $device, '', $index, 'nvidia-smi', $descr, 1, $card['fan.speed [%]'], [ 'limit_high' => 100, 'limit_low' => 0 ], 'agent');
|
||||
$agent_sensors['load']['nvidia-smi'][$index] = [ 'description' => $descr, 'current' => $card['fan.speed [%]'], 'index' => $index ];
|
||||
print_cli_data("fan.speed", $card['fan.speed [%]']."");
|
||||
}
|
||||
|
||||
if (!in_array($card['utilisation.gpu [%]'], ['[Not Supported]', 'N/A', '[N/A]']))
|
||||
{
|
||||
$index = 'utilisation.gpu.'.$card['index'];
|
||||
if (!in_array($card['utilization.gpu [%]'], $invalid)) {
|
||||
$index = 'utilization.gpu.'.$card['index'];
|
||||
$descr = $descr_card . " GPU Load";
|
||||
discover_sensor('load', $device, '', $index, 'nvidia-smi', $descr, 1, $card['fan.speed [%]'], ['limit_high' => 100, 'limit_low' => 0], 'agent');
|
||||
$agent_sensors['load']['nvidia-smi'][$index] = array('description' => $descr, 'current' => $card['utilisation.gpu [%]'], 'index' => $index);
|
||||
print_cli_data("utilisation.gpu", $card['utilisation.gpu [%]']."");
|
||||
discover_sensor('load', $device, '', $index, 'nvidia-smi', $descr, 1, $card['utilization.gpu [%]'], [ 'limit_high' => 100, 'limit_low' => 0 ], 'agent');
|
||||
$agent_sensors['load']['nvidia-smi'][$index] = [ 'description' => $descr, 'current' => $card['utilization.gpu [%]'], 'index' => $index ];
|
||||
print_cli_data("utilization.gpu", $card['utilization.gpu [%]']."");
|
||||
}
|
||||
|
||||
if (!in_array($card['utilisation.memory [%]'], ['[Not Supported]', 'N/A', '[N/A]']))
|
||||
{
|
||||
$index = 'utilisation.memory.'.$card['index'];
|
||||
if (!in_array($card['utilization.memory [%]'], $invalid)) {
|
||||
$index = 'utilization.memory.'.$card['index'];
|
||||
$descr = $descr_card . " Memory Load";
|
||||
discover_sensor('load', $device, '', $index, 'nvidia-smi', $descr, 1, $card['fan.speed [%]'], ['limit_high' => 100, 'limit_low' => 0], 'agent');
|
||||
$agent_sensors['load']['nvidia-smi'][$index] = array('description' => $descr, 'current' => $card['utilisation.memory [%]'], 'index' => $index);
|
||||
print_cli_data("utilisation.memory", $card['utilisation.memory [%]']."");
|
||||
discover_sensor('load', $device, '', $index, 'nvidia-smi', $descr, 1, $card['utilization.memory [%]'], [ 'limit_high' => 100, 'limit_low' => 0 ], 'agent');
|
||||
$agent_sensors['load']['nvidia-smi'][$index] = [ 'description' => $descr, 'current' => $card['utilization.memory [%]'], 'index' => $index ];
|
||||
print_cli_data("utilization.memory", $card['utilization.memory [%]']."");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ if (!safe_empty($pkgs_db_id)) {
|
||||
log_event('Package removed: ' . $pkg['name'] . ' ' . $pkg['arch'] . ' ' . $pkg['version'] . ($pkg['build'] != '' ? "-" . $pkg['build'] : ''), $device, 'package');
|
||||
}
|
||||
// Multi delete
|
||||
dbDelete('packages', generate_query_values(array_keys($pkgs_db_id), 'pkg_id', NULL, OBS_DB_NO_LEADING_AND));
|
||||
dbDelete('packages', generate_query_values_ng(array_keys($pkgs_db_id), 'pkg_id'));
|
||||
}
|
||||
|
||||
echo(PHP_EOL);
|
||||
|
Reference in New Issue
Block a user