diff options
author | Kristian Lyngstøl <kly@kly.no> | 2017-04-16 01:47:57 +0200 |
---|---|---|
committer | Kristian Lyngstøl <kly@kly.no> | 2017-04-16 01:47:57 +0200 |
commit | 0b99608227d53c9eebb01fd7f98d1618cbb7a2cf (patch) | |
tree | bc7a412d82ced33c10749289228df0cda942e632 | |
parent | bb862773d69bc5997bd1628a3f0505827e7cfe5c (diff) |
TG17 monster commit
-rwxr-xr-x | collectors/ping.pl | 4 | ||||
-rwxr-xr-x | collectors/snmpfetchng.pl | 20 | ||||
-rw-r--r-- | group_vars/front-test.yml | 2 | ||||
-rwxr-xr-x | include/config.pm | 20 | ||||
-rwxr-xr-x | include/nms.pm | 7 | ||||
-rw-r--r-- | include/nms/util.pm | 14 | ||||
-rwxr-xr-x | web/api/public/switch-state | 57 | ||||
-rwxr-xr-x | web/api/read/oplog | 3 | ||||
-rw-r--r-- | web/index.html | 14 | ||||
-rw-r--r-- | web/js/nms-info-box.js | 17 | ||||
-rw-r--r-- | web/js/nms-map-handlers.js | 114 | ||||
-rw-r--r-- | web/js/nms-map.js | 2 | ||||
-rw-r--r-- | web/js/nms-oplog.js | 5 | ||||
-rw-r--r-- | web/js/nms-search.js | 16 |
14 files changed, 235 insertions, 60 deletions
diff --git a/collectors/ping.pl b/collectors/ping.pl index 2d181b3..0ad0d1a 100755 --- a/collectors/ping.pl +++ b/collectors/ping.pl @@ -20,7 +20,7 @@ my $q = $dbh->prepare("SELECT switch,sysname,host(mgmt_v4_addr) as ip,host(mgmt_ my $lq = $dbh->prepare("SELECT linknet,addr1,addr2 FROM linknets WHERE addr1 is not null and addr2 is not null;"); my $last = time(); -my $target = 1.5; +my $target = 0.7; # Hack to avoid starting the collector before graphite is up. sleep(5); my $sock = IO::Socket::IP->new( @@ -38,7 +38,7 @@ while (1) { $last = time(); # ping loopbacks my $ping = Net::Oping->new; - $ping->timeout(0.9); + $ping->timeout(0.3); $q->execute; my %ip_to_switch = (); diff --git a/collectors/snmpfetchng.pl b/collectors/snmpfetchng.pl index df90138..b1ee68a 100755 --- a/collectors/snmpfetchng.pl +++ b/collectors/snmpfetchng.pl @@ -7,7 +7,7 @@ use POSIX; use SNMP; use Data::Dumper; use lib '/opt/gondul/include'; -use nms qw(convert_mac); +use nms qw(convert_mac convert_decimal); use IO::Socket::IP; SNMP::initMib(); @@ -109,7 +109,7 @@ sub inner_loop } } mylog( "Polling " . @switches . " switches: $poll_todo"); - SNMP::MainLoop(10); + SNMP::MainLoop(6); } sub callback{ @@ -121,24 +121,32 @@ sub callback{ my @nicids; my $total = 0; my $now_graphite = time(); + my %tree2; for my $ret (@top) { for my $var (@{$ret}) { for my $inner (@{$var}) { $total++; my ($tag,$type,$name,$iid, $val) = ( $inner->tag ,$inner->type , $inner->name, $inner->iid, $inner->val); - if ($tag eq "ifPhysAddress") { + if ($tag eq "ifPhysAddress" or $tag eq "jnxVirtualChassisMemberMacAddBase") { $val = convert_mac($val); } $tree{$iid}{$tag} = $val; if ($tag eq "ifIndex") { push @nicids, $iid; } + if ($tag =~ m/^jnxVirtualChassisMember/) { + $tree2{'vcm'}{$tag}{$iid} = $val; + } + if ($tag =~ m/^jnxVirtualChassisPort/ ) { + my ($member,$lol,$interface) = split(/\./,$iid,3); + my $decoded_if = convert_decimal($interface); + $tree2{'vcp'}{$tag}{$member}{$decoded_if} = $val; + } } } } - my %tree2; for my $nic (@nicids) { $tree2{'ports'}{$tree{$nic}{'ifName'}} = $tree{$nic}; for my $tmp_key (keys $tree{$nic}) { @@ -175,7 +183,9 @@ sub callback{ or die "Couldn't unlock switch"; $dbh->commit; if ($total > 0) { - mylog( "Polled $switch{'sysname'} in " . (time - $switch{'start'}) . "s."); + if ((time - $switch{'start'}) > 10) { + mylog( "Polled $switch{'sysname'} in " . (time - $switch{'start'}) . "s."); + } } else { mylog( "Polled $switch{'sysname'} in " . (time - $switch{'start'}) . "s - no data. Timeout?"); } diff --git a/group_vars/front-test.yml b/group_vars/front-test.yml index 51d4672..6682d96 100644 --- a/group_vars/front-test.yml +++ b/group_vars/front-test.yml @@ -1,3 +1,3 @@ --- front_ports: [] -varnish_ports: ["80:80"] +varnish_ports: ["127.0.0.1:8080:80"] diff --git a/include/config.pm b/include/config.pm index 2a65c94..ec4a634 100755 --- a/include/config.pm +++ b/include/config.pm @@ -50,7 +50,25 @@ our @snmp_objects = [ ['jnxOperatingTemp'], ['jnxOperatingCPU'], ['jnxOperatingDescr'], - ['jnxBoxSerialNo'] + ['jnxBoxSerialNo'], + ['jnxVirtualChassisFpcId'], + ['jnxVirtualChassisPortName'], + ['jnxVirtualChassisPortAdminStatus'], + ['jnxVirtualChassisPortOperStatus'], + ['jnxVirtualChassisPortInPkts'], + ['jnxVirtualChassisPortOutPkts'], + ['jnxVirtualChassisPortInOctets'], + ['jnxVirtualChassisPortOutOctets'], + ['jnxVirtualChassisPortInMcasts'], + ['jnxVirtualChassisPortOutMcasts'], + ['jnxVirtualChassisPortInPkts1secRate'], + ['jnxVirtualChassisPortOutPkts1secRate'], + ['jnxVirtualChassisPortInOctets1secRate'], + ['jnxVirtualChassisPortOutOctets1secRate'], + ['jnxVirtualChassisPortCarrierTrans'], + ['jnxVirtualChassisPortInCRCAlignErrors'], + ['jnxVirtualChassisPortUndersizePkts'], + ['jnxVirtualChassisPortCollisions'] ]; BEGIN { diff --git a/include/nms.pm b/include/nms.pm index eff61c3..3133042 100755 --- a/include/nms.pm +++ b/include/nms.pm @@ -8,7 +8,7 @@ use JSON; package nms; use base 'Exporter'; -our @EXPORT = qw(db_connect convert_mac); +our @EXPORT = qw(db_connect convert_mac convert_decimal); BEGIN { require "config.pm"; @@ -54,6 +54,11 @@ sub convert_addr { } } +# I am not a perl programmer +sub convert_decimal { + return join("",(map { sprintf "%c", $_ } split(/\./,shift))); +} + # Convert raw binary SNMP data to list of bits. sub convert_bytelist { return split //, unpack("B*", shift); diff --git a/include/nms/util.pm b/include/nms/util.pm index 1cc34e9..511da33 100644 --- a/include/nms/util.pm +++ b/include/nms/util.pm @@ -132,10 +132,10 @@ sub guess_placement_tg { $x = int(292 + (($e-1)/2) * 31.1); $y = undef; - $x += 14 if ($e >= 13); - $x += 14 if ($e >= 25); - $x += 14 if ($e >= 41); - $x += 14 if ($e >= 59); + $x += 14 if ($e >= 21); + $x += 14 if ($e >= 37); + $x += 14 if ($e >= 55); + $x += 14 if ($e >= 69); if ($s > 2) { $y = 405 - 120 * ($s-2); @@ -151,9 +151,9 @@ sub guess_placement_tg { $y += 20 if $name eq "e3-4"; $y += 15 if $name eq "e5-4"; $yy -= 25 if $name eq "e7-1"; - $y += 10 if $name eq "e5-2"; - $yy -= 25 if $name eq "e5-2"; - $y += 20 if ($e >= 81 and $s == 2); + $yy -= 25 if $name eq "e5-1"; + $yy -= 25 if $name eq "e3-1"; + $y += 20 if ($e >= 79 and $s == 2); $yy -= 20 if ($e >= 79 and $s == 1); $yy -= 30 if ($e >= 81 and $s == 1); diff --git a/web/api/public/switch-state b/web/api/public/switch-state index 36dfeaf..77350c7 100755 --- a/web/api/public/switch-state +++ b/web/api/public/switch-state @@ -25,6 +25,8 @@ while ( my $ref = $q->fetchrow_hashref() ) { my %data = %{JSON::XS::decode_json($ref->{'data'})}; + $json{'switches'}{$sysname}{'clients'}{'live'} = 0; + $json{'then'}{$sysname}{'clients'}{'live'} = 0; for my $porti (keys %{$data{'ports'}}) { if (defined($port) and $port ne "" and $port ne $porti) { next; @@ -41,21 +43,25 @@ while ( my $ref = $q->fetchrow_hashref() ) { } if ($data{'ports'}{$porti}{'ifType'} ne "propVirtual" and $data{'ports'}{$porti}{'ifAlias'} =~ m/LAG member/i) { - $json{'switches'}{$sysname}{'uplinks'}{'ifHCInOctets'} += $port{'ifHCInOctets'}; - $json{'switches'}{$sysname}{'uplinks'}{'ifHCOutOctets'} += $port{'ifHCOutOctets'}; - if ($port{'ifOperStatus'} eq "up") { - $json{'switches'}{$sysname}{'uplinks'}{'live'} += 1; + if ($port{'ifAdminStatus'} eq "up") { + $json{'switches'}{$sysname}{'uplinks'}{'ifHCInOctets'} += $port{'ifHCInOctets'}; + $json{'switches'}{$sysname}{'uplinks'}{'ifHCOutOctets'} += $port{'ifHCOutOctets'}; + if ($port{'ifOperStatus'} eq "up") { + $json{'switches'}{$sysname}{'uplinks'}{'live'} += 1; + } + $json{'switches'}{$sysname}{'uplinks'}{'total'} += 1; } - $json{'switches'}{$sysname}{'uplinks'}{'total'} += 1; } if ($data{'ports'}{$porti}{'ifType'} ne "propVirtual" and $data{'ports'}{$porti}{'ifAlias'} =~ m/Clients/i) { - $json{'switches'}{$sysname}{'clients'}{'ifHCInOctets'} += $port{'ifHCInOctets'}; - $json{'switches'}{$sysname}{'clients'}{'ifHCOutOctets'} += $port{'ifHCOutOctets'}; - if ($port{'ifOperStatus'} eq "up") { - $json{'switches'}{$sysname}{'clients'}{'live'} += 1; + if ($port{'ifAdminStatus'} eq "up") { + $json{'switches'}{$sysname}{'clients'}{'ifHCInOctets'} += $port{'ifHCInOctets'}; + $json{'switches'}{$sysname}{'clients'}{'ifHCOutOctets'} += $port{'ifHCOutOctets'}; + if ($port{'ifOperStatus'} eq "up") { + $json{'switches'}{$sysname}{'clients'}{'live'} += 1; + } + $json{'switches'}{$sysname}{'clients'}{'total'} += 1; } - $json{'switches'}{$sysname}{'clients'}{'total'} += 1; } $json{'switches'}{$sysname}{ifs}{$smallport}{'ifHCInOctets'} += $port{'ifHCInOctets'} || 0; $json{'switches'}{$sysname}{ifs}{$smallport}{'ifHCOutOctets'} += $port{'ifHCOutOctets'} || 0; @@ -67,6 +73,9 @@ while ( my $ref = $q->fetchrow_hashref() ) { } $json{'switches'}{$sysname}{totals}{'total'} += 1; } + + $json{'switches'}{$sysname}{vcp}{jnxVirtualChassisPortInOctets} = $data{'vcp'}{'jnxVirtualChassisPortInOctets'}; + $json{'switches'}{$sysname}{vcp}{jnxVirtualChassisPortOutOctets} = $data{'vcp'}{'jnxVirtualChassisPortOutOctets'}; $json{'switches'}{$sysname}{'temp'} = $data{'misc'}{'jnxOperatingTemp'}{'7.1.0.0'} || $data{'misc'}{'ciscoEnvMonTemperatureStatusValue'}{'1011'} || $data{'misc'}{'ciscoEnvMonTemperatureStatusValue'}{'1008'}; $json{'switches'}{$sysname}{'time'} = $ref->{'time'}; } @@ -94,28 +103,32 @@ while ( my $ref = $q2->fetchrow_hashref() ) { if ($porti =~ m/\.0$/) { next; } - if ($data{'ports'}{$porti}{'ifAlias'} =~ m/client/) { + if ($data{'ports'}{$porti}{'ifAlias'} =~ m/client/i) { $smallport =~ s/[0-9-].*$//; } else { $json{'then'}{$sysname}{ifs}{$smallport}{'ifAlias'} = $port{'ifAlias'}; } if ($data{'ports'}{$porti}{'ifType'} ne "propVirtual" and $data{'ports'}{$porti}{'ifAlias'} =~ m/LAG member/i) { - $json{'then'}{$sysname}{'uplinks'}{'ifHCInOctets'} += $port{'ifHCInOctets'}; - $json{'then'}{$sysname}{'uplinks'}{'ifHCOutOctets'} += $port{'ifHCOutOctets'}; - if ($port{'ifOperStatus'} eq "up") { - $json{'then'}{$sysname}{'uplinks'}{'live'} += 1; + if ($port{'ifAdminStatus'} eq "up") { + $json{'then'}{$sysname}{'uplinks'}{'ifHCInOctets'} += $port{'ifHCInOctets'}; + $json{'then'}{$sysname}{'uplinks'}{'ifHCOutOctets'} += $port{'ifHCOutOctets'}; + if ($port{'ifOperStatus'} eq "up") { + $json{'then'}{$sysname}{'uplinks'}{'live'} += 1; + } + $json{'then'}{$sysname}{'uplinks'}{'total'} += 1; } - $json{'then'}{$sysname}{'uplinks'}{'total'} += 1; } if ($data{'ports'}{$porti}{'ifType'} ne "propVirtual" and $data{'ports'}{$porti}{'ifAlias'} =~ m/Clients/i) { - $json{'then'}{$sysname}{'clients'}{'ifHCInOctets'} += $port{'ifHCInOctets'}; - $json{'then'}{$sysname}{'clients'}{'ifHCOutOctets'} += $port{'ifHCOutOctets'}; - if ($port{'ifOperStatus'} eq "up") { - $json{'then'}{$sysname}{'clients'}{'live'} += 1; + if ($port{'ifAdminStatus'} eq "up") { + $json{'then'}{$sysname}{'clients'}{'ifHCInOctets'} += $port{'ifHCInOctets'}; + $json{'then'}{$sysname}{'clients'}{'ifHCOutOctets'} += $port{'ifHCOutOctets'}; + if ($port{'ifOperStatus'} eq "up") { + $json{'then'}{$sysname}{'clients'}{'live'} += 1; + } + $json{'then'}{$sysname}{'clients'}{'total'} += 1; } - $json{'then'}{$sysname}{'clients'}{'total'} += 1; } $json{'then'}{$sysname}{ifs}{$smallport}{'ifHCInOctets'} += $port{'ifHCInOctets'} || 0; @@ -128,6 +141,8 @@ while ( my $ref = $q2->fetchrow_hashref() ) { } $json{'then'}{$sysname}{totals}{'total'} += 1; } + $json{'then'}{$sysname}{vcp}{jnxVirtualChassisPortInOctets} = $data{'vcp'}{'jnxVirtualChassisPortInOctets'}; + $json{'then'}{$sysname}{vcp}{jnxVirtualChassisPortOutOctets} = $data{'vcp'}{'jnxVirtualChassisPortOutOctets'}; $json{'then'}{$sysname}{'temp'} = $data{'misc'}{'jnxOperatingTemp'}{'7.1.0.0'} || $data{'misc'}{'ciscoEnvMonTemperatureStatusValue'}{'1011'} || $data{'misc'}{'ciscoEnvMonTemperatureStatusValue'}{'1008'}; $json{'then'}{$sysname}{'time'} = $ref->{'time'}; } diff --git a/web/api/read/oplog b/web/api/read/oplog index 92511bb..15c6177 100755 --- a/web/api/read/oplog +++ b/web/api/read/oplog @@ -16,6 +16,9 @@ while (my $ref = $query->fetchrow_hashref()) { $meh{'id'} = $ref->{'id'}; $meh{'systems'} = $ref->{'systems'}; $meh{'timestamp'} = $ref->{'timestamp'}; + $meh{'timestamp'} =~ s/ /T/; + $meh{'timestamp'} =~ s/\+00$/Z/; + push @{$nms::web::json{'oplog'}},\%meh; } diff --git a/web/index.html b/web/index.html index 7ea26e3..85cac15 100644 --- a/web/index.html +++ b/web/index.html @@ -37,12 +37,12 @@ <div id="navbar" class="navbar-collapse collapse"> <p class="navbar-text"><span class="glyphicon glyphicon-heart" id="heartbeat" aria-hidden="true"></span></p> <ul class="nav navbar-nav"> - <li id='map-link' class="active"><a href="#" onclick="nmsUi.setActive('map');">Map<span class="sr-only">(current)</span></a></li> - <li id='admin-link' class="gondul-is-private"><a href="#" onclick="nmsUi.setActive('admin');nmsAdmin.updateConfigPane();">Admin</a></li> - <li id='template-link' class="gondul-is-private"><a href="#" onclick="nmsUi.setActive('template');">Templates</a></li> - <li id='oplog-link' class="gondul-is-private"><a href="#" onclick="nmsUi.setActive('oplog');">Oplog</a></li> + <li id='map-link' class="active"><a href="#" onclick="nmsUi.setActive('map');" title="Map">M<span class="sr-only">(current)</span></a></li> + <li id='admin-link' class="gondul-is-private"><a href="#" onclick="nmsUi.setActive('admin');nmsAdmin.updateConfigPane();" title="Admin">A</a></li> + <li id='template-link' class="gondul-is-private"><a href="#" onclick="nmsUi.setActive('template');" title="Template">T</a></li> + <li id='oplog-link' class="gondul-is-private"><a href="#" onclick="nmsUi.setActive('oplog');" title="Oplog">O</a></li> <li class="dropdown"> - <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Menu + <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false" title="Menu">M <span class="caret"></span> </a> <ul class="dropdown-menu" role="menu"> @@ -82,7 +82,7 @@ </li> <div class="navbar-form navbar-left"> <div class="input-group input-group-sm"> - <input id="searchbox" type="text" class="form-control" placeholder="Filter" oninput="nmsSearch.search()" /> + <input id="searchbox" type="text" class="form-control" size="8" placeholder="Filter" oninput="nmsSearch.search()" /> <span class="input-group-btn"> <button id="searchbox-x" class="btn btn-default" type="button" onclick="nmsSearch.reset();">X</button> <button id="searchbox-help" class="btn btn-default" type="button" onclick="nmsInfoBox.showWindow('searchHelp');">?</button> @@ -317,7 +317,7 @@ </div> </div> - <div style="display:none;"><img id="source" src="img/tg15-salkart-clean-big.png" ></div> + <div style="display:none;"><img id="source" src="img/tg17-clean.png" ></div> </div> </div><!--/.fluid-container--> <script src="js/jquery.min.js" type="text/javascript"></script> diff --git a/web/js/nms-info-box.js b/web/js/nms-info-box.js index 2cc6fc4..b902a69 100644 --- a/web/js/nms-info-box.js +++ b/web/js/nms-info-box.js @@ -832,10 +832,23 @@ var inventoryListingPanel = function() { value = nmsData.snmp.snmp[sw]["misc"]["sysDescr"][0]; break; case 'jnxBoxSerialNo': + if(testTree(nmsData,["snmp","snmp",sw,"misc","entPhysicalSerialNum"])) { + for (var x in nmsData.snmp.snmp[sw]["misc"]["entPhysicalSerialNum"]) { + value = "misc" + x + ":" + nmsData.snmp.snmp[sw]["misc"]["entPhysicalSerialNum"][x]; + resultArray.push([sw, value]); + } + } + if (testTree(nmsData,["snmp","snmp",sw,"misc","jnxVirtualChassisMemberSerialnumber"])) { + for (var x in nmsData.snmp.snmp[sw]["misc"]["jnxVirtualChassisMemberSerialnumber"]) { + value = "member " + x + ":" + nmsData.snmp.snmp[sw]["misc"]["jnxVirtualChassisMemberSerialnumber"][x]; + resultArray.push([sw, value]); + } + } value = nmsData.snmp.snmp[sw]["misc"]["jnxBoxSerialNo"][0]; break; } - } catch (e) {} + } catch (e) {console.log("sw: " + sw); console.log(e);} + resultArray.push([sw, value]); } @@ -1012,7 +1025,7 @@ var switchCommentsPanel = function () { var tmp = (date.getYear() + 1900) + "-" + (month < 10 ? "0": "") + month + "-" + (day < 10 ? "0" : "") + day + " " + date.toTimeString().replace(/:\d\d .*$/,""); td1.textContent = tmp; td1.classList.add("left"); - td2.textContent = "[" + logs[v]['username'] + "] " + logs[v]['log']; + td2.textContent = logs[v]['systems'] + "[" + logs[v]['username'] + "] " + logs[v]['log']; } domObj.appendChild(table); this._render(domObj); diff --git a/web/js/nms-map-handlers.js b/web/js/nms-map-handlers.js index 2214e2d..03f5c9e 100644 --- a/web/js/nms-map-handlers.js +++ b/web/js/nms-map-handlers.js @@ -68,6 +68,7 @@ var handler_snmp = { var handler_cpu = { init:cpuInit, + getInfo:cpuInfo, tag:"cpu", name:"CPU utilization" }; @@ -84,6 +85,11 @@ var handler_mgmt = { tag:"mgmt", name:"Management info" }; +var handler_snmpup = { + getInfo:snmpUpInfo, + tag:"snmpup", + name:"SNMP Uplink state" +}; var handlerInfo = function(tag,desc) { /* @@ -126,7 +132,8 @@ var handlers = [ handler_traffic_tot, handler_dhcp, handler_snmp, - handler_cpu + handler_cpu, + handler_snmpup ]; function uplinkInfo(sw) @@ -159,13 +166,16 @@ function uplinkInfo(sw) } if (u == known_t) { - ret.score = 0 - ret.why = "All uplinks up"; + ret.score = 0; + ret.why = "All uplinks up"; } else if (u == 1) { ret.score = 800; ret.why = "Only 1 of " + known_t + " uplinks alive"; - } else { - ret.score = 650; + } else if (u < known_t) { + ret.score = 450; + ret.why = u + " of " + known_t + " uplinks alive"; + } else if (u > known_t) { + ret.score = 350; ret.why = u + " of " + known_t + " uplinks alive"; } } @@ -453,6 +463,31 @@ function pingInfo(sw) ret.why = "No ping replies"; ret.score = 999; } + + if (testTree(nmsData,['smanagement','switches',sw])) { + try { + var distro = nmsData['smanagement']['switches'][sw]['distro_name']; + var phy = nmsData['smanagement']['switches'][sw]['distro_phy_port']; + if (!(distro == "" || phy == "" || distro == undefined || phy == undefined)) { + if (testTree(nmsData,['snmp','snmp',distro, 'ports',phy,'ifOperStatus'])) { + var x = nmsData['snmp']['snmp'][distro]['ports'][phy]['ifOperStatus']; + var ping = parseFloat(nmsData["ping"]["switches"][sw]["latency4"]); + var ping6 = parseFloat(nmsData["ping"]["switches"][sw]["latency6"]); + if (x == "up") { + ret.data[3] = {}; + ret.data[3].description = "Distro-port"; + ret.data[3].value = "Distro port is live"; + if (isNaN(ping) && isNaN(ping6)) { + ret.score = 850; + ret.why = "Distro port is alive, but no IPv4/IPv6 ping. ROLLBACK!"; + } + } + } + } + } catch(e) { + console.log("lol"); + } + } return ret; } @@ -500,19 +535,19 @@ function dhcpUpdater() function dhcpInfo(sw) { var ret = new handlerInfo("dhcp","DHCP state"); ret.why = "No DHCP data"; - ret.data[0].description = "DHCP age (seconds)"; + ret.data[0].description = "DHCP age"; if (testTree(nmsData,['dhcp','dhcp',sw])) { var now = nmsData.dhcp.time; var then = nmsData.dhcp.dhcp[sw]; var diff = now - then; - var divider = 4; + var divider = 6; if(tagged(sw,'slowdhcp')) { - divider = 10; + divider = 12; } - ret.data[0].value = diff; + ret.data[0].value = secondsToTime(diff); ret.why = "DHCP freshness"; - ret.score = diff/divider> 500 ? 500 : parseInt(diff/divider); + ret.score = diff/divider> 350 ? 350 : parseInt(diff/divider); } else { ret.data[0].value = "No DHCP data"; if (testTree(nmsData,['smanagement','switches',sw])) { @@ -522,7 +557,7 @@ function dhcpInfo(sw) { ret.score = 0; ret.why = "No subnet registered"; } else { - ret.score = 500; + ret.score = 350; ret.why = "No DHCP data"; } } else { @@ -658,6 +693,7 @@ function snmpInfo(sw) { return ret; } + function snmpInit() { nmsData.addHandler("snmp", "mapHandler", snmpUpdater); @@ -669,6 +705,59 @@ function snmpInit() { snmpUpdater(); } +function snmpUpInfo(sw) { + var ret = new handlerInfo("snmpup","SNMP uplink data"); + ret.why = "No SNMP data"; + ret.score = 0; + + if (testTree(nmsData,['snmp','snmp',sw, 'ports'])) { + var total_up = 0; + var seen_up = 0; + for (var port in nmsData.snmp.snmp[sw].ports) { + var x = nmsData.snmp.snmp[sw].ports[port]; + if (x["ifAlias"].match(/Uplink/i) && x["ifOperStatus"] == "up") { + total_up += parseInt(x["ifHighSpeed"]); + } + if (x["ifAlias"].match(/LAG Member/i) && x["ifOperStatus"] == "up") { + seen_up += parseInt(x["ifHighSpeed"]); + } + } + ret.data[0].value = "LAG member speed and total speed is " + seen_up; + if (total_up != seen_up) { + ret.score = 500; + ret.why = "LAG member (ge/xt/etc) speed is " + seen_up + " but logical (ae) is " + total_up; + ret.data[0].value = ret.why; + } + } + return ret; +} + +function cpuInfo(sw) { + var ret = new handlerInfo("cpu","CPU utilization"); + ret.why = "No CPU info"; + ret.score = 0; + + if (testTree(nmsData,['snmp','snmp',sw, 'misc','jnxOperatingCPU'])) { + var cpu = 0; + for (var u in nmsData.snmp.snmp[sw].misc.jnxOperatingCPU) { + var local = nmsData.snmp.snmp[sw].misc['jnxOperatingCPU'][u]; + cpu = Math.max(nmsData.snmp.snmp[sw].misc.jnxOperatingCPU[u],cpu); + } + if (cpu < 30) { + ret.score = 0; + } else if (cpu < 50) { + ret.score = 100; + } else if (cpu < 95) { + ret.score = cpu * 2; + } else { + ret.score = cpu * 4; + } + ret.why = "CPU utilization: " + cpu + "%"; + ret.data[0].value = cpu + "%"; + } + return ret; +} + function cpuUpdater() { for (var sw in nmsData.switches.switches) { try { @@ -714,6 +803,9 @@ function mgmtInfo(sw) { }, { value: mg.subnet6 || "N/A", description: "Subnet (v6)" + }, { + value: mg.distro_name || "N/A", + description: "Distro" }]; if ((mg.mgmt_v4_addr == undefined || mg.mgmt_v4_addr == "") && (mg.mgmt_v6_addr == undefined || mg.mgmt_v6_addr == "")) { ret.why = "No IPv4 or IPv6 mamagement IP"; diff --git a/web/js/nms-map.js b/web/js/nms-map.js index 5669acb..1ebcf92 100644 --- a/web/js/nms-map.js +++ b/web/js/nms-map.js @@ -38,7 +38,7 @@ var nmsMap = nmsMap || { textMargin: 4, xMargin: 10, yMargin: 20, - fontSize: 15, + fontSize: 14, fontFace: "sans-serif" }, scale: 1, diff --git a/web/js/nms-oplog.js b/web/js/nms-oplog.js index c418e33..7ac11c4 100644 --- a/web/js/nms-oplog.js +++ b/web/js/nms-oplog.js @@ -59,7 +59,7 @@ nmsOplog.commit = function() { } nmsOplog.updateComments = function() { - nmsOplog._updateComments(3,"-mini","time",100); + nmsOplog._updateComments(10,"-mini","time",100); nmsOplog._updateComments(0,"","timestamp"); } @@ -89,6 +89,9 @@ nmsOplog._updateComments = function(limit,prefix,timefield,cutoff) { table.classList.add("table-condensed"); var i = 0; for (var v in nmsData['oplog']['oplog']) { + if (cutoff && nmsData.oplog.oplog[v]['username'] == "system") { + continue; + } tr = table.insertRow(-1); td1 = tr.insertCell(0); td2 = tr.insertCell(1); diff --git a/web/js/nms-search.js b/web/js/nms-search.js index 1167b51..f435c81 100644 --- a/web/js/nms-search.js +++ b/web/js/nms-search.js @@ -96,6 +96,22 @@ nmsSearch.searchTest = function(id, sw) { } } } catch (e) {} + try { + for (var x in nmsData.snmp.snmp[sw].misc.jnxBoxSerialNo) { + if (nmsData.snmp.snmp[sw].misc.jnxBoxSerialNo[x] == null) { + continue; + } + if (nmsData.snmp.snmp[sw].misc.jnxBoxSerialNo[x] == undefined) { + continue; + } + if (nmsData.snmp.snmp[sw].misc.jnxBoxSerialNo[x] == "") { + continue; + } + if (re.test(nmsData.snmp.snmp[sw].misc.jnxBoxSerialNo[x])) { + return true; + } + } + } catch (e) {} if (re.test(nmsData.snmp.snmp[sw].misc.sysDescr[0])) { return true; } |