<?php /* * LibreNMS module to create sensors from Cisco Integrated Management Controllers (CIMC) * * Copyright (c) 2016 Aaron Daniels <*****@*****.**> * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or (at your * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ if ($device['os'] == 'cimc') { // Let's add some power sensors. $pwr_board = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.719.1.9.14'); /* * False == OID not found - this is not an error. * null == timeout or something else that caused an error. */ if (is_null($pwr_board)) { echo "Error\n"; } else { // No Error, lets process things. $index = 1; // Board Input Power $oid = '.1.3.6.1.4.1.9.9.719.1.9.14.1.4'; $description = "MB Input Power"; d_echo($oid . " - " . $description . " - " . $pwr_board[$oid][$index] . "\n"); discover_sensor($valid['sensor'], 'power', $device, $oid . "." . $index, 'mb-input-power', 'cimc', $description, '1', '1', null, null, null, null, $temp_board[$oid][$index]); // Board Input Current
<?php // Gather our SLA's from the DB. $slas = dbFetchRows('SELECT * FROM `slas` WHERE `device_id` = ? AND `deleted` = 0', array($device['device_id'])); if (count($slas) > 0) { // We have SLA's, lets go!!! // Go get some data from the device. $rttMonLatestRttOperTable = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.42.1.2.10.1', 1); $rttMonLatestOper = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.42.1.5', 1); $uptime = snmp_get($device, 'sysUpTime.0', '-Otv'); $time_offset = time() - intval($uptime) / 100; foreach ($slas as $sla) { $sla_nr = $sla['sla_nr']; $rtt_type = $sla['rtt_type']; // Lets process each SLA $unixtime = intval($rttMonLatestRttOperTable['1.3.6.1.4.1.9.9.42.1.2.10.1.5'][$sla_nr] / 100 + $time_offset); $time = strftime('%Y-%m-%d %H:%M:%S', $unixtime); $update = array(); // Use Nagios Status codes. $opstatus = $rttMonLatestRttOperTable['1.3.6.1.4.1.9.9.42.1.2.10.1.2'][$sla_nr]; if ($opstatus == 1) { $opstatus = 0; // 0=Good } else { $opstatus = 2; // 2=Critical } // Populating the update array means we need to update the DB. if ($opstatus != $sla['opstatus']) { $update['opstatus'] = $opstatus; }
$error_overlay[5] = "createAndWait"; $error_overlay[6] = "destroy"; $module = 'Cisco-OTV'; $component = new LibreNMS\Component(); $options['filter']['type'] = array('=', $module); $options['filter']['disabled'] = array('=', 0); $components = $component->getComponents($device['device_id'], $options); // We only care about our device id. $components = $components[$device['device_id']]; // Only collect SNMP data if we have enabled components if (count($components > 0)) { // Let's gather the stats.. $tblOverlayEntry = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.810.1.2.1.1'); $tblAdjacencyDatabaseEntry = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.810.1.3.1.1', 0); $tblRouteNextHopAddr = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.810.1.5.1.1.8', 0); $tblVlanEdgeDevIsAed = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.810.1.2.2.1.6', 2); // Let's create an array of each remote OTV endpoint and the count of MAC addresses that are reachable via. $count_mac = array(); foreach ($tblRouteNextHopAddr as $k => $v) { $count_mac[$v]++; } // Let's log some debugging d_echo("\n\nMAC Addresses: " . print_r($count_mac, true)); // Loop through the components and extract the data. foreach ($components as $key => &$array) { if ($array['otvtype'] == 'overlay') { // Let's check the various status' of the overlay $message = false; $vpn_state = $tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.3'][$array['index']]; if ($vpn_state != 2) { $message .= "VPN Down: " . $error_vpn[$tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.4'][$array['index']]];
* the source code distribution for details. */ if ($device['os_group'] == "cisco") { $module = 'Cisco-CBQOS'; require_once 'includes/component.php'; $component = new component(); $options['filter']['type'] = array('=', $module); $options['filter']['disabled'] = array('=', 0); $options['filter']['ignore'] = array('=', 0); $components = $component->getComponents($device['device_id'], $options); // We only care about our device id. $components = $components[$device['device_id']]; // Only collect SNMP data if we have enabled components if (count($components > 0)) { // Let's gather the stats.. $tblcbQosClassMapStats = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.166.1.15.1.1', 2); // Loop through the components and extract the data. foreach ($components as $key => $array) { $type = $array['qos-type']; // Get data from the class table. if ($type == 2) { // Let's make sure the rrd is setup for this class. $filename = "port-" . $array['ifindex'] . "-cbqos-" . $array['sp-id'] . "-" . $array['sp-obj'] . ".rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename($filename); if (!file_exists($rrd_filename)) { rrdtool_create($rrd_filename, " DS:postbits:COUNTER:600:0:U DS:bufferdrops:COUNTER:600:0:U DS:qosdrops:COUNTER:600:0:U" . $config['rrd_rra']); } // Let's print some debugging info. d_echo("\n\nComponent: " . $key . "\n"); d_echo(" Class-Map: " . $array['label'] . "\n"); d_echo(" SPID.SPOBJ: " . $array['sp-id'] . "." . $array['sp-obj'] . "\n");
* Free Software Foundation, either version 3 of the License, or (at your * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ $module = 'ntp'; $component = new LibreNMS\Component(); $components = $component->getComponents($device['device_id'], array('type' => $module)); // We only care about our device id. $components = $components[$device['device_id']]; // Begin our master array, all other values will be processed into this array. $tblComponents = array(); // Let's gather some data.. // For Reference: // http://www.oidview.com/mibs/9/CISCO-NTP-MIB.html // http://www.cisco.com/c/en/us/support/docs/availability/high-availability/19643-ntpm.html $cntpPeersVarEntry = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.168.1.2.1.1', 2); /* * False == no object found - this is not an error, no objects exist * null == timeout or something else that caused an error, there may be objects but we couldn't get it. */ if (is_null($cntpPeersVarEntry)) { // We have to error here or we will end up deleting all our components. echo "Error\n"; } else { // No Error, lets process things. d_echo("Objects Found:\n"); // Let's grab the index for each NTP peer foreach ($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][2] as $index => $value) { $result = array(); $result['UID'] = (string) $index; // This is cast as a string so it can be compared with the database value.
/* * LibreNMS module to create sensors from Cisco Integrated Management Controllers (CIMC) * * Copyright (c) 2016 Aaron Daniels <*****@*****.**> * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or (at your * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ if ($device['os'] == 'cimc') { // Let's add some temperature sensors. $temp_board = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.719.1.9.44.1'); $temp_mem = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.719.1.30.12.1'); $temp_cpu = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.719.1.41'); /* * False == OID not found - this is not an error. * null == timeout or something else that caused an error. */ if (is_null($temp_board) || is_null($temp_mem) || is_null($temp_cpu)) { echo "Error\n"; } else { // No Error, lets process things. // Board Temperatures foreach ($temp_board['1.3.6.1.4.1.9.9.719.1.9.44.1.2'] as $index => $string) { $temp = preg_match('/sys\\/(rack-unit-[^,]+)\\/board\\/temp-stats/', $string, $regexp_result); $description = $regexp_result[1]; // Ambient Temperature $oid = '.1.3.6.1.4.1.9.9.719.1.9.44.1.4' . $index; d_echo($oid . " - " . $description . " - Ambient: " . $temp_board[$oid][$index] . "\n");
*/ if ($device['os_group'] == 'cisco') { $module = 'Cisco-CBQOS'; require_once 'includes/component.php'; $component = new component(); $components = $component->getComponents($device['device_id'], array('type' => $module)); // We only care about our device id. $components = $components[$device['device_id']]; // Begin our master array, all other values will be processed into this array. $tblCBQOS = array(); // Let's gather some data.. $tblcbQosServicePolicy = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.166.1.1'); $tblcbQosObjects = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.166.1.5', 2); $tblcbQosPolicyMapCfg = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.166.1.6'); $tblcbQosClassMapCfg = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.166.1.7'); $tblcbQosMatchStmtCfg = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.166.1.8'); /* * False == no object found - this is not an error, there is no QOS configured * null == timeout or something else that caused an error, there may be QOS configured but we couldn't get it. */ if (is_null($tblcbQosServicePolicy) || is_null($tblcbQosObjects) || is_null($tblcbQosPolicyMapCfg) || is_null($tblcbQosClassMapCfg) || is_null($tblcbQosMatchStmtCfg)) { // We have to error here or we will end up deleting all our QoS components. echo "Error\n"; } else { // No Error, lets process things. d_echo("QoS Objects Found:\n"); foreach ($tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.2'] as $spid => $array) { foreach ($array as $spobj => $index) { $result = array(); // Produce a unique reproducible index for this entry. $result['UID'] = hash('crc32', $spid . "-" . $spobj);
$error_overlay[3] = "notReady"; $error_overlay[4] = "createAndGo"; $error_overlay[5] = "createAndWait"; $error_overlay[6] = "destroy"; $module = 'Cisco-OTV'; $component = new LibreNMS\Component(); $components = $component->getComponents($device['device_id'], array('type' => $module)); // We only care about our device id. $components = $components[$device['device_id']]; // Begin our master array, all other values will be processed into this array. $tblOTV = array(); $tblEndpoints = array(); // Let's gather some data.. $tblOverlayEntry = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.810.1.2.1.1'); $tblAdjacencyDatabaseEntry = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.810.1.3.1.1', 0); $tblAdjacentDevName = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.810.1.3.1.1.4', 0); /* * False == no object found - this is not an error, there is no QOS configured * null == timeout or something else that caused an error, there may be QOS configured but we couldn't get it. */ if (is_null($tblOverlayEntry) || is_null($tblAdjacencyDatabaseEntry) || is_null($tblAdjacentDevName)) { // We have to error here or we will end up deleting all our components. echo "Error\n"; } else { // No Error, lets process things. // Add each overlay to the array. foreach ($tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.2'] as $index => $name) { $result = array(); $message = false; $result['index'] = $index; $result['label'] = $name;
* * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or (at your * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ $comp_module = 'Cisco-CIMC'; $component = new LibreNMS\Component(); $components = $component->getComponents($device['device_id'], array('type' => $comp_module)); // We only care about our device id. $components = $components[$device['device_id']]; // Begin our master array, all other values will be processed into this array. $tblCIMC = array(); // Let's gather some data.. $tblUCSObjects = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.719.1', 2); /* * False == no object found - this is not an error, there is no QOS configured * null == timeout or something else that caused an error, the OID's may be present but we couldn't get them. */ if (is_null($tblUCSObjects)) { // We have to error here or we will end up deleting all our components. } else { // No Error, lets process things. echo "CIMC Hardware Found: "; // Make sure we have an array before we try to iterate over it if (is_array($tblUCSObjects)) { // Gather entPhysical data $entmax = 0; $entphysical = array(); $dbentphysical = $entries = dbFetchRows('SELECT * FROM entPhysical WHERE device_id=?', array($device['device_id']));
<?php if ($device['os'] == 'routeros' || 1) { $oids = snmp_walk($device, 'flowMeter', '-OsqnU', 'DOMOTICS-MIB'); d_echo($oids . "\n"); if ($oids !== false) { echo 'DOMOTICS-MIB '; $class = 'domotics'; $names = reset(snmpwalk_array_num($device, 'flowMeterDescr')); $idxs = reset(snmpwalk_array_num($device, 'flowMeterIndex')); $typeMap = array('TempIn' => 'temperature', 'TempOut' => 'temperature', 'AmbientTemp' => 'temperature', 'Humidity' => 'humidity', 'Flow' => 'flow'); foreach ($typeMap as $what => $type) { $labels = reset(snmpwalk_array_num($device, 'flowMeter' . $what . 'Label')); $divs = reset(snmpwalk_array_num($device, 'flowMeter' . $what . 'Divisor')); $oidvals = snmpwalk_array_num($device, 'flowMeter' . $what); $vals = reset($oidvals); $baseoid = key($oidvals); if ($vals) { foreach ($idxs as $index => $pubIndex) { $oid = $baseoid . '.' . $index; if (!$labels[$index]) { $labels[$index] = $type; } $descr = $labels[$index] . ' ' . $names[$index] . '/' . $pubIndex; $divisor = $divs[$index]; $temperature = $vals[$index]; discover_sensor($valid['sensor'], $type, $device, $oid, $index, $class, $descr, $divisor ? $divisor : 1, '1', null, null, null, null, $temperature); // discover_sensor($valid['sensor'], 'temperature', $device, $oid, 1, 'extreme-temp', $descr, '1', '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $value); } } }