| 
									
										
										
										
											2010-07-31 19:49:11 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-15 16:59:01 +00:00
										 |  |  | ## APC PDUs
 | 
					
						
							| 
									
										
										
										
											2010-07-31 19:49:11 +00:00
										 |  |  | if ($device['os'] == "apc") | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-03-16 12:22:59 +00:00
										 |  |  |   # PDU - Phase
 | 
					
						
							|  |  |  |   $oids = snmp_walk($device, "rPDUStatusPhaseIndex", "-OsqnU", "PowerNet-MIB"); | 
					
						
							|  |  |  |   if ($oids) | 
					
						
							| 
									
										
										
										
											2010-07-31 19:49:11 +00:00
										 |  |  |   { | 
					
						
							| 
									
										
										
										
											2011-03-16 12:22:59 +00:00
										 |  |  |     if ($debug) { echo($oids."\n"); } | 
					
						
							|  |  |  |     $oids = trim($oids); | 
					
						
							|  |  |  |     if ($oids) echo("APC PowerNet-MIB Phase "); | 
					
						
							|  |  |  |     $type = "apc"; | 
					
						
							|  |  |  |     $precision = "10"; | 
					
						
							|  |  |  |     foreach (explode("\n", $oids) as $data) | 
					
						
							| 
									
										
										
										
											2010-07-31 19:49:11 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2011-03-16 12:22:59 +00:00
										 |  |  |       $data = trim($data); | 
					
						
							|  |  |  |       if ($data) | 
					
						
							| 
									
										
										
										
											2010-07-31 19:49:11 +00:00
										 |  |  |       { | 
					
						
							| 
									
										
										
										
											2011-03-16 12:22:59 +00:00
										 |  |  |         list($oid,$kind) = explode(" ", $data); | 
					
						
							|  |  |  |         $split_oid = explode('.',$oid); | 
					
						
							|  |  |  |         $index = $split_oid[count($split_oid)-1]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-20 14:22:34 +00:00
										 |  |  |         $current_oid   = "1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.".$index;        #rPDULoadStatusLoad
 | 
					
						
							|  |  |  |         $phase_oid     = "1.3.6.1.4.1.318.1.1.12.2.3.1.1.4.".$index;        #rPDULoadStatusPhaseNumber
 | 
					
						
							|  |  |  |         $limit_oid     = "1.3.6.1.4.1.318.1.1.12.2.2.1.1.4.".$index;        #rPDULoadPhaseConfigOverloadThreshold
 | 
					
						
							|  |  |  |         $lowlimit_oid  = "1.3.6.1.4.1.318.1.1.12.2.2.1.1.2.".$index;        #rPDULoadPhaseConfigLowLoadThreshold
 | 
					
						
							|  |  |  |         $warnlimit_oid = "1.3.6.1.4.1.318.1.1.12.2.2.1.1.3.".$index;        #rPDULoadPhaseConfigNearOverloadThreshold
 | 
					
						
							| 
									
										
										
										
											2011-03-16 12:22:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         $phase     = snmp_get($device, $phase_oid, "-Oqv", ""); | 
					
						
							|  |  |  |         $current   = snmp_get($device, $current_oid, "-Oqv", "") / $precision; | 
					
						
							| 
									
										
										
										
											2011-09-20 14:22:34 +00:00
										 |  |  |         $limit     = snmp_get($device, $limit_oid, "-Oqv", "");                        # No / $precision here! Nice, APC!
 | 
					
						
							|  |  |  |         $lowlimit  = snmp_get($device, $lowlimit_oid, "-Oqv", "");                # No / $precision here! Nice, APC!
 | 
					
						
							|  |  |  |         $warnlimit = snmp_get($device, $warnlimit_oid, "-Oqv", "");                # No / $precision here! Nice, APC!
 | 
					
						
							| 
									
										
										
										
											2011-03-16 12:22:59 +00:00
										 |  |  |         if (count(explode("\n",$oids)) != 1) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           $descr     = "Phase $phase"; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           $descr     = "Output"; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2012-04-05 16:17:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-04 11:04:19 +00:00
										 |  |  |         discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', $lowlimit, NULL, $warnlimit, $limit, $current); | 
					
						
							| 
									
										
										
										
											2010-07-31 19:49:11 +00:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2011-03-16 12:22:59 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   unset($oids); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   #v2 firmware- first bank is total, v3 firmware, 3rd bank is total
 | 
					
						
							| 
									
										
										
										
											2011-09-20 14:22:34 +00:00
										 |  |  |   $oids = snmp_walk($device, "rPDULoadBankConfigIndex", "-OsqnU", "PowerNet-MIB");        # should work with firmware v2 and v3
 | 
					
						
							| 
									
										
										
										
											2011-03-16 12:22:59 +00:00
										 |  |  |   if ($oids) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     echo("APC PowerNet-MIB Banks "); | 
					
						
							|  |  |  |     if ($debug) { echo($oids."\n"); } | 
					
						
							|  |  |  |     $oids = trim($oids); | 
					
						
							|  |  |  |     $type = "apc"; | 
					
						
							|  |  |  |     $precision = "10"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # version 2 does some stuff differently- total power is first oid in index instead of the last.
 | 
					
						
							|  |  |  |     # will look something like "AOS v2.6.4 / App v2.6.5"
 | 
					
						
							|  |  |  |     $baseversion = "3"; | 
					
						
							|  |  |  |     if (stristr($device['version'], 'AOS v2') == TRUE) { $baseversion = "2"; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     foreach (explode("\n", $oids) as $data) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       $data = trim($data); | 
					
						
							|  |  |  |       if ($data) | 
					
						
							| 
									
										
										
										
											2010-07-31 19:49:11 +00:00
										 |  |  |       { | 
					
						
							| 
									
										
										
										
											2011-03-16 12:22:59 +00:00
										 |  |  |         list($oid,$kind) = explode(" ", $data); | 
					
						
							|  |  |  |         $split_oid = explode('.',$oid); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $index = $split_oid[count($split_oid)-1]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-20 19:48:21 +00:00
										 |  |  |         $banknum = $index -1; | 
					
						
							|  |  |  |         $descr = "Bank ".$banknum; | 
					
						
							| 
									
										
										
										
											2011-03-16 12:22:59 +00:00
										 |  |  |         if ($baseversion == "3") | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2011-03-20 19:48:21 +00:00
										 |  |  |           if ($index == "1") { $descr = "Bank Total"; } | 
					
						
							| 
									
										
										
										
											2011-03-16 12:22:59 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |         if ($baseversion == "2") | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           if ($index == "1") { $descr = "Bank Total"; } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-05 16:17:41 +00:00
										 |  |  |         $current_oid   = "1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.".$index;  #rPDULoadStatusLoad
 | 
					
						
							|  |  |  |         $bank_oid      = "1.3.6.1.4.1.318.1.1.12.2.3.1.1.5.".$index;  #rPDULoadStatusBankNumber
 | 
					
						
							|  |  |  |         $limit_oid     = "1.3.6.1.4.1.318.1.1.12.2.4.1.1.4.".$index;  #rPDULoadBankConfigOverloadThreshold
 | 
					
						
							|  |  |  |         $lowlimit_oid  = "1.3.6.1.4.1.318.1.1.12.2.4.1.1.2.".$index;  #rPDULoadBankConfigLowLoadThreshold
 | 
					
						
							|  |  |  |         $warnlimit_oid = "1.3.6.1.4.1.318.1.1.12.2.4.1.1.3.".$index;  #rPDULoadBankConfigNearOverloadThreshold
 | 
					
						
							| 
									
										
										
										
											2011-03-16 12:22:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         $bank      = snmp_get($device, $bank_oid, "-Oqv", ""); | 
					
						
							|  |  |  |         $current   = snmp_get($device, $current_oid, "-Oqv", "") / $precision; | 
					
						
							|  |  |  |         $limit     = snmp_get($device, $limit_oid, "-Oqv", ""); | 
					
						
							|  |  |  |         $lowlimit  = snmp_get($device, $lowlimit_oid, "-Oqv", ""); | 
					
						
							|  |  |  |         $warnlimit = snmp_get($device, $warnlimit_oid, "-Oqv", ""); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-04 11:04:19 +00:00
										 |  |  |         discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', $lowlimit, NULL, $warnlimit, $limit, $current); | 
					
						
							| 
									
										
										
										
											2010-07-31 19:49:11 +00:00
										 |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-03-16 12:22:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     unset($baseversion); | 
					
						
							| 
									
										
										
										
											2010-07-31 19:49:11 +00:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-16 12:22:59 +00:00
										 |  |  |   unset($oids); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-09 11:13:20 +00:00
										 |  |  |  #Per Outlet Power Bar
 | 
					
						
							|  |  |  |   $oids = snmp_walk($device, "1.3.6.1.4.1.318.1.1.26.9.4.3.1.1", "-t 30 -OsqnU", "PowerNet-MIB"); | 
					
						
							|  |  |  |   if ($oids) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     echo("APC PowerNet-MIB Outlets "); | 
					
						
							|  |  |  |     if ($debug) { echo($oids."\n"); } | 
					
						
							|  |  |  |     $oids = trim($oids); | 
					
						
							|  |  |  |     $type = "apc"; | 
					
						
							|  |  |  |     $precision = "10"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     foreach (explode("\n", $oids) as $data) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       $data = trim($data); | 
					
						
							|  |  |  |       if ($data) | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         list($oid,$kind) = explode(" ", $data); | 
					
						
							|  |  |  |         $split_oid = explode('.',$oid); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $index = $split_oid[count($split_oid)-1]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-05 16:17:41 +00:00
										 |  |  |         $voltage_oid   = "1.3.6.1.4.1.318.1.1.26.6.3.1.6";            #rPDU2PhaseStatusVoltage
 | 
					
						
							| 
									
										
										
										
											2011-12-09 11:13:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-05 16:17:41 +00:00
										 |  |  |         $current_oid   = "1.3.6.1.4.1.318.1.1.26.9.4.3.1.6.".$index;  #rPDU2OutletMeteredStatusCurrent
 | 
					
						
							|  |  |  |         $limit_oid     = "1.3.6.1.4.1.318.1.1.26.9.4.1.1.7.".$index;  #rPDU2OutletMeteredConfigOverloadCurrentThreshold
 | 
					
						
							|  |  |  |         $lowlimit_oid  = "1.3.6.1.4.1.318.1.1.26.9.4.1.1.7.".$index;  #rPDU2OutletMeteredConfigLowLoadCurrentThreshold
 | 
					
						
							|  |  |  |         $warnlimit_oid = "1.3.6.1.4.1.318.1.1.26.9.4.1.1.6.".$index;  #rPDU2OutletMeteredConfigNearOverloadCurrentThreshold
 | 
					
						
							|  |  |  |         $name_oid      = "1.3.6.1.4.1.318.1.1.26.9.4.3.1.3.".$index;  #rPDU2OutletMeteredStatusName
 | 
					
						
							| 
									
										
										
										
											2011-12-09 11:13:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-05 16:17:41 +00:00
										 |  |  |         $voltage   = snmp_get($device, $voltage_oid, "-Oqv", ""); | 
					
						
							| 
									
										
										
										
											2011-12-09 11:13:20 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         $current   = snmp_get($device, $current_oid, "-Oqv", "") / $precision; | 
					
						
							|  |  |  |         $limit     = snmp_get($device, $limit_oid, "-Oqv", "") / $voltage; | 
					
						
							|  |  |  |         $lowlimit  = snmp_get($device, $lowlimit_oid, "-Oqv", "") / $voltage; | 
					
						
							|  |  |  |         $warnlimit = snmp_get($device, $warnlimit_oid, "-Oqv", "") / $voltage; | 
					
						
							| 
									
										
										
										
											2012-04-05 16:17:41 +00:00
										 |  |  |         $descr     = "Outlet " . $index . " - " .  snmp_get($device, $name_oid, "-Oqv", ""); | 
					
						
							| 
									
										
										
										
											2011-12-09 11:13:20 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', $lowlimit, NULL, $warnlimit, $limit, $current); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-05 16:17:41 +00:00
										 |  |  |   unset($oids); | 
					
						
							| 
									
										
										
										
											2011-12-09 11:13:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-14 19:24:23 +00:00
										 |  |  |   # ATS
 | 
					
						
							| 
									
										
										
										
											2011-03-16 12:22:59 +00:00
										 |  |  |   $oids = snmp_walk($device, "atsConfigPhaseTableIndex", "-OsqnU", "PowerNet-MIB"); | 
					
						
							|  |  |  |   if ($oids) | 
					
						
							| 
									
										
										
										
											2010-07-31 19:49:11 +00:00
										 |  |  |   { | 
					
						
							| 
									
										
										
										
											2011-03-16 12:22:59 +00:00
										 |  |  |     $type = "apc"; | 
					
						
							|  |  |  |     if ($debug) { print_r($oids); } | 
					
						
							|  |  |  |     $oids = trim($oids); | 
					
						
							|  |  |  |     if ($oids) echo("APC PowerNet-MIB ATS "); | 
					
						
							| 
									
										
										
										
											2012-04-05 16:17:41 +00:00
										 |  |  |     $current_oid   = "1.3.6.1.4.1.318.1.1.8.5.4.3.1.4.1.1.1";  #atsOutputCurrent
 | 
					
						
							|  |  |  |     $limit_oid     = "1.3.6.1.4.1.318.1.1.8.4.16.1.5.1";       #atsConfigPhaseOverLoadThreshold
 | 
					
						
							|  |  |  |     $lowlimit_oid  = "1.3.6.1.4.1.318.1.1.8.4.16.1.3.1";       #atsConfigPhaseLowLoadThreshold
 | 
					
						
							|  |  |  |     $warnlimit_oid = "1.3.6.1.4.1.318.1.1.8.4.16.1.4.1";       #atsConfigPhaseNearOverLoadThreshold
 | 
					
						
							| 
									
										
										
										
											2011-03-14 19:24:23 +00:00
										 |  |  |     $index         = 1; | 
					
						
							| 
									
										
										
										
											2010-07-31 19:49:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-14 19:24:23 +00:00
										 |  |  |     $current   = snmp_get($device, $current_oid, "-Oqv", "") / $precision; | 
					
						
							| 
									
										
										
										
											2012-04-05 16:17:41 +00:00
										 |  |  |     $limit     = snmp_get($device, $limit_oid, "-Oqv", "");     # No / $precision here! Nice, APC!
 | 
					
						
							|  |  |  |     $lowlimit  = snmp_get($device, $lowlimit_oid, "-Oqv", "");  # No / $precision here! Nice, APC!
 | 
					
						
							|  |  |  |     $warnlimit = snmp_get($device, $warnlimit_oid, "-Oqv", ""); # No / $precision here! Nice, APC!
 | 
					
						
							| 
									
										
										
										
											2011-03-14 19:24:23 +00:00
										 |  |  |     $descr     = "Output Feed"; | 
					
						
							| 
									
										
										
										
											2010-07-31 19:49:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-04 11:04:19 +00:00
										 |  |  |     discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', $lowlimit, NULL, $warnlimit, $limit, $current); | 
					
						
							| 
									
										
										
										
											2010-07-31 19:49:11 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2011-03-16 12:22:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   unset($oids); | 
					
						
							| 
									
										
										
										
											2010-07-31 19:49:11 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2011-03-14 19:24:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-20 19:48:21 +00:00
										 |  |  | ?>
 |