#910 implement import of snmpwalk and more robust snapshot handling (#1086)

* initial work

* initial work

* initial work

* some fixes for time and Layer3 weird spec

* store again the snapshot after update for specific

* resolve the enums

* monkeypatch SNMP::translateObj to avoid hardware exception on macOS

* only save cache to db in the late phase worker

* no need to check for cache on transport, can just go ahead and try

* use database only for oidmap instead of netdisco-mibs

* rewrite device snapshot to gather loaded mib leafs only

* remove old walker code from snapshot worker

* allow snmp browser to work without snapshot

* only store snapshot leafs which the device responded on

* refactor to separate snapshot work from snmp transport work

* refactor to separate snapshot work from snmp transport work

* allow typeahead on MIB qualified leafs

* fixes for snmpwalk input after previous refactor

* add the extra stuff SNMP::Info device class uses into snapshot

* better width for snmp search box

* fix css for snmp options

* add spinner while snmp loading

* add spinner while snmp loading

* add spinner while snmp loading

* support SNMP::Info device class or named MIBs as extra on snapshot

* add final tidy and bug fix
This commit is contained in:
Oliver Gorwits
2023-08-10 22:27:02 +01:00
committed by GitHub
parent 7afae0b9b2
commit 9eb537a4c1
12 changed files with 803 additions and 507 deletions

View File

@@ -5,17 +5,31 @@
<div id="snmpnodecontainer" class="span8">
<form id="nd_snmp_search_form" class="form-inline col-md-4">
<span class="form-group">
<input id="nd_snmp_search_text" type="text" class="form-control nd_snmp_search_param" name="term" size="30" required placeholder="Search for label or OID">
<i id="nd_snmp_loading_spinner" class="icon-circle-blank icon-large"></i>
&nbsp;
<input id="nd_snmp_search_text" type="text"
class="form-control nd_snmp_search_param span5"
name="term" required placeholder="Search for label or OID">
<button type="submit" class="btn btn-default">Search</button>
&nbsp;
<label class="checkbox-inline"
rel="tooltip" data-placement="top" data-offset="5" data-title="Anchored to the beginning">
<input type="checkbox" id="nd_snmp_search_partial" name="partial" class="nd_snmp_search_param"> Partial </input>
rel="tooltip" data-placement="top" data-offset="5"
data-title="Anchored to the beginning">
<input type="checkbox" id="nd_snmp_search_partial"
name="partial" class="nd_snmp_search_param"> Partial </input>
</label>
<input type="checkbox" id="nd_snmp_search_deviceonly" name="deviceonly" class="nd_snmp_search_param" checked="checked"> Only this device </input>
<input type="hidden" id="nd_snmp_search_ip" name="ip" class="nd_snmp_search_param" value="[% device %]" />
&nbsp;
<input type="checkbox" id="nd_snmp_search_deviceonly"
name="deviceonly" class="nd_snmp_search_param"
checked="checked"> Only this device </input>
<input type="hidden" id="nd_snmp_search_ip"
name="ip" class="nd_snmp_search_param" value="[% device %]" />
</span>
</form>
<div id="node">
@@ -74,15 +88,23 @@
<script type="text/javascript">
$(function () {
var jstree_search_callback = function(str, node) {
var pattern = str.toLowerCase();
var mib = str.replace(/::.+/,'');
var leaf = str.replace(/.+::/,'');
var pattern = str.replace(/.+::/,'').toLowerCase();
var name = node.text.toLowerCase();
var oid = node.id.toLowerCase();
var oid = node.id.toLowerCase();
if (document.getElementById('nd_snmp_search_partial').checked) {
if ((name.indexOf(pattern) == 0) || (oid.indexOf(pattern) == 0)) {
return true;
}
}
else if (mib.length && leaf.length && mib != leaf) {
if ((mib == node.original.mib) && (leaf == node.original.leaf)) {
return true;
}
}
else {
if ((name.indexOf(pattern + ' ') == 0) || (oid == pattern)) {
return true;
@@ -110,10 +132,18 @@
'ajax' : {
'url' : '[% uri_base | none %]/ajax/data/snmp/nodesearch',
'beforeSend' : function(jqXHR, settings) {
$('#nd_snmp_loading_spinner').removeClass('icon-circle-blank icon-exclamation-sign text-success')
.addClass('icon-spinner text-warning icon-spin');
if (document.getElementById('nd_snmp_search_partial').checked) {
settings.url = settings.url + '&partial=on';
}
return true;
},
'error' : function() {
$('#nd_snmp_loading_spinner').removeClass('icon-spinner text-warning icon-spin')
.addClass('icon-exclamation-sign');
}
},
'search_callback' : jstree_search_callback
@@ -140,6 +170,9 @@
var path = $('#jstree').jstree().get_path(node[0], false, true);
var parent = path[path.length - 2];
document.getElementById( parent ).scrollIntoView();
$('#nd_snmp_loading_spinner').removeClass('icon-spinner text-warning icon-spin')
.addClass('icon-circle-blank text-success');
}
});
$("#nd_snmp_search_form").submit(function(e) {