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
|
|
|
/**
|
2016-09-08 14:12:23 +01:00
|
|
|
* LibreNMS
|
2012-05-09 10:01:42 +00:00
|
|
|
*
|
2016-09-08 14:12:23 +01:00
|
|
|
* This file is part of LibreNMS.
|
2012-05-09 10:01:42 +00:00
|
|
|
*
|
2016-09-08 14:12:23 +01:00
|
|
|
* @package LibreNMS
|
2013-10-28 12:01:36 -07:00
|
|
|
* @subpackage snmptraps
|
|
|
|
* @copyright (C) 2006 - 2012 Adam Armstrong
|
2012-05-09 10:01:42 +00:00
|
|
|
*/
|
|
|
|
|
2016-09-14 10:53:04 -05:00
|
|
|
chdir(__DIR__); // cwd to the directory containing this script
|
|
|
|
|
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
|
|
|
|
2016-11-21 14:12:59 -06:00
|
|
|
$init_modules = array();
|
|
|
|
require __DIR__ . '/includes/init.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";
|
2016-08-28 17:32:55 -05:00
|
|
|
} else {
|
2015-07-10 13:36:21 +02:00
|
|
|
echo "unknown trap ($file)";
|
|
|
|
}
|