mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
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
This commit is contained in:
@@ -79,7 +79,7 @@ if (!$auth)
|
||||
{
|
||||
echo("<option value='".generate_url($vars, array('type' => $type."_".$avail_type, 'page' => "graphs"))."'");
|
||||
if ($avail_type == $subtype) { echo(" selected"); }
|
||||
echo(">".$avail_type."</option>");
|
||||
echo(">".nicecase($avail_type)."</option>");
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
@@ -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) {
|
||||
|
@@ -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);
|
||||
|
@@ -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");
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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";
|
||||
|
@@ -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'];
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@@ -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'];
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
#FIXME snmp_ function!
|
||||
$hardware = trim(exec($config['snmpget'] . " -M ".$config['mibdir'] . " -O vqs -m FOUNDRY-SN-AGENT-MIB:FOUNDRY-SN-ROOT-MIB -" . $device['snmpver'] . " -c " . $device['community'] . " " .
|
||||
$hardware = trim(exec($config['snmpget'] . " -M ".$config['mibdir'] . " -O vqs -m FOUNDRY-SN-AGENT-MIB:FOUNDRY-SN-ROOT-MIB " . snmp_gen_auth($device) . " " .
|
||||
$device['hostname'].":".$device['port'] . " sysObjectID.0"));
|
||||
|
||||
$hardware = rewrite_ironware_hardware($hardware);
|
||||
|
||||
$version = trim(exec($config['snmpget'] . " -M ".$config['mibdir'] . " -O vqs -m FOUNDRY-SN-AGENT-MIB:FOUNDRY-SN-ROOT-MIB -" . $device['snmpver'] . " -c " . $device['community'] . " " .
|
||||
$version = trim(exec($config['snmpget'] . " -M ".$config['mibdir'] . " -O vqs -m FOUNDRY-SN-AGENT-MIB:FOUNDRY-SN-ROOT-MIB " . snmp_gen_auth($device) . " " .
|
||||
$device['hostname'].":".$device['port'] . " snAgBuildVer.0"));
|
||||
|
||||
$version = str_replace("V", "", $version);
|
||||
$version = str_replace("\"", "", $version);
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@@ -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);
|
||||
|
@@ -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`;
|
||||
|
@@ -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];
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
Reference in New Issue
Block a user