$ip_ver = 'ipv4'; } $peer_identifier = $ip_type . '.' . $ip_len . '.' . $bgp_peer_ident; $peer_data_tmp = snmp_get_multi($device, ' cbgpPeer2State.' . $peer_identifier . ' cbgpPeer2AdminStatus.' . $peer_identifier . ' cbgpPeer2InUpdates.' . $peer_identifier . ' cbgpPeer2OutUpdates.' . $peer_identifier . ' cbgpPeer2InTotalMessages.' . $peer_identifier . ' cbgpPeer2OutTotalMessages.' . $peer_identifier . ' cbgpPeer2FsmEstablishedTime.' . $peer_identifier . ' cbgpPeer2InUpdateElapsedTime.' . $peer_identifier . ' cbgpPeer2LocalAddr.' . $peer_identifier, '-OQUs', 'CISCO-BGP4-MIB', $config['mibdir']); $ident = "{$ip_ver}.\"" . $bgp_peer_ident . '"'; unset($peer_data); $ident_key = array_keys($peer_data_tmp); foreach ($peer_data_tmp[$ident_key[0]] as $k => $v) { if (strstr($k, 'cbgpPeer2LocalAddr')) { if ($ip_ver == 'ipv6') { $v = str_replace('"', '', $v); $v = rtrim($v); $v = preg_replace('/(\\S+\\s+\\S+)\\s/', '$1:', $v); $v = strtolower($v); } else { $v = hex_to_ip($v); } } $peer_data .= "{$v}\n"; } } else { $peer_cmd = $config['snmpget'] . ' -M ' . $config['mibdir'] . ' -m BGP4-MIB -OUvq ' . snmp_gen_auth($device) . ' ' . $device['hostname'] . ':' . $device['port'] . ' '; $peer_cmd .= 'bgpPeerState.' . $peer['bgpPeerIdentifier'] . ' bgpPeerAdminStatus.' . $peer['bgpPeerIdentifier'] . ' bgpPeerInUpdates.' . $peer['bgpPeerIdentifier'] . ' bgpPeerOutUpdates.' . $peer['bgpPeerIdentifier'] . ' bgpPeerInTotalMessages.' . $peer['bgpPeerIdentifier'] . ' '; $peer_cmd .= 'bgpPeerOutTotalMessages.' . $peer['bgpPeerIdentifier'] . ' bgpPeerFsmEstablishedTime.' . $peer['bgpPeerIdentifier'] . ' bgpPeerInUpdateElapsedTime.' . $peer['bgpPeerIdentifier'] . ' '; $peer_cmd .= 'bgpPeerLocalAddr.' . $peer['bgpPeerIdentifier'] . ''; $peer_data = trim(`{$peer_cmd}`); } //end if list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime, $bgpLocalAddr) = explode("\n", $peer_data); $bgpLocalAddr = str_replace('"', '', str_replace(' ', '', $bgpLocalAddr)); } else {
*/ 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. $result['peer'] = $cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][3][$index]; $result['port'] = $cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][4][$index]; $result['stratum'] = $cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][9][$index]; $result['peerref'] = hex_to_ip($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][15][$index]); $result['label'] = $result['peer'] . ":" . $result['port']; // Set the status, 16 = Bad if ($result['stratum'] == 16) { $result['status'] = 2; $result['error'] = 'NTP Stratum is Insane'; } else { $result['status'] = 0; $result['error'] = ''; } d_echo("NTP Peer found: "); d_echo($result); $tblComponents[] = $result; } /* * Ok, we have our 2 array's (Components and SNMP) now we need