- applied changes made by f0o

This commit is contained in:
Sławomir Paszkiewicz 2015-10-09 19:41:19 +02:00
parent 457babd32d
commit 462b41c4f8

View File

@ -22,8 +22,8 @@ require 'includes/discovery/functions.inc.php';
$start = utime();
$runtime_stats = array();
$options = getopt('h:m:i:n:d::a::q',['os:']);
$sqlparams = array();
$options = getopt('h:m:i:n:d::a::q',array('os:','type:'));
if (!isset($options['q'])) {
echo $config['project_name_version']." Discovery\n";
@ -47,10 +47,6 @@ if (isset($options['h'])) {
$where = 'AND `last_discovered` IS NULL';
$doing = 'new';
}
else if ($options['h'] == 'linux') {
$where = 'AND os = "linux"';
$doing = 'linux';
}
else if ($options['h']) {
if (is_numeric($options['h'])) {
$where = "AND `device_id` = '".$options['h']."'";
@ -64,17 +60,17 @@ if (isset($options['h'])) {
}//end if
if (isset($options['os'])) {
$where = $where." AND os = '".$options['os']."'";
$doing = $options['os'];
$where .= " AND os = ?";
$sqlparams[] = $options['os'];
}
if (isset($options['type'])) {
$where = $where." AND type = '".$options['type']."'";
$doing = $options['type'];
$where .= " AND type = ?";
$sqlparams[] = $options['type'];
}
if (isset($options['i']) && $options['i'] && isset($options['n'])) {
$where = 'AND MOD(device_id,'.$options['i'].") = '".$options['n']."'";
$where .= ' AND MOD(device_id,'.$options['i'].") = '".$options['n']."'";
$doing = $options['n'].'/'.$options['i'];
}
@ -100,10 +96,10 @@ if (!$where) {
echo "-h even Poll even numbered devices (same as -i 2 -n 1)\n";
echo "-h all Poll all devices\n";
echo "-h new Poll all devices that have not had a discovery run before\n";
echo "-h [odd|even|new|all] --os <os_name> Poll devices only with specified operating system\n";
echo "-h [odd|even|new|all] --type <type> Poll devices only with specified type\n\n";
echo "--os <os_name> Poll devices only with specified operating system\n";
echo "--type <type> Poll devices only with specified type\n";
echo "-i <instances> -n <number> Poll as instance <number> of <instances>\n";
echo " Instances start at 0. 0-3 for -n 4\n\n";
echo " Instances start at 0. 0-3 for -n 4\n";
echo "\n";
echo "Debugging and testing options:\n";
echo "-d Enable debugging output\n";
@ -121,7 +117,7 @@ if ($config['distributed_poller'] === true) {
$where .= ' AND poller_group IN('.$config['distributed_poller_group'].')';
}
foreach (dbFetch("SELECT * FROM `devices` WHERE status = 1 AND disabled = 0 $where ORDER BY device_id DESC") as $device) {
foreach (dbFetch("SELECT * FROM `devices` WHERE status = 1 AND disabled = 0 $where ORDER BY device_id DESC",$sqlparams) as $device) {
discover_device($device, $options);
}