mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Updated adding devices for distributed poller
This commit is contained in:
39
addhost.php
39
addhost.php
@@ -20,6 +20,23 @@ include("config.php");
|
||||
include("includes/definitions.inc.php");
|
||||
include("includes/functions.php");
|
||||
|
||||
$options = getopt("g:f::");
|
||||
|
||||
echo $options['g'];
|
||||
if (isset($options['g']) && $options['g'] >= 0) {
|
||||
$cmd = array_shift($argv);
|
||||
array_shift($argv);
|
||||
array_shift($argv);
|
||||
array_unshift($argv, $cmd);
|
||||
$poller_group = $options['g'];
|
||||
}
|
||||
if (isset($options['f']) && $options['f'] == 0) {
|
||||
$cmd = array_shift($argv);
|
||||
array_shift($argv);
|
||||
array_unshift($argv, $cmd);
|
||||
$force_add = 1;
|
||||
}
|
||||
|
||||
if (!empty($argv[1]))
|
||||
{
|
||||
$host = strtolower($argv[1]);
|
||||
@@ -70,7 +87,7 @@ if (!empty($argv[1]))
|
||||
if ($seclevel === "nanp")
|
||||
{ array_push($config['snmp']['v3'], $v3); }
|
||||
|
||||
$device_id = addHost($host, $snmpver, $port, $transport);
|
||||
$device_id = addHost($host, $snmpver, $port, $transport,0,$poller_group,$force_add);
|
||||
|
||||
}
|
||||
elseif ($seclevel === "anp" or $seclevel === "authNoPriv")
|
||||
@@ -99,7 +116,7 @@ if (!empty($argv[1]))
|
||||
}
|
||||
|
||||
array_push($config['snmp']['v3'], $v3);
|
||||
$device_id = addHost($host, $snmpver, $port, $transport);
|
||||
$device_id = addHost($host, $snmpver, $port, $transport,0,$poller_group,$force_add);
|
||||
|
||||
}
|
||||
elseif ($seclevel === "ap" or $seclevel === "authPriv")
|
||||
@@ -132,7 +149,7 @@ if (!empty($argv[1]))
|
||||
}
|
||||
|
||||
array_push($config['snmp']['v3'], $v3);
|
||||
$device_id = addHost($host, $snmpver, $port, $transport);
|
||||
$device_id = addHost($host, $snmpver, $port, $transport,0,$poller_group,$force_add);
|
||||
|
||||
}
|
||||
else
|
||||
@@ -166,7 +183,7 @@ if (!empty($argv[1]))
|
||||
$config['snmp']['community'] = array($community);
|
||||
}
|
||||
|
||||
$device_id = addHost($host, $snmpver, $port, $transport);
|
||||
$device_id = addHost($host, $snmpver, $port, $transport,0,$poller_group,$force_add);
|
||||
}
|
||||
|
||||
if ($snmpver)
|
||||
@@ -181,7 +198,7 @@ if (!empty($argv[1]))
|
||||
while (!$device_id && count($snmpversions))
|
||||
{
|
||||
$snmpver = array_shift($snmpversions);
|
||||
$device_id = addHost($host, $snmpver, $port, $transport);
|
||||
$device_id = addHost($host, $snmpver, $port, $transport,0,$poller_group,$force_add);
|
||||
}
|
||||
|
||||
if ($device_id)
|
||||
@@ -194,11 +211,13 @@ if (!empty($argv[1]))
|
||||
|
||||
print $console_color->convert("\n" . $config['project_name_version']." Add Host Tool
|
||||
|
||||
Usage (SNMPv1/2c): ./addhost.php <%Whostname%n> [community] [v1|v2c] [port] [" . implode("|",$config['snmp']['transports']) . "]
|
||||
Usage (SNMPv3) : Config Defaults : ./addhost.php <%Whostname%n> any v3 [user] [port] [" . implode("|",$config['snmp']['transports']) . "]
|
||||
No Auth, No Priv : ./addhost.php <%Whostname%n> nanp v3 [user] [port] [" . implode("|",$config['snmp']['transports']) . "]
|
||||
Auth, No Priv : ./addhost.php <%Whostname%n> anp v3 <user> <password> [md5|sha] [port] [" . implode("|",$config['snmp']['transports']) . "]
|
||||
Auth, Priv : ./addhost.php <%Whostname%n> ap v3 <user> <password> <enckey> [md5|sha] [aes|dsa] [port] [" . implode("|",$config['snmp']['transports']) . "]
|
||||
Usage (SNMPv1/2c): ./addhost.php [-g <poller group>] [-f] <%Whostname%n> [community] [v1|v2c] [port] [" . implode("|",$config['snmp']['transports']) . "]
|
||||
Usage (SNMPv3) : Config Defaults : ./addhost.php [-g <poller group>] [-f]<%Whostname%n> any v3 [user] [port] [" . implode("|",$config['snmp']['transports']) . "]
|
||||
No Auth, No Priv : ./addhost.php [-g <poller group>] [-f]<%Whostname%n> nanp v3 [user] [port] [" . implode("|",$config['snmp']['transports']) . "]
|
||||
Auth, No Priv : ./addhost.php [-g <poller group>] [-f]<%Whostname%n> anp v3 <user> <password> [md5|sha] [port] [" . implode("|",$config['snmp']['transports']) . "]
|
||||
Auth, Priv : ./addhost.php [-g <poller group>] [-f]<%Whostname%n> ap v3 <user> <password> <enckey> [md5|sha] [aes|dsa] [port] [" . implode("|",$config['snmp']['transports']) . "]
|
||||
-g <poller group> allows you to add a device to be pinned to a specific poller when using distributed polling. X can be any number associated with a poller group
|
||||
-f forces the device to be added by skipping the icmp and snmp check against the host.
|
||||
%rRemember to run discovery for the host afterwards.%n
|
||||
|
||||
");
|
||||
|
||||
Reference in New Issue
Block a user