diff --git a/discovery.php b/discovery.php index 3006399ff..e29b4d60d 100755 --- a/discovery.php +++ b/discovery.php @@ -22,8 +22,8 @@ require 'includes/discovery/functions.inc.php'; $start = utime(); $runtime_stats = array(); - -$options = getopt('h:m:i:n:d::a::q'); +$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"; @@ -59,8 +59,18 @@ if (isset($options['h'])) { }//end if }//end if +if (isset($options['os'])) { + $where .= " AND os = ?"; + $sqlparams[] = $options['os']; +} + +if (isset($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']; } @@ -85,9 +95,11 @@ if (!$where) { echo "-h odd Poll odd numbered devices (same as -i 2 -n 0)\n"; 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\n"; + echo "-h new Poll all devices that have not had a discovery run before\n"; + echo "--os Poll devices only with specified operating system\n"; + echo "--type Poll devices only with specified type\n"; echo "-i -n Poll as instance of \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"; @@ -105,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); }