mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
* feature: allow validate.php to be run from any working directory * remove redundant realpath() call * re-add realpath() to remove symbolic links * realpath() isn't needed... * chdir() in all php scripts in ./ and ./scripts/ * update-sql.php clearly is not used, as it was broken. * Change some scripts to executable Remove extra chdir() call in snmp-scan.php * Missed console-ui.php Kind of fixed console-ui.php help output * Re-add newline
47 lines
1.0 KiB
PHP
Executable File
47 lines
1.0 KiB
PHP
Executable File
#!/usr/bin/env php
|
|
<?php
|
|
|
|
/**
|
|
* LibreNMS
|
|
*
|
|
* This file is part of LibreNMS.
|
|
*
|
|
* @package LibreNMS
|
|
* @subpackage snmptraps
|
|
* @copyright (C) 2006 - 2012 Adam Armstrong
|
|
*/
|
|
|
|
chdir(__DIR__); // cwd to the directory containing this script
|
|
|
|
ini_set('display_errors', 1);
|
|
ini_set('display_startup_errors', 1);
|
|
ini_set('log_errors', 1);
|
|
ini_set('error_reporting', E_ALL);
|
|
|
|
require 'includes/defaults.inc.php';
|
|
require 'config.php';
|
|
require 'includes/definitions.inc.php';
|
|
require 'includes/functions.php';
|
|
|
|
$entry = explode(',', $argv[1]);
|
|
|
|
logfile($argv[1]);
|
|
|
|
// print_r($entry);
|
|
$device = @dbFetchRow('SELECT * FROM devices WHERE `hostname` = ?', array($entry['0']));
|
|
|
|
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']));
|
|
}
|
|
|
|
if (!$device['device_id']) {
|
|
exit;
|
|
}
|
|
|
|
$file = $config['install_dir'].'/includes/snmptrap/'.$entry['1'].'.inc.php';
|
|
if (is_file($file)) {
|
|
include "$file";
|
|
} else {
|
|
echo "unknown trap ($file)";
|
|
}
|