mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
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:
@@ -957,10 +957,12 @@ function enable_os_graphs($os, &$graph_enable)
|
||||
*/
|
||||
function enable_graphs($device, &$graph_enable)
|
||||
{
|
||||
// These are standard graphs we should have for all systems
|
||||
// These are standard graphs we should have for (almost) all systems
|
||||
$graph_enable['poller']['poller_perf'] = 'device_poller_perf';
|
||||
$graph_enable['poller']['poller_modules_perf'] = 'device_poller_modules_perf';
|
||||
if (can_ping_device($device) === true) {
|
||||
if (!$device['snmp_disable']) {
|
||||
$graph_enable['poller']['poller_modules_perf'] = 'device_poller_modules_perf';
|
||||
}
|
||||
if (get_dev_attrib($device, "override_icmp_disable") != "true" && can_ping_device($device) === true) {
|
||||
$graph_enable['poller']['ping_perf'] = 'device_ping_perf';
|
||||
}
|
||||
|
||||
|
5
includes/definitions/ping.yaml
Normal file
5
includes/definitions/ping.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
os: ping
|
||||
text: 'Ping only'
|
||||
over:
|
||||
- { graph: device_ping_perf, text: ICMP Response }
|
||||
type: server
|
@@ -144,16 +144,20 @@ function discover_device(&$device, $options = null)
|
||||
|
||||
echo "\n";
|
||||
|
||||
// If we've specified modules, use them, else walk the modules array
|
||||
$force_module = false;
|
||||
if ($options['m']) {
|
||||
Config::set('discovery_modules', array());
|
||||
foreach (explode(',', $options['m']) as $module) {
|
||||
if (is_file("includes/discovery/$module.inc.php")) {
|
||||
Config::set("discovery_modules.$module", 1);
|
||||
$force_module = true;
|
||||
if ($device['snmp_disable'] != '1') {
|
||||
// If we've specified modules, use them, else walk the modules array
|
||||
if ($options['m']) {
|
||||
Config::set('discovery_modules', array());
|
||||
foreach (explode(',', $options['m']) as $module) {
|
||||
if (is_file("includes/discovery/$module.inc.php")) {
|
||||
Config::set("discovery_modules.$module", 1);
|
||||
$force_module = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Config::set('discovery_modules', array());
|
||||
}
|
||||
foreach (Config::get('discovery_modules', array()) as $module => $module_status) {
|
||||
$os_module_status = Config::getOsSetting($device['os'], "discovery_modules.$module");
|
||||
|
@@ -459,6 +459,7 @@ function delete_device($id)
|
||||
* @param string $poller_group the poller group this device will belong to
|
||||
* @param boolean $force_add add even if the device isn't reachable
|
||||
* @param string $port_assoc_mode snmp field to use to determine unique ports
|
||||
* @param array $additional an array with additional parameters to take into consideration when adding devices
|
||||
*
|
||||
* @return int returns the device_id of the added device
|
||||
*
|
||||
@@ -469,7 +470,7 @@ function delete_device($id)
|
||||
* @throws InvalidPortAssocModeException The given port association mode was invalid
|
||||
* @throws SnmpVersionUnsupportedException The given snmp version was invalid
|
||||
*/
|
||||
function addHost($host, $snmp_version = '', $port = '161', $transport = 'udp', $poller_group = '0', $force_add = false, $port_assoc_mode = 'ifIndex')
|
||||
function addHost($host, $snmp_version = '', $port = '161', $transport = 'udp', $poller_group = '0', $force_add = false, $port_assoc_mode = 'ifIndex', $additional = array())
|
||||
{
|
||||
global $config;
|
||||
|
||||
@@ -509,6 +510,9 @@ function addHost($host, $snmp_version = '', $port = '161', $transport = 'udp', $
|
||||
$snmpvers = array($snmp_version);
|
||||
}
|
||||
|
||||
if (isset($additional['snmp_disable']) && $additional['snmp_disable'] == 1) {
|
||||
return createHost($host, '', $snmp_version, $port, $transport, array(), $poller_group, 1, true, $additional);
|
||||
}
|
||||
$host_unreachable_exception = new HostUnreachableException("Could not connect to $host, please check the snmp details and snmp reachability");
|
||||
// try different snmp variables to add the device
|
||||
foreach ($snmpvers as $snmpver) {
|
||||
@@ -537,7 +541,11 @@ function addHost($host, $snmp_version = '', $port = '161', $transport = 'udp', $
|
||||
throw new SnmpVersionUnsupportedException("Unsupported SNMP Version \"$snmpver\", must be v1, v2c, or v3");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($additional['ping_fallback']) && $additional['ping_fallback'] == 1) {
|
||||
$additional['snmp_disable'] = 1;
|
||||
$additional['os'] = "ping";
|
||||
return createHost($host, '', $snmp_version, $port, $transport, array(), $poller_group, 1, true, $additional);
|
||||
}
|
||||
throw $host_unreachable_exception;
|
||||
}
|
||||
|
||||
@@ -717,6 +725,7 @@ function getpollergroup($poller_group = '0')
|
||||
* @param int $poller_group distributed poller group to assign this host to
|
||||
* @param string $port_assoc_mode field to use to identify ports: ifIndex, ifName, ifDescr, ifAlias
|
||||
* @param bool $force_add Do not detect the host os
|
||||
* @param array $additional an array with additional parameters to take into consideration when adding devices
|
||||
* @return int the id of the added host
|
||||
* @throws HostExistsException Throws this exception if the host already exists
|
||||
* @throws Exception Throws this exception if insertion into the database fails
|
||||
@@ -730,7 +739,8 @@ function createHost(
|
||||
$v3 = array(),
|
||||
$poller_group = 0,
|
||||
$port_assoc_mode = 'ifIndex',
|
||||
$force_add = false
|
||||
$force_add = false,
|
||||
$additional = array()
|
||||
) {
|
||||
$host = trim(strtolower($host));
|
||||
|
||||
@@ -745,7 +755,8 @@ function createHost(
|
||||
$device = array(
|
||||
'hostname' => $host,
|
||||
'sysName' => $host,
|
||||
'os' => 'generic',
|
||||
'os' => $additional['os'] ? $additional['os'] : 'generic',
|
||||
'hardware' => $additional['hardware'] ? $additional['hardware'] : null,
|
||||
'community' => $community,
|
||||
'port' => $port,
|
||||
'transport' => $transport,
|
||||
@@ -754,6 +765,7 @@ function createHost(
|
||||
'poller_group' => $poller_group,
|
||||
'status_reason' => '',
|
||||
'port_association_mode' => $port_assoc_mode,
|
||||
'snmp_disable' => $additional['snmp_disable'] ? $additional['snmp_disable'] : 0,
|
||||
);
|
||||
|
||||
$device = array_merge($device, $v3); // merge v3 settings
|
||||
@@ -2114,7 +2126,7 @@ function device_is_up($device, $record_perf = false)
|
||||
$response = array();
|
||||
$response['ping_time'] = $ping_response['last_ping_timetaken'];
|
||||
if ($ping_response['result']) {
|
||||
if (isSNMPable($device)) {
|
||||
if ($device['snmp_disable'] || isSNMPable($device)) {
|
||||
$response['status'] = '1';
|
||||
$response['status_reason'] = '';
|
||||
} else {
|
||||
@@ -2128,7 +2140,7 @@ function device_is_up($device, $record_perf = false)
|
||||
$response['status_reason'] = 'icmp';
|
||||
}
|
||||
|
||||
if ($device['status'] != $response['status']) {
|
||||
if ($device['status'] != $response['status'] || $device['status_reason'] != $response['status_reason']) {
|
||||
dbUpdate(
|
||||
array('status' => $response['status'], 'status_reason' => $response['status_reason']),
|
||||
'devices',
|
||||
|
@@ -259,18 +259,22 @@ function poll_device($device, $options)
|
||||
$graphs = array();
|
||||
$oldgraphs = array();
|
||||
|
||||
// we always want the core module to be included
|
||||
include 'includes/polling/core.inc.php';
|
||||
|
||||
$force_module = false;
|
||||
if ($options['m']) {
|
||||
$config['poller_modules'] = array();
|
||||
foreach (explode(',', $options['m']) as $module) {
|
||||
if (is_file('includes/polling/'.$module.'.inc.php')) {
|
||||
$config['poller_modules'][$module] = 1;
|
||||
$force_module = true;
|
||||
if (!$device['snmp_disable']) {
|
||||
// we always want the core module to be included
|
||||
include 'includes/polling/core.inc.php';
|
||||
|
||||
if ($options['m']) {
|
||||
$config['poller_modules'] = array();
|
||||
foreach (explode(',', $options['m']) as $module) {
|
||||
if (is_file('includes/polling/'.$module.'.inc.php')) {
|
||||
$config['poller_modules'][$module] = 1;
|
||||
$force_module = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$config['poller_modules'] = array();
|
||||
}
|
||||
foreach ($config['poller_modules'] as $module => $module_status) {
|
||||
$os_module_status = $config['os'][$device['os']]['poller_modules'][$module];
|
||||
|
Reference in New Issue
Block a user