| 
									
										
										
										
											2011-11-14 16:53:37 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | echo 'Entity Physical: '; | 
					
						
							| 
									
										
										
										
											2011-11-14 16:53:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | if ($device['os'] == 'ios') { | 
					
						
							|  |  |  |     echo "Cisco Cat6xxx/76xx Crossbar : \n"; | 
					
						
							| 
									
										
										
										
											2011-11-14 16:53:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  |     $mod_stats  = snmpwalk_cache_oid($device, 'cc6kxbarModuleModeTable', array(), 'CISCO-CAT6K-CROSSBAR-MIB'); | 
					
						
							|  |  |  |     $chan_stats = snmpwalk_cache_oid($device, 'cc6kxbarModuleChannelTable', array(), 'CISCO-CAT6K-CROSSBAR-MIB'); | 
					
						
							|  |  |  |     $chan_stats = snmpwalk_cache_oid($device, 'cc6kxbarStatisticsTable', $chan_stats, 'CISCO-CAT6K-CROSSBAR-MIB'); | 
					
						
							| 
									
										
										
										
											2011-11-14 16:53:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     foreach ($mod_stats as $index => $entry) { | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  |         $group = 'c6kxbar'; | 
					
						
							|  |  |  |         foreach ($entry as $key => $value) { | 
					
						
							|  |  |  |             $subindex = null; | 
					
						
							|  |  |  |             $entPhysical_state[$index][$subindex][$group][$key] = $value; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-11-14 20:25:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     foreach ($chan_stats as $index => $entry) { | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  |         list($index,$subindex) = explode('.', $index, 2); | 
					
						
							|  |  |  |         $group                 = 'c6kxbar'; | 
					
						
							|  |  |  |         foreach ($entry as $key => $value) { | 
					
						
							|  |  |  |             $entPhysical_state[$index][$subindex][$group][$key] = $value; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-18 16:26:55 +00:00
										 |  |  |         $fields = array( | 
					
						
							|  |  |  |             'inutil'      => $entry['cc6kxbarStatisticsInUtil'], | 
					
						
							|  |  |  |             'oututil'     => $entry['cc6kxbarStatisticsOutUtil'], | 
					
						
							|  |  |  |             'outdropped'  => $entry['cc6kxbarStatisticsOutDropped'], | 
					
						
							|  |  |  |             'outerrors'   => $entry['cc6kxbarStatisticsOutErrors'], | 
					
						
							|  |  |  |             'inerrors'    => $entry['cc6kxbarStatisticsInErrors'], | 
					
						
							|  |  |  |         ); | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         $rrd = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('c6kxbar-'.$index.'-'.$subindex.'.rrd'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if ($debug) { | 
					
						
							|  |  |  |             echo "$rrd "; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (!is_file($rrd)) { | 
					
						
							|  |  |  |             rrdtool_create( | 
					
						
							|  |  |  |                 $rrd, | 
					
						
							|  |  |  |                 '--step 300 \ | 
					
						
							| 
									
										
										
										
											2011-11-14 20:25:13 +00:00
										 |  |  |      DS:inutil:GAUGE:600:0:100 \ | 
					
						
							|  |  |  |      DS:oututil:GAUGE:600:0:100 \ | 
					
						
							|  |  |  |      DS:outdropped:DERIVE:600:0:125000000000 \ | 
					
						
							|  |  |  |      DS:outerrors:DERIVE:600:0:125000000000 \ | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  |      DS:inerrors:DERIVE:600:0:125000000000 '.$config['rrd_rra'] | 
					
						
							|  |  |  |             ); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2011-11-14 16:53:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-18 16:26:55 +00:00
										 |  |  |         rrdtool_update($rrd, $fields); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-19 20:58:02 +00:00
										 |  |  |         $tags = array('index' => $index, 'subindex' => $subindex); | 
					
						
							|  |  |  |         influx_update($device,'c6kxbar',$tags,$fields); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  |     }//end foreach
 | 
					
						
							| 
									
										
										
										
											2011-11-14 16:53:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  |     // print_r($entPhysical_state);
 | 
					
						
							|  |  |  | }//end if
 | 
					
						
							| 
									
										
										
										
											2011-11-14 16:53:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-14 18:28:00 +00:00
										 |  |  | // Set Entity state
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | foreach (dbFetch('SELECT * FROM `entPhysical_state` WHERE `device_id` = ?', array($device['device_id'])) as $entity) { | 
					
						
							|  |  |  |     if (!isset($entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']])) { | 
					
						
							|  |  |  |         dbDelete( | 
					
						
							|  |  |  |             'entPhysical_state', | 
					
						
							|  |  |  |             '`device_id` = ? AND `entPhysicalIndex` = ? AND `subindex` = ? AND `group` = ? AND `key` = ?', | 
					
						
							|  |  |  |             array( | 
					
						
							|  |  |  |              $device['device_id'], | 
					
						
							|  |  |  |              $entity['entPhysicalIndex'], | 
					
						
							|  |  |  |              $entity['subindex'], | 
					
						
							|  |  |  |              $entity['group'], | 
					
						
							|  |  |  |              $entity['key'], | 
					
						
							|  |  |  |             ) | 
					
						
							|  |  |  |         ); | 
					
						
							| 
									
										
										
										
											2011-11-14 16:53:37 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  |     else { | 
					
						
							|  |  |  |         if ($entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']] != $entity['value']) { | 
					
						
							|  |  |  |             echo 'no match!'; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         unset($entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']]); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | }//end foreach
 | 
					
						
							| 
									
										
										
										
											2011-11-14 16:53:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | // End Set Entity Attrivs
 | 
					
						
							| 
									
										
										
										
											2011-11-14 18:28:00 +00:00
										 |  |  | // Delete Entity state
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | foreach ($entPhysical_state as $epi => $entity) { | 
					
						
							|  |  |  |     foreach ($entity as $subindex => $si) { | 
					
						
							|  |  |  |         foreach ($si as $group => $ti) { | 
					
						
							|  |  |  |             foreach ($ti as $key => $value) { | 
					
						
							|  |  |  |                 dbInsert(array('device_id' => $device['device_id'], 'entPhysicalIndex' => $epi, 'subindex' => $subindex, 'group' => $group, 'key' => $key, 'value' => $value), 'entPhysical_state'); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2011-11-14 16:53:37 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | // End Delete Entity state
 | 
					
						
							|  |  |  | echo "\n"; |