Files
librenms-librenms/snmptrap.php
T

30 lines
799 B
PHP
Raw Normal View History

2010-09-03 18:26:59 +00:00
#!/usr/bin/env php
<?php
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);
2011-03-16 22:04:29 +00:00
include("includes/defaults.inc.php");
include("config.php");
include("includes/functions.php");
2011-03-16 22:04:29 +00:00
$entry = explode(",", $argv[1]);
2011-03-16 22:04:29 +00:00
print_r($entry);
2011-05-13 12:39:56 +00:00
$device = @dbFetchRow("SELECT * FROM devices WHERE `hostname` = ?", array($entry['0']));
2011-03-16 22:04:29 +00:00
if (!$device['device_id'])
{
2011-05-13 12:39:56 +00:00
$device = @dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = ? AND I.interface_id = A.interface_id", array($entry['0']));
2011-03-16 22:04:29 +00:00
}
2011-03-16 22:04:29 +00:00
if (!$device['device_id']) { exit; } else { }
2011-03-16 22:04:29 +00:00
$file = $config['install_dir'] . "/includes/snmptrap/".$entry['1'].".inc.php";
if (is_file($file)) { include("$file"); } else { echo("unknown trap ($file)"); exit; }
2011-05-13 12:39:56 +00:00
?>