From 1f9eae36991bbb304e9561c63a8ac9efba769d39 Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Tue, 15 May 2012 13:45:26 +0000 Subject: [PATCH] add snmpv3 support to old snmp queries - patch by gl git-svn-id: http://www.observium.org/svn/observer/trunk@3184 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/pages/graphs.inc.php | 2 +- includes/discovery/cisco-mac-accounting.inc.php | 2 +- .../discovery/temperatures/observernms-custom.inc.php | 4 ++-- includes/discovery/vlans.inc.php | 1 + includes/polling/applications/mysql.inc.php | 2 +- includes/polling/bgp-peers.inc.php | 8 ++++---- includes/polling/mempools/cemp.inc.php | 4 ++-- includes/polling/mempools/cmp.inc.php | 4 ++-- includes/polling/os/ironware.inc.php | 6 +++--- includes/polling/os/screenos.inc.php | 2 +- includes/polling/os/snom.inc.php | 6 +++--- includes/polling/os/speedtouch.inc.php | 4 ++-- 12 files changed, 23 insertions(+), 22 deletions(-) diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index e51dc6aac..82e64755f 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -79,7 +79,7 @@ if (!$auth) { echo(""); + echo(">".nicecase($avail_type).""); } ?> diff --git a/includes/discovery/cisco-mac-accounting.inc.php b/includes/discovery/cisco-mac-accounting.inc.php index ed378b9de..dd4a13d19 100755 --- a/includes/discovery/cisco-mac-accounting.inc.php +++ b/includes/discovery/cisco-mac-accounting.inc.php @@ -4,7 +4,7 @@ if ($device['os_group'] == "cisco") { echo("Cisco MAC Accounting : "); - $datas = shell_exec($config['snmpbulkwalk'] . " -M ".$config['mibdir']." -m CISCO-IP-STAT-MIB -Oqn -".$device['snmpver']." -c ".$device['community']." ".$device['hostname']." cipMacSwitchedBytes"); + $datas = shell_exec($config['snmpbulkwalk'] . " -M ".$config['mibdir']." -m CISCO-IP-STAT-MIB -Oqn " . snmp_gen_auth($device) . " " . $device['hostname']." cipMacSwitchedBytes"); #echo("$datas\n"); #echo("done\n"); foreach (explode("\n", $datas) as $data) { diff --git a/includes/discovery/temperatures/observernms-custom.inc.php b/includes/discovery/temperatures/observernms-custom.inc.php index 7e0b707ab..d0d7e787f 100644 --- a/includes/discovery/temperatures/observernms-custom.inc.php +++ b/includes/discovery/temperatures/observernms-custom.inc.php @@ -4,7 +4,7 @@ if ($device['os_group'] == "unix") { # FIXME snmp_walk # ObserverNMS-style temperature - $cmd = $config['snmpwalk'] . " -M " . $config['mibdir'] . " -M " . $config['mibdir'] . " -".$device['snmpver']." -m SNMPv2-SMI -Osqn -CI -c ".$device['community']." ".$device['transport'].":".$device['hostname'].":".$device['port']." .1.3.6.1.4.1.2021.7891 | sed s/.1.3.6.1.4.1.2021.7891.// | grep '.1.1 ' | grep -v '.101.' | cut -d'.' -f 1"; + $cmd = $config['snmpwalk'] . " -M " . $config['mibdir'] . " -M " . $config['mibdir'] . " -m SNMPv2-SMI -Osqn -CI " . snmp_gen_auth($device) . " " . $device['transport'].":".$device['hostname'].":".$device['port']." .1.3.6.1.4.1.2021.7891 | sed s/.1.3.6.1.4.1.2021.7891.// | grep '.1.1 ' | grep -v '.101.' | cut -d'.' -f 1"; if ($debug) { echo("$cmd\n"); } $oids = shell_exec($cmd); $oids = trim($oids); @@ -15,7 +15,7 @@ if ($device['os_group'] == "unix") if ($oid != "") { # FIXME snmp_get - $descr_query = $config['snmpget'] . " -M " . $config['mibdir'] . " -".$device['snmpver']." -m SNMPv2-SMI -Osqn -c ".$device['community']." ".$device['transport'].':'.$device['hostname'].":".$device['port']." .1.3.6.1.4.1.2021.7891.$oid.2.1 | sed s/.1.3.6.1.4.1.2021.7891.$oid.2.1\ //"; + $descr_query = $config['snmpget'] . " -M " . $config['mibdir'] . " -m SNMPv2-SMI -Osqn " . snmp_gen_auth($device) . " " . $device['transport'].':'.$device['hostname'].":".$device['port']." .1.3.6.1.4.1.2021.7891.$oid.2.1 | sed s/.1.3.6.1.4.1.2021.7891.$oid.2.1\ //"; $descr = trim(str_replace("\"", "", shell_exec($descr_query))); $fulloid = ".1.3.6.1.4.1.2021.7891.$oid.101.1"; discover_sensor($valid['sensor'], 'temperature', $device, $fulloid, $oid, 'observium', $descr, '1', '1', NULL, NULL, NULL, NULL, $current); diff --git a/includes/discovery/vlans.inc.php b/includes/discovery/vlans.inc.php index 3cd08f4ba..0b5ceb4ed 100644 --- a/includes/discovery/vlans.inc.php +++ b/includes/discovery/vlans.inc.php @@ -30,6 +30,7 @@ foreach ($device['vlans'] as $domain_id => $vlans) { if ($device['os_group'] == "cisco" || $device['os'] == "ios") /// This shit only seems to work on IOS { + # Probably does not work with snmpv3. I have no real idea about what this code is really doing $vlan_device = array_merge($device, array('community' => $device['community']."@".$vlan_id)); $vlan_data = snmpwalk_cache_oid($vlan_device, "dot1dStpPortEntry", array(), "BRIDGE-MIB:Q-BRIDGE-MIB"); $vlan_data = snmpwalk_cache_oid($vlan_device, "dot1dBasePortEntry", $vlan_data, "BRIDGE-MIB:Q-BRIDGE-MIB"); diff --git a/includes/polling/applications/mysql.inc.php b/includes/polling/applications/mysql.inc.php index f3e48a549..1c6426e24 100644 --- a/includes/polling/applications/mysql.inc.php +++ b/includes/polling/applications/mysql.inc.php @@ -6,7 +6,7 @@ if(!empty($agent_data['app']['mysql'])) $mysql = $agent_data['app']['mysql']; } else { #Polls MySQL statistics from script via SNMP - $mysql_cmd = $config['snmpget'] ." -m NET-SNMP-EXTEND-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; + $mysql_cmd = $config['snmpget'] ." -m NET-SNMP-EXTEND-MIB -O qv " . snmp_gen_auth($device) . " " . $device['hostname'].":".$device['port']; $mysql_cmd .= " nsExtendOutputFull.5.109.121.115.113.108"; $mysql = shell_exec($mysql_cmd); } diff --git a/includes/polling/bgp-peers.inc.php b/includes/polling/bgp-peers.inc.php index bd9be8f1a..528010887 100755 --- a/includes/polling/bgp-peers.inc.php +++ b/includes/polling/bgp-peers.inc.php @@ -16,7 +16,7 @@ if ($config['enable_bgp']) { # v4 BGP4 MIB ## FIXME - needs moved to function - $peer_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m BGP4-MIB -OUvq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'] . " "; + $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'] . ""; @@ -33,7 +33,7 @@ if ($config['enable_bgp']) { echo("\nCaching Oids..."); ## FIXME - needs moved to function - $peer_cmd = $config['snmpwalk'] . " -M ".$config['mibdir'] . "/junos -m BGP4-V2-MIB-JUNIPER -OUnq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port']; + $peer_cmd = $config['snmpwalk'] . " -M ".$config['mibdir'] . "/junos -m BGP4-V2-MIB-JUNIPER -OUnq -" . $device['snmpver'] . " " . snmp_gen_auth($device) . " " . $device['hostname'].":".$device['port']; $peer_cmd .= " jnxBgpM2PeerStatus.0.ipv6"; foreach (explode("\n",trim(`$peer_cmd`)) as $oid) { @@ -44,7 +44,7 @@ if ($config['enable_bgp']) } ## FIXME - move to function (and clean up, wtf?) - $peer_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . "/junos -m BGP4-V2-MIB-JUNIPER -OUvq -" . $device['snmpver'] . " -c" . $device['community']; + $peer_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . "/junos -m BGP4-V2-MIB-JUNIPER -OUvq " . snmp_get_auth($device); $peer_cmd .= ' -M"' . $config['install_dir'] . '/mibs/junos"'; $peer_cmd .= " " . $device['hostname'].":".$device['port']; $peer_cmd .= " jnxBgpM2PeerState.0.ipv6." . $junos_v6[$peer_ip]; @@ -137,7 +137,7 @@ if ($config['enable_bgp']) if ($device['os_group'] == "cisco") { ## FIXME - move to function - $cbgp_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m CISCO-BGP4-MIB -Ovq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port']; + $cbgp_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m CISCO-BGP4-MIB -Ovq " . snmp_gen_auth($device) . " " . $device['hostname'].":".$device['port']; $cbgp_cmd .= " cbgpPeerAcceptedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi"; $cbgp_cmd .= " cbgpPeerDeniedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi"; $cbgp_cmd .= " cbgpPeerPrefixAdminLimit." . $peer['bgpPeerIdentifier'] . ".$afi.$safi"; diff --git a/includes/polling/mempools/cemp.inc.php b/includes/polling/mempools/cemp.inc.php index 0b5b8175b..5a259e120 100755 --- a/includes/polling/mempools/cemp.inc.php +++ b/includes/polling/mempools/cemp.inc.php @@ -3,7 +3,7 @@ $oid = $mempool['mempool_index']; # FIXME snmp_get -$pool_cmd = $config['snmpget'] . " -M ".$config['mibdir']. " -m CISCO-ENHANCED-MEMPOOL-MIB -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; +$pool_cmd = $config['snmpget'] . " -M ".$config['mibdir']. " -m CISCO-ENHANCED-MEMPOOL-MIB -O Uqnv " . snmp_gen_auth($device) . " " . $device['hostname'].":".$device['port']; $pool_cmd .= " cempMemPoolUsed.$oid cempMemPoolFree.$oid cempMemPoolLargestFree.$oid"; $pool_cmd .= " | cut -f 1 -d ' '"; @@ -14,4 +14,4 @@ $pool = shell_exec($pool_cmd); list($mempool['used'], $mempool['free'], $mempool['largestfree']) = explode("\n", $pool); $mempool['total'] = $mempool['used'] + $mempool['free']; -?> \ No newline at end of file +?> diff --git a/includes/polling/mempools/cmp.inc.php b/includes/polling/mempools/cmp.inc.php index f7a3bd6cc..0399eaf66 100755 --- a/includes/polling/mempools/cmp.inc.php +++ b/includes/polling/mempools/cmp.inc.php @@ -3,7 +3,7 @@ $oid = $mempool['mempool_index']; # FIXME snmp_get -$pool_cmd = $config['snmpget'] . " -M ".$config['mibdir']. " -m CISCO-MEMORY-POOL-MIB -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; +$pool_cmd = $config['snmpget'] . " -M ".$config['mibdir']. " -m CISCO-MEMORY-POOL-MIB -O Uqnv " . snmp_gen_auth($device) . " " . $device['hostname'].":".$device['port']; $pool_cmd .= " ciscoMemoryPoolUsed.$oid ciscoMemoryPoolFree.$oid ciscoMemoryPoolLargestFree.$oid"; $pool_cmd .= " | cut -f 1 -d ' '"; @@ -14,4 +14,4 @@ $pool = shell_exec($pool_cmd); list($mempool['used'], $mempool['free'], $mempool['largestfree']) = explode("\n", $pool); $mempool['total'] = $mempool['used'] + $mempool['free']; -?> \ No newline at end of file +?> diff --git a/includes/polling/os/ironware.inc.php b/includes/polling/os/ironware.inc.php index bc4bd0d54..5a59932fc 100644 --- a/includes/polling/os/ironware.inc.php +++ b/includes/polling/os/ironware.inc.php @@ -1,15 +1,15 @@ \ No newline at end of file +?> diff --git a/includes/polling/os/screenos.inc.php b/includes/polling/os/screenos.inc.php index 6e5d983c0..ba0a2a7a5 100755 --- a/includes/polling/os/screenos.inc.php +++ b/includes/polling/os/screenos.inc.php @@ -4,7 +4,7 @@ $version = preg_replace("/(.+)\ version\ (.+)\ \(SN:\ (.+)\,\ (.+)\)/", "\\1||\\ list($hardware,$version,$serial,$features) = explode("||", $version); $sessrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/screenos_sessions.rrd"; -$sess_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname']; +$sess_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -O qv " . snmp_gen_auth($device) . " " . $device['hostname']; $sess_cmd .= " .1.3.6.1.4.1.3224.16.3.2.0 .1.3.6.1.4.1.3224.16.3.3.0 .1.3.6.1.4.1.3224.16.3.4.0"; $sess_data = shell_exec($sess_cmd); list ($sessalloc, $sessmax, $sessfailed) = explode("\n", $sess_data); diff --git a/includes/polling/os/snom.inc.php b/includes/polling/os/snom.inc.php index 6478d5e75..106a05199 100755 --- a/includes/polling/os/snom.inc.php +++ b/includes/polling/os/snom.inc.php @@ -6,7 +6,7 @@ echo("Polling SNOM device...\n"); ## FIXME - This needs a good cleanup... -$cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " 1.3.6.1.2.1.7526.2.4"; +$cmd = "snmpget -O qv " . snmp_gen_auth($device) . " " . $device['hostname'].":".$device['port'] . " 1.3.6.1.2.1.7526.2.4"; $poll_device['sysDescr'] = `$cmd`; $poll_device['sysDescr'] = str_replace("-", " ", $poll_device['sysDescr']); $poll_device['sysDescr'] = str_replace("\"", "", $poll_device['sysDescr']); @@ -14,8 +14,8 @@ list($hardware, $features, $version) = explode(" ", $poll_device['sysDescr']); // Get data for calls and network from SNOM specific SNMP OIDs. -$cmda = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " 1.3.6.1.2.1.7526.2.1.1 1.3.6.1.2.1.7526.2.1.2 1.3.6.1.2.1.7526.2.2.1 1.3.6.1.2.1.7526.2.2.2"; -$cmdb = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " 1.3.6.1.2.1.7526.2.5 1.3.6.1.2.1.7526.2.6"; +$cmda = "snmpget -O qv " . snmp_gen_auth($device) . " " . $device['hostname'].":".$device['port'] . " 1.3.6.1.2.1.7526.2.1.1 1.3.6.1.2.1.7526.2.1.2 1.3.6.1.2.1.7526.2.2.1 1.3.6.1.2.1.7526.2.2.2"; +$cmdb = "snmpget -O qv " . snmp_gen_auth($device) . " " . $device['hostname'].":".$device['port'] . " 1.3.6.1.2.1.7526.2.5 1.3.6.1.2.1.7526.2.6"; #echo($cmda); $snmpdata = `$cmda`; $snmpdatab = `$cmdb`; diff --git a/includes/polling/os/speedtouch.inc.php b/includes/polling/os/speedtouch.inc.php index 5a3550caf..11dd598ac 100644 --- a/includes/polling/os/speedtouch.inc.php +++ b/includes/polling/os/speedtouch.inc.php @@ -8,7 +8,7 @@ $features = ""; ### Filthy hack to get software version. may not work on anything but 585v7 :) -$loop = shell_exec($config['snmpget'] . " -M ".$config['mibdir'] . ' -Ovq -v1 -c '.$device['community'].' '.$device['hostname'].' ifDescr.101'); +$loop = shell_exec($config['snmpget'] . " -M ".$config['mibdir'] . ' -Ovq '. snmp_gen_auth($device) .' '.$device['hostname'].' ifDescr.101'); if ($loop) { @@ -17,4 +17,4 @@ if ($loop) $version = $matches[1]; } -?> \ No newline at end of file +?>