-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathsnmptrap.php
executable file
·46 lines (35 loc) · 924 Bytes
/
snmptrap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env php
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage snmptraps
* @copyright (C) Adam Armstrong
*
*/
chdir(dirname($argv[0]));
$options = getopt("d");
if (isset($options['d'])) {
array_shift($argv);
} // for compatibility
include("includes/observium.inc.php");
$entry = explode(",", $argv[1]);
logfile('SNMPTRAP: ' . $argv[1]);
#print_vars($entry);
$device = @dbFetchRow("SELECT * FROM devices WHERE `hostname` = ?", [$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", [$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)");
}
// EOF