git-svn-id: http://www.observium.org/svn/observer/trunk@484 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2009-10-13 10:13:04 +00:00
parent ef6df60201
commit 4c94cce97e
3 changed files with 5525 additions and 3 deletions

File diff suppressed because it is too large Load Diff

39
new-poller.php Executable file
View File

@@ -0,0 +1,39 @@
#!/usr/bin/php
<?php
include("config.php");
include("includes/functions.php");
if($argv[1]) { $where = "WHERE `device_id` = '$argv[1]'"; }
function snmp_array($oid, $device, $mib = 0) {
global $config;
$cmd = $config['snmpbulkwalk'] . " -O Qs -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ";
if($mib) { $cmd .= "-m $mib "; }
$cmd .= $oid;
$data = trim(shell_exec($cmd));
$array = array();
$device_id = $device['device_id'];
foreach(explode("\n", $data) as $entry) {
list ($this_oid, $this_value) = split(" = ", $entry);
list ($this_oid, $this_index) = explode(".", $this_oid);
$array[$device_id][$this_oid][$this_index] = $this_value;
}
return $array;
}
$interface_data = array();
$device_query = mysql_query("SELECT * FROM `devices` $where ORDER BY device_id DESC");
while ($device = mysql_fetch_array($device_query)) {
$oids = array('ifName','ifDescr','ifAlias');
foreach ($oids as $oid) {
$entries = snmp_array($oid, $device);
$interface_data = @array_merge($entries, $interface_data);
}
print_r($interface_data);
}
?>

View File

@@ -6,9 +6,6 @@ include("includes/functions.php");
$search = $argv[1] . "$";
$data = trim(`cat ips-scanned.txt | grep alive | cut -d" " -f 1 | egrep $search`);
foreach( explode("\n", $data) as $ip) {