mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Adding the ability to use multiple poller groups for a poller.
This commit is contained in:
@@ -28,7 +28,7 @@ if (isset($options['g']) && $options['g'] >= 0) {
|
||||
array_shift($argv);
|
||||
array_unshift($argv, $cmd);
|
||||
$poller_group = $options['g'];
|
||||
} elseif ($config['distributed_poller_group'] > 0 && $config['distributed_poller'] === TRUE) {
|
||||
} elseif ($config['distributed_poller'] === TRUE) {
|
||||
$poller_group = $config['distributed_poller_group'];
|
||||
}
|
||||
|
||||
|
@@ -99,7 +99,7 @@ include("includes/sql-schema/update.php");
|
||||
$discovered_devices = 0;
|
||||
|
||||
if ($config['distributed_poller'] === TRUE) {
|
||||
$where .= " AND poller_group=?";
|
||||
$where .= " AND poller_group IN(?)";
|
||||
$params = array($config['distributed_poller_group']);
|
||||
}
|
||||
foreach (dbFetch("SELECT * FROM `devices` WHERE status = 1 AND disabled = 0 $where ORDER BY device_id DESC",$params) as $device)
|
||||
|
@@ -530,14 +530,36 @@ function utime()
|
||||
return $sec + $usec;
|
||||
}
|
||||
|
||||
function getpollergroup($poller_group='0')
|
||||
{
|
||||
//Is poller group an integer
|
||||
if (is_int($poller_group) || ctype_digit($poller_group)) {
|
||||
return $poller_group;
|
||||
} else {
|
||||
//Check if it contains a comma
|
||||
if (strpos($poller_group,',')!== FALSE) {
|
||||
//If it has a comma use the first element as the poller group
|
||||
$poller_group=explode(',',$poller_group)[0];
|
||||
return getpollergroup($poller_group);
|
||||
} else {
|
||||
if ($config['distributed_poller_group']) {
|
||||
//If not use the poller's group from the config
|
||||
return getpollergroup($config['distributed_poller_group']);
|
||||
} else {
|
||||
//If all else fails use default
|
||||
return '0';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createHost($host, $community = NULL, $snmpver, $port = 161, $transport = 'udp', $v3 = array(), $poller_group='0')
|
||||
{
|
||||
global $config;
|
||||
$host = trim(strtolower($host));
|
||||
|
||||
if (is_numeric($poller_group) === FALSE) {
|
||||
$poller_group = $config['distributed_poller_group'];
|
||||
}
|
||||
$poller_group=getpollergroup($poller_group);
|
||||
|
||||
$device = array('hostname' => $host,
|
||||
'sysName' => $host,
|
||||
'community' => $community,
|
||||
|
@@ -195,7 +195,7 @@ except:
|
||||
"""
|
||||
# (c) 2015, GPLv3, Daniel Preussker <f0o@devilcode.org> <<<EOC2
|
||||
if poller_group is not False:
|
||||
query = "select device_id from devices where poller_group = " + poller_group + " and disabled = 0 order by last_polled_timetaken desc"
|
||||
query = "select device_id from devices where poller_group IN(" + poller_group + ") and disabled = 0 order by last_polled_timetaken desc"
|
||||
else:
|
||||
query = "select device_id from devices where disabled = 0 order by last_polled_timetaken desc"
|
||||
# EOC2
|
||||
|
Reference in New Issue
Block a user