mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-12 16:06:25 +02:00
- applied changes made by f0o
This commit is contained in:
+11
-15
@@ -22,8 +22,8 @@ require 'includes/discovery/functions.inc.php';
|
|||||||
|
|
||||||
$start = utime();
|
$start = utime();
|
||||||
$runtime_stats = array();
|
$runtime_stats = array();
|
||||||
|
$sqlparams = array();
|
||||||
$options = getopt('h:m:i:n:d::a::q',['os:']);
|
$options = getopt('h:m:i:n:d::a::q',array('os:','type:'));
|
||||||
|
|
||||||
if (!isset($options['q'])) {
|
if (!isset($options['q'])) {
|
||||||
echo $config['project_name_version']." Discovery\n";
|
echo $config['project_name_version']." Discovery\n";
|
||||||
@@ -47,10 +47,6 @@ if (isset($options['h'])) {
|
|||||||
$where = 'AND `last_discovered` IS NULL';
|
$where = 'AND `last_discovered` IS NULL';
|
||||||
$doing = 'new';
|
$doing = 'new';
|
||||||
}
|
}
|
||||||
else if ($options['h'] == 'linux') {
|
|
||||||
$where = 'AND os = "linux"';
|
|
||||||
$doing = 'linux';
|
|
||||||
}
|
|
||||||
else if ($options['h']) {
|
else if ($options['h']) {
|
||||||
if (is_numeric($options['h'])) {
|
if (is_numeric($options['h'])) {
|
||||||
$where = "AND `device_id` = '".$options['h']."'";
|
$where = "AND `device_id` = '".$options['h']."'";
|
||||||
@@ -64,17 +60,17 @@ if (isset($options['h'])) {
|
|||||||
}//end if
|
}//end if
|
||||||
|
|
||||||
if (isset($options['os'])) {
|
if (isset($options['os'])) {
|
||||||
$where = $where." AND os = '".$options['os']."'";
|
$where .= " AND os = ?";
|
||||||
$doing = $options['os'];
|
$sqlparams[] = $options['os'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['type'])) {
|
if (isset($options['type'])) {
|
||||||
$where = $where." AND type = '".$options['type']."'";
|
$where .= " AND type = ?";
|
||||||
$doing = $options['type'];
|
$sqlparams[] = $options['type'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['i']) && $options['i'] && isset($options['n'])) {
|
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'];
|
$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 even Poll even numbered devices (same as -i 2 -n 1)\n";
|
||||||
echo "-h all Poll all devices\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 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 "--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 "--type <type> Poll devices only with specified type\n";
|
||||||
echo "-i <instances> -n <number> Poll as instance <number> of <instances>\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 "\n";
|
||||||
echo "Debugging and testing options:\n";
|
echo "Debugging and testing options:\n";
|
||||||
echo "-d Enable debugging output\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'].')';
|
$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);
|
discover_device($device, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user