| 
									
										
										
										
											2010-09-03 18:26:59 +00:00
										 |  |  | #!/usr/bin/env php
 | 
					
						
							| 
									
										
										
										
											2010-02-17 11:02:18 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-09 10:01:42 +00:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2013-10-28 12:01:36 -07:00
										 |  |  |  * Observium | 
					
						
							| 
									
										
										
										
											2012-05-09 10:01:42 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2013-10-28 12:01:36 -07:00
										 |  |  |  *   This file is part of Observium. | 
					
						
							| 
									
										
										
										
											2012-05-09 10:01:42 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2013-10-28 12:01:36 -07:00
										 |  |  |  * @package    observium | 
					
						
							|  |  |  |  * @subpackage snmptraps | 
					
						
							|  |  |  |  * @author     Adam Armstrong <adama@memetic.org> | 
					
						
							|  |  |  |  * @copyright  (C) 2006 - 2012 Adam Armstrong | 
					
						
							| 
									
										
										
										
											2012-05-09 10:01:42 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-16 22:04:29 +00:00
										 |  |  | ini_set('display_errors', 1); | 
					
						
							|  |  |  | ini_set('display_startup_errors', 1); | 
					
						
							|  |  |  | ini_set('log_errors', 1); | 
					
						
							|  |  |  | ini_set('error_reporting', E_ALL); | 
					
						
							| 
									
										
										
										
											2010-02-17 11:02:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | require 'includes/defaults.inc.php'; | 
					
						
							|  |  |  | require 'config.php'; | 
					
						
							|  |  |  | require 'includes/definitions.inc.php'; | 
					
						
							|  |  |  | require 'includes/functions.php'; | 
					
						
							| 
									
										
										
										
											2010-02-17 11:02:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | $entry = explode(',', $argv[1]); | 
					
						
							| 
									
										
										
										
											2010-02-17 11:02:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-14 18:28:00 +00:00
										 |  |  | logfile($argv[1]); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | // print_r($entry);
 | 
					
						
							|  |  |  | $device = @dbFetchRow('SELECT * FROM devices WHERE `hostname` = ?', array($entry['0'])); | 
					
						
							| 
									
										
										
										
											2010-02-17 11:02:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | if (!$device['device_id']) { | 
					
						
							|  |  |  |     $device = @dbFetchRow('SELECT * FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = ? AND I.port_id = A.port_id', array($entry['0'])); | 
					
						
							| 
									
										
										
										
											2011-03-16 22:04:29 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2010-02-17 11:02:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | if (!$device['device_id']) { | 
					
						
							|  |  |  |     exit; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2011-03-16 22:04:29 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | $file = $config['install_dir'].'/includes/snmptrap/'.$entry['1'].'.inc.php'; | 
					
						
							|  |  |  | if (is_file($file)) { | 
					
						
							|  |  |  |     include "$file"; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | else { | 
					
						
							|  |  |  |     echo "unknown trap ($file)"; | 
					
						
							|  |  |  | } |