feature: Support for up/down detection of ping only devices.

* Added support for ping only devices.

* Renamed sql-schema/206 to 207.

* Discovery tried to detect the OS when it shouldn't.

* Updated db_schema.yaml

* Added ping icon.

* Don't show unused graphs and tabs when SNMP is disabled.

* Allow the user to specify OS of ping only devices.

* Removing custom OS now changes it to 'ping'.

* Removed unnecessary use of mres().

* UI select box for SNMP enable/disable.

* Hide device_ping_perf if ping is disable on device.

* Fixed SNMP settings update status messages.

* Added functionality to add ping only devices via the web ui.

* Added ping only option to addhost.php

* Added ping only support to snmp-scan.py

* Moved sql 208 to 211

* Fixed scrutinizer issues.

* Fixed broken ossearch.

* Added ping only support to the API.

* Updated API doc.

* Added (optional) to OS and hardware description. Hid Port Settings, Applications, Modules, Storage, Processors, Memory and Components from the edit menu

* Style fix.

* Updated ping icon.

* clean() instead of mres(). More escaping. Better help in snmp-scan.py and addhost.php

* Fixed scrutinizer issue.

* Always try SNMP in snmp-scan.py, new option for it in addhost.php. Slice instead of chunk in ajax_ossuggest.php. Other minor style changes.

* Updated sql modifications to insert the new column in the same place as in db_schema.yaml.
This commit is contained in:
Zmegolaz
2017-10-28 05:59:25 +02:00
committed by Tony Murray
parent a81ce594c7
commit f8d7ccfe0d
20 changed files with 578 additions and 249 deletions

View File

@@ -16,7 +16,7 @@ use LibreNMS\Exceptions\HostUnreachableException;
$init_modules = array();
require __DIR__ . '/includes/init.php';
$options = getopt('g:p:f::');
$options = getopt('Pbg:p:f::');
if (isset($options['g']) && $options['g'] >= 0) {
$cmd = array_shift($argv);
@@ -55,6 +55,18 @@ if (isset($options['p'])) {
array_unshift($argv, $cmd);
}
if (isset($options['P'])) {
$cmd = array_shift($argv);
array_shift($argv);
array_unshift($argv, $cmd);
}
if (isset($options['b'])) {
$cmd = array_shift($argv);
array_shift($argv);
array_unshift($argv, $cmd);
}
if (!empty($argv[1])) {
$host = strtolower($argv[1]);
$community = $argv[2];
@@ -63,7 +75,21 @@ if (!empty($argv[1])) {
$port = 161;
$transport = 'udp';
if ($snmpver === 'v3') {
$additional = array();
if (isset($options['b'])) {
$additional = array(
'ping_fallback' => 1,
);
}
if (isset($options['P'])) {
$community = '';
$snmpver = 'v2c';
$additional = array(
'snmp_disable' => 1,
'os' => $argv[2] ? mres($argv[2]) : "ping",
'hardware' => $argv[3] ? mres($argv[3]) : '',
);
} elseif ($snmpver === 'v3') {
$seclevel = $community;
// These values are the same as in defaults.inc.php
@@ -163,7 +189,7 @@ if (!empty($argv[1])) {
}//end if
try {
$device_id = addHost($host, $snmpver, $port, $transport, $poller_group, $force_add, $port_assoc_mode);
$device_id = addHost($host, $snmpver, $port, $transport, $poller_group, $force_add, $port_assoc_mode, $additional);
$device = device_by_id_cache($device_id);
echo "Added device {$device['hostname']} ($device_id)\n";
exit(0);
@@ -181,18 +207,22 @@ if (!empty($argv[1])) {
c_echo(
"\n".$config['project_name_version'].' Add Host Tool
Usage (SNMPv1/2c): ./addhost.php [-g <poller group>] [-f] [-p <port assoc mode>] <%Whostname%n> [community] [v1|v2c] [port] ['.implode('|', $config['snmp']['transports']).']
Usage (SNMPv3) : Config Defaults : ./addhost.php [-g <poller group>] [-f] [-p <port assoc mode>] <%Whostname%n> any v3 [user] [port] ['.implode('|', $config['snmp']['transports']).']
No Auth, No Priv : ./addhost.php [-g <poller group>] [-f] [-p <port assoc mode>] <%Whostname%n> nanp v3 [user] [port] ['.implode('|', $config['snmp']['transports']).']
Auth, No Priv : ./addhost.php [-g <poller group>] [-f] [-p <port assoc mode>] <%Whostname%n> anp v3 <user> <password> [md5|sha] [port] ['.implode('|', $config['snmp']['transports']).']
Auth, Priv : ./addhost.php [-g <poller group>] [-f] [-p <port assoc mode>] <%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] [-b] [-p <port assoc mode>] <%Whostname%n> [community] [v1|v2c] [port] ['.implode('|', $config['snmp']['transports']).']
Usage (SNMPv3) :
Config Defaults : ./addhost.php [-g <poller group>] [-f] [-b] [-p <port assoc mode>] <%Whostname%n> any v3 [user] [port] ['.implode('|', $config['snmp']['transports']).']
No Auth, No Priv : ./addhost.php [-g <poller group>] [-f] [-b] [-p <port assoc mode>] <%Whostname%n> nanp v3 [user] [port] ['.implode('|', $config['snmp']['transports']).']
Auth, No Priv : ./addhost.php [-g <poller group>] [-f] [-b] [-p <port assoc mode>] <%Whostname%n> anp v3 <user> <password> [md5|sha] [port] ['.implode('|', $config['snmp']['transports']).']
Auth, Priv : ./addhost.php [-g <poller group>] [-f] [-b] [-p <port assoc mode>] <%Whostname%n> ap v3 <user> <password> <enckey> [md5|sha] [aes|dsa] [port] ['.implode('|', $config['snmp']['transports']).']
Usage (ICMP only) : ./addhost.php [-g <poller group>] [-f] -P <%Whostname%n> [os] [hardware]
-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.
-p <port assoc mode> allow you to set a port association mode for this device. By default ports are associated by \'ifIndex\'.
For Linux/Unix based devices \'ifName\' or \'ifDescr\' might be useful for a stable iface mapping.
The default for this installation is \'' . $config['default_port_association_mode'] . '\'
Valid port assoc modes are: ' . join(', ', $valid_assoc_modes) . '
-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.
-p <port assoc mode> allow you to set a port association mode for this device. By default ports are associated by \'ifIndex\'.
For Linux/Unix based devices \'ifName\' or \'ifDescr\' might be useful for a stable iface mapping.
The default for this installation is \'' . $config['default_port_association_mode'] . '\'
Valid port assoc modes are: ' . join(', ', $valid_assoc_modes) . '
-b Add the host with SNMP if it replies to it, otherwise only ICMP.
-P Add the host with only ICMP, no SNMP or OS discovery.
%rRemember to run discovery for the host afterwards.%n
'