diff --git a/AUTHORS.md b/AUTHORS.md index 4c3d6983b..0b495e5b1 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -69,4 +69,5 @@ Contributors to LibreNMS: - Rob Gormley (rgormley) - Richard Kojedzinszky (rkojedzinszky) - Tony Murray (murrant) +- Peter Lamperud (vizay) [1]: http://observium.org/ "Observium web site" diff --git a/html/includes/authentication/active_directory.inc.php b/html/includes/authentication/active_directory.inc.php index a562ae901..a1dd80f86 100644 --- a/html/includes/authentication/active_directory.inc.php +++ b/html/includes/authentication/active_directory.inc.php @@ -35,6 +35,7 @@ function authenticate($username, $password) { if (isset($config['auth_ad_groups'][$group_cn]['level'])) { // user is in one of the defined groups $user_authenticated = 1; + adduser($username); } } @@ -43,6 +44,7 @@ function authenticate($username, $password) { } else { // group membership is not required and user is valid + adduser($username); return 1; } } @@ -81,11 +83,20 @@ function auth_usermanagement() { } -function adduser() { - // not supported so return 0 - return 0; +function adduser($username) { + // Check to see if user is already added in the database + if (!user_exists_in_db($username)) { + return dbInsert(array('username' => $username, 'user_id' => get_userid($username), 'level' => "0", 'can_modify_passwd' => 0, 'twofactor' => 0), 'users'); + } + else { + return false; + } } +function user_exists_in_db($username) { + $return = dbFetchCell('SELECT COUNT(*) FROM users WHERE username = ?', array($username), true); + return $return; +} function user_exists($username) { global $config, $ds; diff --git a/html/includes/forms/query-ripenccapi.inc.php b/html/includes/forms/query-ripenccapi.inc.php new file mode 100644 index 000000000..dd62474f5 --- /dev/null +++ b/html/includes/forms/query-ripenccapi.inc.php @@ -0,0 +1,30 @@ + + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +$status = 'error'; +$message = 'unknown error'; +$parameter = mres($_POST['parameter']); +if (isset($parameter)) { + $status = 'ok'; + $message = 'Queried'; + $output = get_ripe_api_whois_data_json($parameter); +} +else { + $status = 'error'; + $message = 'ERROR: Could not query'; +} +die(json_encode(array( + 'status' => $status, + 'message' => $message, + 'parameter' => $parameter, + 'output' => $output +))); diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index 3246cdc9a..3403b99b7 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -1178,6 +1178,9 @@ function dynamic_override_config($type, $name, $device) { if ($type == 'checkbox') { return ''; } + elseif ($type == 'text') { + return ''; + } }//end dynamic_override_config() function generate_dynamic_config_panel($title,$end_panel=true,$config_groups,$items=array(),$transport='') { @@ -1250,3 +1253,8 @@ function generate_dynamic_config_panel($title,$end_panel=true,$config_groups,$it return $output; }//end generate_dynamic_config_panel() +function get_ripe_api_whois_data_json($ripe_parameter) { + $ripe_whois_url = 'https://stat.ripe.net/data/whois/data.json?resource=' . $ripe_parameter; + return json_decode(file_get_contents($ripe_whois_url) , true); +}//end get_ripe_api_whois_data_json() + diff --git a/html/includes/print-map.inc.php b/html/includes/print-map.inc.php index eb41929fe..d512a7e21 100644 --- a/html/includes/print-map.inc.php +++ b/html/includes/print-map.inc.php @@ -218,7 +218,7 @@ echo $edges; var network = new vis.Network(container, data, options); network.on('click', function (properties) { if (properties.nodes > 0) { - window.location.href = "/device/device="+properties.nodes+"/tab=map/" + window.location.href = "device/device="+properties.nodes+"/tab=map/" } }); diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index 09d4b57b7..e61990ea0 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -74,6 +74,12 @@ if ($_SESSION['userlevel'] >= '10') {
  • Availability
  • Network
  • + +
  • Eventlog
  • diff --git a/html/includes/table/eventlog.inc.php b/html/includes/table/eventlog.inc.php index 797b71d77..62edbbefd 100644 --- a/html/includes/table/eventlog.inc.php +++ b/html/includes/table/eventlog.inc.php @@ -29,7 +29,7 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { $sql .= " AND (`D`.`hostname` LIKE '%$searchPhrase%' OR `E`.`datetime` LIKE '%$searchPhrase%' OR `E`.`message` LIKE '%$searchPhrase%' OR `E`.`type` LIKE '%$searchPhrase%')"; } -$count_sql = "SELECT COUNT(datetime) $sql"; +$count_sql = "SELECT COUNT(event_id) $sql"; $total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; diff --git a/html/js/librenms.js b/html/js/librenms.js index 576362bc6..3df1fc533 100644 --- a/html/js/librenms.js +++ b/html/js/librenms.js @@ -25,6 +25,32 @@ $(document).ready(function() { }); }); + // Device override for text inputs + $(document).on('blur', 'input[name="override_config_text"]', function(event) { + event.preventDefault(); + var $this = $(this); + var attrib = $this.data('attrib'); + var device_id = $this.data('device_id'); + var value = $this.val(); + $.ajax({ + type: 'POST', + url: 'ajax_form.php', + data: { type: 'override-config', device_id: device_id, attrib: attrib, state: value }, + dataType: 'json', + success: function(data) { + if (data.status == 'ok') { + toastr.success(data.message); + } + else { + toastr.error(data.message); + } + }, + error: function() { + toastr.error('Could not set this override'); + } + }); + }); + // Checkbox config ajax calls $("[name='global-config-check']").bootstrapSwitch('offColor','danger'); $('input[name="global-config-check"]').on('switchChange.bootstrapSwitch', function(event, state) { diff --git a/html/pages/device/edit/apps.inc.php b/html/pages/device/edit/apps.inc.php index c885666df..fc5e50eea 100644 --- a/html/pages/device/edit/apps.inc.php +++ b/html/pages/device/edit/apps.inc.php @@ -36,7 +36,7 @@ if ($_POST['device']) { foreach ($enabled as $app) { if (!in_array($app, $app_in_db)) { - $updated += dbInsert(array('device_id' => $device['device_id'], 'app_type' => $app), 'applications'); + $updated += dbInsert(array('device_id' => $device['device_id'], 'app_type' => $app, 'app_status' => '', 'app_instance' => ''), 'applications'); } } @@ -99,4 +99,4 @@ echo '
    '; echo ''; echo '
    '; -echo ''; \ No newline at end of file +echo ''; diff --git a/html/pages/device/edit/misc.inc.php b/html/pages/device/edit/misc.inc.php index a85689852..d1731ecdf 100644 --- a/html/pages/device/edit/misc.inc.php +++ b/html/pages/device/edit/misc.inc.php @@ -14,6 +14,12 @@ echo ' '.dynamic_override_config('checkbox','override_Oxidized_disable', $device).' +
    + +
    + '.dynamic_override_config('text','override_Unixagent_port', $device).' +
    +
    '; diff --git a/html/pages/ripenccapi.inc.php b/html/pages/ripenccapi.inc.php new file mode 100644 index 000000000..498467ae7 --- /dev/null +++ b/html/pages/ripenccapi.inc.php @@ -0,0 +1,51 @@ + + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ +$pagetitle[] = 'RIPE NCC - API Tools'; +?> +

    RIPE NCC API Tools

    +
    +

    Whois

    +
    +
    + + + + +
    +
    +
    +
    +
    + diff --git a/html/pages/settings/external.inc.php b/html/pages/settings/external.inc.php index 2960b2e25..5459ed67e 100644 --- a/html/pages/settings/external.inc.php +++ b/html/pages/settings/external.inc.php @@ -19,12 +19,28 @@ $oxidized_conf = array( ), ); +$unixagent_conf = array( + array('name' => 'unix-agent.port', + 'descr' => 'Default unix-agent port', + 'type' => 'text', + ), + array('name' => 'unix-agent.connection-timeout', + 'descr' => 'Connection timeout', + 'type' => 'text', + ), + array('name' => 'unix-agent.read-timeout', + 'descr' => 'Read timeout', + 'type' => 'text', + ), +); + echo '
    '; echo generate_dynamic_config_panel('Oxidized integration',true,$config_groups,$oxidized_conf); +echo generate_dynamic_config_panel('Unix-agent integration',true,$config_groups,$unixagent_conf); echo '
    diff --git a/includes/common.php b/includes/common.php index 167468d44..3d1f8a76e 100644 --- a/includes/common.php +++ b/includes/common.php @@ -802,7 +802,7 @@ function ceph_rrd($gtype) { * @return array Containing the lat and lng coords **/ function parse_location($location) { - preg_match('/(\[)([0-9\. ]+), ([0-9\. ]+)(\])/', $location, $tmp_loc); + preg_match('/(\[)([0-9\. ]+),[ ]*([0-9\. ]+)(\])/', $location, $tmp_loc); if (!empty($tmp_loc[2]) && !empty($tmp_loc[3])) { return array('lat' => $tmp_loc[2], 'lng' => $tmp_loc[3]); } diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 16873101c..16e3482e6 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -107,6 +107,17 @@ $config['os'][$os]['over'][1]['text'] = 'Processor Usage'; $config['os'][$os]['over'][2]['graph'] = 'device_ucd_memory'; $config['os'][$os]['over'][2]['text'] = 'Memory Usage'; +$os = 'infinity'; +$config['os'][$os]['text'] = 'LigoWave Infinity'; +$config['os'][$os]['type'] = 'wireless'; +$config['os'][$os]['nobulk'] = 1; +$config['os'][$os]['over'][0]['graph'] = 'device_bits'; +$config['os'][$os]['over'][0]['text'] = 'Device Traffic'; +$config['os'][$os]['over'][1]['graph'] = 'device_processor'; +$config['os'][$os]['over'][1]['text'] = 'Processor Usage'; +$config['os'][$os]['over'][2]['graph'] = 'device_mempool'; +$config['os'][$os]['over'][2]['text'] = 'Memory Usage'; + // Ubiquiti $os = 'unifi'; $config['os'][$os]['text'] = 'Ubiquiti UniFi'; diff --git a/includes/discovery/mempools/infinity.inc.php b/includes/discovery/mempools/infinity.inc.php new file mode 100644 index 000000000..a6734cb31 --- /dev/null +++ b/includes/discovery/mempools/infinity.inc.php @@ -0,0 +1,22 @@ + + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if ($device['os'] == 'infinity') { + echo 'INFINITY-MEMORY-POOL: '; + + $total = snmp_get($device, '.1.3.6.1.4.1.10002.1.1.1.1.1.0', '-OvQ'); + $free = snmp_get($device, '.1.3.6.1.4.1.10002.1.1.1.1.2.0', '-OvQ'); + + if (is_numeric($total) && is_numeric($free)) { + discover_mempool($valid_mempool, $device, 0, 'infinity', 'Memory', '1', null, null); + } +} diff --git a/includes/discovery/os/infinity.inc.php b/includes/discovery/os/infinity.inc.php new file mode 100644 index 000000000..517cdfaf3 --- /dev/null +++ b/includes/discovery/os/infinity.inc.php @@ -0,0 +1,17 @@ + + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if (!$os) { + if (preg_match('/^NFT 2N/', $sysDescr)) { + $os = 'infinity'; + } +} diff --git a/includes/discovery/processors/infinity.inc.php b/includes/discovery/processors/infinity.inc.php new file mode 100644 index 000000000..ee7779dd9 --- /dev/null +++ b/includes/discovery/processors/infinity.inc.php @@ -0,0 +1,24 @@ + + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if ($device['os'] == 'infinity') { + echo 'LigoWave Infinity: '; + + $descr = 'CPU'; + $usage = snmp_get($device, '.1.3.6.1.4.1.10002.1.1.1.4.2.1.3.2', '-Ovqn'); + + if (is_numeric($usage)) { + discover_processor($valid['processor'], $device, '.1.3.6.1.4.1.10002.1.1.1.4.2.1.3.2', '0', 'infinity', $descr, '1', $usage, null, null); + } +} + +unset($processors_array); diff --git a/includes/polling/mempools/infinity.inc.php b/includes/polling/mempools/infinity.inc.php new file mode 100644 index 000000000..94e3e9dd1 --- /dev/null +++ b/includes/polling/mempools/infinity.inc.php @@ -0,0 +1,17 @@ + + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +$total = snmp_get($device, '.1.3.6.1.4.1.10002.1.1.1.1.1.0', '-OvQ'); +$free = snmp_get($device, '.1.3.6.1.4.1.10002.1.1.1.1.2.0', '-OvQ'); +$mempool['total'] = $total * 1024; +$mempool['free'] = $free * 1024; +$mempool['used'] = ($mempool['total'] - $mempool['free']); diff --git a/includes/polling/os/infinity.inc.php b/includes/polling/os/infinity.inc.php new file mode 100644 index 000000000..ddebce091 --- /dev/null +++ b/includes/polling/os/infinity.inc.php @@ -0,0 +1,15 @@ + + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +$version = snmp_get($device, 'SNMPv2-MIB::sysDescr.0', '-Ovq'); +$version = explode(' ', $version)[2]; +$hardware = snmp_get($device, 'IEEE802dot11-MIB::dot11manufacturerProductName.5', '-Ovq'); diff --git a/includes/polling/unix-agent.inc.php b/includes/polling/unix-agent.inc.php index 18d30e58e..bdaf7df49 100644 --- a/includes/polling/unix-agent.inc.php +++ b/includes/polling/unix-agent.inc.php @@ -3,14 +3,22 @@ if ($device['os_group'] == 'unix') { echo $config['project_name'].' UNIX Agent: '; - // FIXME - this should be in config and overridable in database - $agent_port = '6556'; + $agent_port = get_dev_attrib($device,'override_Unixagent_port'); + if (empty($agent_port)) { + $agent_port = $config['unix-agent']['port']; + } + if (empty($config['unix-agent']['connection-timeout'])) { + $config['unix-agent']['connection-timeout'] = $config['unix-agent-connection-time-out']; + } + if (empty($config['unix-agent']['read-timeout'])) { + $config['unix-agent']['read-timeout'] = $config['unix-agent-read-time-out']; + } $agent_start = utime(); - $agent = fsockopen($device['hostname'], $agent_port, $errno, $errstr, $config['unix-agent-connection-time-out']); + $agent = fsockopen($device['hostname'], $agent_port, $errno, $errstr, $config['unix-agent']['connection-timeout']); // Set stream timeout (for timeouts during agent fetch - stream_set_timeout($agent, $config['unix-agent-read-time-out']); + stream_set_timeout($agent, $config['unix-agent']['read-timeout']); $agentinfo = stream_get_meta_data($agent); if (!$agent) { @@ -108,7 +116,7 @@ if ($device['os_group'] == 'unix') { if (in_array($key, array('apache', 'mysql', 'nginx', 'proxmox', 'ceph'))) { if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ?', array($device['device_id'], $key)) == '0') { echo "Found new application '$key'\n"; - dbInsert(array('device_id' => $device['device_id'], 'app_type' => $key), 'applications'); + dbInsert(array('device_id' => $device['device_id'], 'app_type' => $key, 'app_status' => '', 'app_instance' => ''), 'applications'); } } } @@ -120,7 +128,7 @@ if ($device['os_group'] == 'unix') { foreach ($agent_data['app']['memcached'] as $memcached_host => $memcached_data) { if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ? AND `app_instance` = ?', array($device['device_id'], 'memcached', $memcached_host)) == '0') { echo "Found new application 'Memcached' $memcached_host\n"; - dbInsert(array('device_id' => $device['device_id'], 'app_type' => 'memcached', 'app_instance' => $memcached_host), 'applications'); + dbInsert(array('device_id' => $device['device_id'], 'app_type' => 'memcached', 'app_status' => '', 'app_instance' => $memcached_host), 'applications'); } } } @@ -134,7 +142,7 @@ if ($device['os_group'] == 'unix') { $agent_data['app']['drbd'][$drbd_dev] = $drbd_data; if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ? AND `app_instance` = ?', array($device['device_id'], 'drbd', $drbd_dev)) == '0') { echo "Found new application 'DRBd' $drbd_dev\n"; - dbInsert(array('device_id' => $device['device_id'], 'app_type' => 'drbd', 'app_instance' => $drbd_dev), 'applications'); + dbInsert(array('device_id' => $device['device_id'], 'app_type' => 'drbd', 'app_status' => '', 'app_instance' => $drbd_dev), 'applications'); } } } diff --git a/sql-schema/076.sql b/sql-schema/076.sql new file mode 100644 index 000000000..80cb87c4a --- /dev/null +++ b/sql-schema/076.sql @@ -0,0 +1 @@ +INSERT INTO config (config_name,config_value,config_default,config_descr,config_group,config_group_order,config_sub_group,config_sub_group_order,config_hidden,config_disabled) values ('unix-agent.port','6556','6556','Default port for the Unix-agent (check_mk)','external',0,'unix-agent',0,'0','0'),('unix-agent.connection-timeout','10','10','Unix-agent connection timeout','external',0,'unix-agent',0,'0','0'),('unix-agent.read-timeout','10','10','Unix-agent read timeout','external',0,'unix-agent',0,'0','0');