mirror of
				https://github.com/librenms/librenms.git
				synced 2024-10-07 16:52:45 +00:00 
			
		
		
		
	add some mibs, update snmp functions
git-svn-id: http://www.observium.org/svn/observer/trunk@1458 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
		@@ -6,7 +6,7 @@ $community = $device['community'];
 | 
			
		||||
 | 
			
		||||
if($device['os'] == "ironware") {
 | 
			
		||||
  echo(" Brocade FDP: ");
 | 
			
		||||
  $fdp_array = snmpwalk_cache_twopart_oid("snFdpCacheEntry", $device, array(), "FOUNDRY-SN-SWITCH-GROUP-MIB");
 | 
			
		||||
  $fdp_array = snmpwalk_cache_twopart_oid($device, "snFdpCacheEntry", array(), "FOUNDRY-SN-SWITCH-GROUP-MIB");
 | 
			
		||||
  $fdp_array = $fdp_array[$device['device_id']];
 | 
			
		||||
  if($fdp_array) {
 | 
			
		||||
    unset($fdp_links);
 | 
			
		||||
@@ -32,7 +32,7 @@ if($device['os'] == "ironware") {
 | 
			
		||||
if($device['os_group'] == "ios") {
 | 
			
		||||
  echo(" CISCO-CDP-MIB: ");  
 | 
			
		||||
  unset($cdp_array);
 | 
			
		||||
  $cdp_array = snmpwalk_cache_twopart_oid("cdpCache", $device, array(), "CISCO-CDP-MIB");
 | 
			
		||||
  $cdp_array = snmpwalk_cache_twopart_oid($device, "cdpCache", array(), "CISCO-CDP-MIB");
 | 
			
		||||
  $cdp_array = $cdp_array[$device['device_id']];
 | 
			
		||||
  if($cdp_array) {
 | 
			
		||||
    unset($cdp_links);
 | 
			
		||||
@@ -58,7 +58,7 @@ if($device['os_group'] == "ios") {
 | 
			
		||||
echo(" LLDP-MIB: ");
 | 
			
		||||
 | 
			
		||||
unset($lldp_array);
 | 
			
		||||
$lldp_array = snmpwalk_cache_threepart_oid("lldpRemoteSystemsData", $device, array(), "LLDP-MIB");
 | 
			
		||||
$lldp_array = snmpwalk_cache_threepart_oid($device, "lldpRemoteSystemsData", array(), "LLDP-MIB");
 | 
			
		||||
$lldp_array = $lldp_array[$device['device_id']];
 | 
			
		||||
if($lldp_array) {
 | 
			
		||||
  $lldp_links = "";
 | 
			
		||||
 
 | 
			
		||||
@@ -7,8 +7,7 @@
 | 
			
		||||
 if($config['enable_inventory']) {
 | 
			
		||||
 | 
			
		||||
  $entity_array = array();
 | 
			
		||||
  $entity_array = snmpwalk_cache_oid("entPhysicalEntry", $device, $entity_array, "ENTITY-MIB");
 | 
			
		||||
  #$entity_array = snmpwalk_cache_oid("entSensorValues", $device, $entity_array, "CISCO-ENTITY-SENSOR-MIB");
 | 
			
		||||
  $entity_array = snmpwalk_cache_oid($device, "entPhysicalEntry", $entity_array, "ENTITY-MIB");
 | 
			
		||||
 | 
			
		||||
  if(!$entity_array[$device['device_id']]) { $entity_array[$device['device_id']] = array(); }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -5,30 +5,38 @@ echo("hrDevice : ");
 | 
			
		||||
$hrDevice_oids = array('hrDeviceEntry','hrProcessorEntry');
 | 
			
		||||
if($debug) {print_r($hrDevices);}
 | 
			
		||||
 | 
			
		||||
foreach ($hrDevice_oids as $oid) { $hrDevices = snmp_cache_oid($oid, $device, $hrDevices, "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES"); }
 | 
			
		||||
 | 
			
		||||
$hrDevices = array();
 | 
			
		||||
foreach ($hrDevice_oids as $oid) { $hrDevices = snmpwalk_cache_oid($device, $oid, $hrDevices, "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES"); }
 | 
			
		||||
if($debug) {print_r($hrDevices);}
 | 
			
		||||
 | 
			
		||||
foreach($hrDevices[$device['device_id']] as $hrDevice) {
 | 
			
		||||
  if(is_array($hrDevice) && is_numeric($hrDevice['hrDeviceIndex'])) {
 | 
			
		||||
   if(mysql_result(mysql_query("SELECT COUNT(*) FROM `hrDevice` WHERE device_id = '".$device['device_id']."' AND hrDeviceIndex = '".$hrDevice['hrDeviceIndex']."'"),0)) {
 | 
			
		||||
     $update_query  = "UPDATE `hrDevice` SET";
 | 
			
		||||
     $update_query .= "  `hrDeviceType` = '".mres($hrDevice[hrDeviceType])."'";
 | 
			
		||||
     $update_query .= ", `hrDeviceDescr` = '".mres($hrDevice[hrDeviceDescr])."'";
 | 
			
		||||
     $update_query .= ", `hrDeviceStatus` = '".mres($hrDevice[hrDeviceStatus])."'";
 | 
			
		||||
     $update_query .= ", `hrDeviceErrors` = '".mres($hrDevice[hrDeviceErrors])."'";
 | 
			
		||||
     if($hrDevice['hrDeviceType'] == "hrDeviceProcessor") {
 | 
			
		||||
       $update_query .= ", `hrProcessorLoad` = '".mres($hrDevice[hrProcessorLoad])."'";
 | 
			
		||||
if(is_array($hrDevices[$device['device_id']]))
 | 
			
		||||
{
 | 
			
		||||
  $hrDevices = $hrDevices[$device['device_id']];
 | 
			
		||||
  foreach($hrDevices as $hrDevice) 
 | 
			
		||||
  {
 | 
			
		||||
    if(is_array($hrDevice) && is_numeric($hrDevice['hrDeviceIndex'])) 
 | 
			
		||||
    {
 | 
			
		||||
     if(mysql_result(mysql_query("SELECT COUNT(*) FROM `hrDevice` WHERE device_id = '".$device['device_id']."' AND hrDeviceIndex = '".$hrDevice['hrDeviceIndex']."'"),0)) 
 | 
			
		||||
     {
 | 
			
		||||
       $update_query  = "UPDATE `hrDevice` SET";
 | 
			
		||||
       $update_query .= "  `hrDeviceType` = '".mres($hrDevice[hrDeviceType])."'";
 | 
			
		||||
       $update_query .= ", `hrDeviceDescr` = '".mres($hrDevice[hrDeviceDescr])."'";
 | 
			
		||||
       $update_query .= ", `hrDeviceStatus` = '".mres($hrDevice[hrDeviceStatus])."'";
 | 
			
		||||
       $update_query .= ", `hrDeviceErrors` = '".mres($hrDevice[hrDeviceErrors])."'";
 | 
			
		||||
       if($hrDevice['hrDeviceType'] == "hrDeviceProcessor") 
 | 
			
		||||
       {
 | 
			
		||||
         $update_query .= ", `hrProcessorLoad` = '".mres($hrDevice[hrProcessorLoad])."'";
 | 
			
		||||
       }
 | 
			
		||||
       $update_query .= " WHERE device_id = '".$device['device_id']."' AND hrDeviceIndex = '".$hrDevice['hrDeviceIndex']."'";
 | 
			
		||||
       @mysql_query($update_query); $mysql++; echo(".");
 | 
			
		||||
     } else {
 | 
			
		||||
       $insert_query = "INSERT INTO `hrDevice` (`hrDeviceIndex`,`device_id`,`hrDeviceType`,`hrDeviceDescr`,`hrDeviceStatus`,`hrDeviceErrors`) ";
 | 
			
		||||
       $insert_query .= " VALUES ('".mres($hrDevice[hrDeviceIndex])."','".mres($device[device_id])."','".mres($hrDevice[hrDeviceType])."','".mres($hrDevice[hrDeviceDescr])."','".mres($hrDevice[hrDeviceStatus])."','".mres($hrDevice[hrDeviceErrors])."')";
 | 
			
		||||
       @mysql_query($insert_query); $mysql++; echo("+");
 | 
			
		||||
       if($debug) { print_r($hrDevice); echo("$insert_query" . mysql_affected_rows() . " row inserted"); }
 | 
			
		||||
     }
 | 
			
		||||
     $update_query .= " WHERE device_id = '".$device['device_id']."' AND hrDeviceIndex = '".$hrDevice['hrDeviceIndex']."'";
 | 
			
		||||
     @mysql_query($update_query); $mysql++; echo(".");
 | 
			
		||||
   } else {
 | 
			
		||||
     $insert_query = "INSERT INTO `hrDevice` (`hrDeviceIndex`,`device_id`,`hrDeviceType`,`hrDeviceDescr`,`hrDeviceStatus`,`hrDeviceErrors`) ";
 | 
			
		||||
     $insert_query .= " VALUES ('".mres($hrDevice[hrDeviceIndex])."','".mres($device[device_id])."','".mres($hrDevice[hrDeviceType])."','".mres($hrDevice[hrDeviceDescr])."','".mres($hrDevice[hrDeviceStatus])."','".mres($hrDevice[hrDeviceErrors])."')";
 | 
			
		||||
     @mysql_query($insert_query); $mysql++; echo("+");
 | 
			
		||||
     if($debug) { print_r($hrDevice); echo("$insert_query" . mysql_affected_rows() . " row inserted"); }
 | 
			
		||||
   }
 | 
			
		||||
   $valid_hrDevice[$hrDevice[hrDeviceIndex]] = 1;
 | 
			
		||||
     $valid_hrDevice[$hrDevice[hrDeviceIndex]] = 1;
 | 
			
		||||
    } 
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -8,9 +8,7 @@ if(($device['os'] == "ios" || $device['os_group'] == "ios") && $cemp_count == "0
 | 
			
		||||
 | 
			
		||||
  echo("OLD-CISCO-MEMORY-POOL: ");
 | 
			
		||||
 | 
			
		||||
  $cmp_oids = array('ciscoMemoryPool');
 | 
			
		||||
 | 
			
		||||
  foreach ($cmp_oids as $oid) { $cmp_array = snmp_cache_oid($oid, $device, array(), "CISCO-MEMORY-POOL-MIB"); }
 | 
			
		||||
  $cmp_array = snmpwalk_cache_oid($device, 'ciscoMemoryPool', NULL, "CISCO-MEMORY-POOL-MIB");
 | 
			
		||||
 | 
			
		||||
  if(is_array($cmp_array)) {
 | 
			
		||||
    foreach($cmp_array[$device[device_id]] as $index => $cmp) {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
$storage_array = snmp_cache_oid("hrStorageEntry", $device, array(), "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES");
 | 
			
		||||
$storage_array = snmpwalk_cache_oid($device, "hrStorageEntry", NULL, "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES");
 | 
			
		||||
 | 
			
		||||
if(is_array($storage_array)) {
 | 
			
		||||
  echo("hrStorage : ");
 | 
			
		||||
 
 | 
			
		||||
@@ -5,8 +5,8 @@ global $valid_processor;
 | 
			
		||||
if ($device['os_group'] == "unix" || $device['os'] == "windows" || $device['os'] == "routeros")
 | 
			
		||||
  {
 | 
			
		||||
  echo("hrDevice ");
 | 
			
		||||
  $hrDevice_oids = array('hrDevice','hrProcessorLoad');  
 | 
			
		||||
  foreach ($hrDevice_oids as $oid) { $hrDevice_array = snmp_cache_oid($oid, $device, $hrDevice_array, "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES"); }
 | 
			
		||||
  $hrDevice_oids = array('hrDevice','hrProcessorLoad'); 
 | 
			
		||||
  foreach ($hrDevice_oids as $oid) { $hrDevice_array = snmpwalk_cache_oid($device, $oid, $hrDevice_array, "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES"); }
 | 
			
		||||
  foreach($hrDevice_array[$device['device_id']] as $index => $entry)
 | 
			
		||||
  {
 | 
			
		||||
    if ($entry['hrDeviceType'] == "hrDeviceProcessor") 
 | 
			
		||||
 
 | 
			
		||||
@@ -5,11 +5,12 @@ global $valid_processor;
 | 
			
		||||
if ($device['os'] == "ios" || $device['os_group'] == "ios")
 | 
			
		||||
{
 | 
			
		||||
  echo("CISCO-PROCESS-MIB : ");
 | 
			
		||||
  $processors_array = snmpwalk_cache_oid("cpmCPU", $device, $processors_array, "CISCO-PROCESS-MIB");
 | 
			
		||||
  $processors_array = snmpwalk_cache_oid($device, "cpmCPU", NULL, "CISCO-PROCESS-MIB");
 | 
			
		||||
  if($debug) { print_r($processors_array); }
 | 
			
		||||
 | 
			
		||||
  foreach ($processors_array[$device['device_id']] as $index => $entry) 
 | 
			
		||||
  {
 | 
			
		||||
    if ($entry['cpmCPUTotal5minRev'] || $entry['cpmCPUTotal5min']) 
 | 
			
		||||
    if (is_numeric($entry['cpmCPUTotal5minRev']) || is_numeric($entry['cpmCPUTotal5min'])) 
 | 
			
		||||
    {
 | 
			
		||||
      $entPhysicalIndex = $entry['cpmCPUTotalPhysicalIndex'];
 | 
			
		||||
 | 
			
		||||
@@ -21,26 +22,31 @@ if ($device['os'] == "ios" || $device['os_group'] == "ios")
 | 
			
		||||
	$usage = $entry['cpmCPUTotal5min'];
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      $descr_oid = "entPhysicalName." . $entPhysicalIndex;
 | 
			
		||||
      $descr = snmp_get($device, $descr_oid, "-Oqv", "ENTITY-MIB");
 | 
			
		||||
      if($entPhysicalIndex) {
 | 
			
		||||
        $descr_oid = "entPhysicalName." . $entPhysicalIndex;
 | 
			
		||||
        $descr = snmp_get($device, $descr_oid, "-Oqv", "ENTITY-MIB");
 | 
			
		||||
      }
 | 
			
		||||
      if(!$descr) { $descr = "Processor $index"; }
 | 
			
		||||
 | 
			
		||||
      $old_rrd  = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("cpmCPU-" . $index . ".rrd");
 | 
			
		||||
      $new_rrd  = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("processor-cpm-" . $index . ".rrd");
 | 
			
		||||
 | 
			
		||||
      if($debug) { echo("$old_rrd $new_rrd"); }
 | 
			
		||||
      if (is_file($old_rrd)) 
 | 
			
		||||
      {
 | 
			
		||||
	shell_exec("mv -f $old_rrd $new_rrd");
 | 
			
		||||
        if($debug) { echo("$old_rrd $new_rrd"); }
 | 
			
		||||
	echo("Moved RRD ");
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      echo("|".$descr."|");
 | 
			
		||||
 | 
			
		||||
      if(!strstr($descr, "No") && !strstr($usage, "No") && $descr != "" ) 
 | 
			
		||||
      {
 | 
			
		||||
	discover_processor($valid_processor, $device, $usage_oid, $index, "cpm", $descr, "1", $entry['juniSystemModuleCpuUtilPct'], $entPhysicalIndex, NULL);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (!is_array($valid_processor['cpm'])) 
 | 
			
		||||
  {
 | 
			
		||||
    $avgBusy5 = snmp_get($device, ".1.3.6.1.4.1.9.2.1.58.0", "-Oqv");
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										26
									
								
								includes/discovery/processors/radlan.inc.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								includes/discovery/processors/radlan.inc.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
global $valid_processor;
 | 
			
		||||
 | 
			
		||||
##
 | 
			
		||||
##  Hardcoded discovery of cpu usage on RADLAN devices.
 | 
			
		||||
##
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if($device['os'] == "radlan")
 | 
			
		||||
{
 | 
			
		||||
  echo("RADLAN : ");
 | 
			
		||||
 | 
			
		||||
      $descr = "Processor";
 | 
			
		||||
      $usage = snmp_get($device, ".1.3.6.1.4.1.89.1.9.0", "-OQUvs", "RADLAN-rndMng", $config['mib_dir'].":".$config['mib_dir']."/radlan");
 | 
			
		||||
 | 
			
		||||
      if(is_numeric($usage))
 | 
			
		||||
      {
 | 
			
		||||
        discover_processor($valid_processor, $device, ".1.3.6.1.4.1.89.1.9.0", "0", "radlan", $descr, "1", $usage, NULL, NULL);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
unset ($processors_array);
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
@@ -2,18 +2,13 @@
 | 
			
		||||
 | 
			
		||||
  echo("Q-BRIDGE-MIB VLANs : ");
 | 
			
		||||
 | 
			
		||||
  $vlanversion_cmd  = $config['snmpget'] . " -M " . $config['mibdir'] . " -m Q-BRIDGE-MIB -Oqv -" . $device['snmpver'] . " -c " . $device['community'] . " ";
 | 
			
		||||
  $vlanversion_cmd .= $device['hostname'].":".$device['port'] . " Q-BRIDGE-MIB::dot1qVlanVersionNumber.0";
 | 
			
		||||
  $vlanversion = trim(`$vlanversion_cmd 2>/dev/null`);  
 | 
			
		||||
  $vlanversion = snmp_get($device, "dot1qVlanVersionNumber.0", "-Oqv", "Q-BRIDGE-MIB");
 | 
			
		||||
 | 
			
		||||
  if($vlanversion == 'version1') {
 | 
			
		||||
 | 
			
		||||
    echo("VLAN $vlanversion ");
 | 
			
		||||
 | 
			
		||||
    $vlans_cmd  = $config['snmpwalk'] . " -M " . $config['mibdir'] . " -m Q-BRIDGE-MIB -O qn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ";
 | 
			
		||||
    $vlans_cmd .= "dot1qVlanFdbId";
 | 
			
		||||
 | 
			
		||||
    $vlans  = trim(`$vlans_cmd | grep -v o`);
 | 
			
		||||
    $vlans = snmp_walk($device, "dot1qVlanFdbId", $options = "-Oqn", $mib = "Q-BRIDGE-MIB");
 | 
			
		||||
 | 
			
		||||
    foreach(explode("\n", $vlans) as $vlan_oid) {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
$storage_array = snmp_cache_oid("hrStorageEntry", $device, array(), "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES");
 | 
			
		||||
$storage_array = snmpwalk_cache_oid($device, "hrStorageEntry", NULL, "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES");
 | 
			
		||||
 | 
			
		||||
if(is_array($storage_array)) {
 | 
			
		||||
  echo("hrStorage : ");
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
  echo("UCD Disk IO : ");
 | 
			
		||||
  $diskio_array = snmpwalk_cache_oid("diskIOEntry", $device, array(), "UCD-DISKIO-MIB" , "+".$config['install_dir']."/mibs/");
 | 
			
		||||
  $diskio_array = snmpwalk_cache_oid($device, "diskIOEntry", array(), "UCD-DISKIO-MIB" , "+".$config['install_dir']."/mibs/");
 | 
			
		||||
  $valid_diskio = array();
 | 
			
		||||
#  if($debug) { print_r($diskio_array); }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user