diff options
author | Nicolai Tellefsen <niccofyren@gmail.com> | 2016-03-21 20:33:44 +0100 |
---|---|---|
committer | Nicolai Tellefsen <niccofyren@gmail.com> | 2016-03-21 20:33:44 +0100 |
commit | 5ba657e0bca0e4970b08583f6dfc94bfae34741c (patch) | |
tree | 44ed77deecd40ca984aae4bfa1bb949cb87bf7a0 /web/nms.gathering.org | |
parent | d528cad67897dd2c3b98ec15a82868ac2764e2c7 (diff) | |
parent | 727e4ab31aa6d1a754711d4cd29dbcefae2e952a (diff) |
Merge branch 'master' of https://github.com/tech-server/tgmanage
Diffstat (limited to 'web/nms.gathering.org')
-rwxr-xr-x | web/nms.gathering.org/api/private/switch-add | 4 | ||||
-rwxr-xr-x | web/nms.gathering.org/api/private/switch-update | 4 | ||||
-rwxr-xr-x | web/nms.gathering.org/api/public/switch-state | 13 | ||||
-rwxr-xr-x | web/nms.gathering.org/api/public/switches | 3 | ||||
-rw-r--r-- | web/nms.gathering.org/js/nms-info-box.js | 52 |
5 files changed, 41 insertions, 35 deletions
diff --git a/web/nms.gathering.org/api/private/switch-add b/web/nms.gathering.org/api/private/switch-add index 70d6212..48f62fc 100755 --- a/web/nms.gathering.org/api/private/switch-add +++ b/web/nms.gathering.org/api/private/switch-add @@ -22,7 +22,7 @@ my @dups; my $sth = $nms::web::dbh->prepare("SELECT sysname FROM switches WHERE sysname=?"); -my @fields = ('ip', 'sysname', 'switchtype', 'last_updated', 'locked', 'poll_frequency', 'community', 'lldp_chassis_id', 'secondary_ip', 'subnet4', 'subnet6', 'placement', 'distro', 'secondary_ip'); +my @fields = ('ip', 'sysname', 'last_updated', 'locked', 'poll_frequency', 'community', 'lldp_chassis_id', 'secondary_ip', 'subnet4', 'subnet6', 'placement', 'distro', 'secondary_ip'); sub convertplace { @@ -81,7 +81,7 @@ foreach my $tmp2 (@tmp) { } keys %switch; - $nms::web::dbh->do("INSERT INTO SWITCHES (ip, sysname, switchtype, last_updated, locked, poll_frequency, community, lldp_chassis_id, secondary_ip, placement) VALUES ($template{'ip'}, $template{'sysname'}, $template{'switchtype'}, $template{'last_updated'}, $template{'locked'}, $template{'poll_frequency'}, $template{'community'}, $template{'lldp_chassis_id'}, $template{'secondary_ip'}, $template{'placement'});"); + $nms::web::dbh->do("INSERT INTO SWITCHES (ip, sysname, last_updated, locked, poll_frequency, community, lldp_chassis_id, secondary_ip, placement,subnet4,subnet6,distro) VALUES ($template{'ip'}, $template{'sysname'}, $template{'last_updated'}, $template{'locked'}, $template{'poll_frequency'}, $template{'community'}, $template{'lldp_chassis_id'}, $template{'secondary_ip'}, $template{'placement'},$template{'subnet4'},$template{'subnet6'},$template{'distro'});"); push @added, $switch{'sysname'}; } } diff --git a/web/nms.gathering.org/api/private/switch-update b/web/nms.gathering.org/api/private/switch-update index 3d7b119..6507d2b 100755 --- a/web/nms.gathering.org/api/private/switch-update +++ b/web/nms.gathering.org/api/private/switch-update @@ -22,7 +22,7 @@ my @dups; my $sth = $nms::web::dbh->prepare("SELECT sysname FROM switches WHERE sysname=?"); -my @fields = ('ip', 'sysname', 'switchtype', 'last_updated', 'locked', 'poll_frequency', 'community', 'lldp_chassis_id', 'secondary_ip', 'subnet4', 'subnet6', 'placement', 'distro', 'secondary_ip'); +my @fields = ('ip', 'sysname', 'last_updated', 'locked', 'poll_frequency', 'community', 'lldp_chassis_id', 'secondary_ip', 'subnet4', 'subnet6', 'placement', 'distro', 'secondary_ip'); sub convertplace { @@ -81,7 +81,7 @@ foreach my $tmp2 (@tmp) { } keys %switch; - $nms::web::dbh->do("INSERT INTO SWITCHES (ip, sysname, switchtype, last_updated, locked, poll_frequency, community, lldp_chassis_id, secondary_ip, placement) VALUES ($template{'ip'}, $template{'sysname'}, $template{'switchtype'}, $template{'last_updated'}, $template{'locked'}, $template{'poll_frequency'}, $template{'community'}, $template{'lldp_chassis_id'}, $template{'secondary_ip'}, $template{'placement'});"); + $nms::web::dbh->do("INSERT INTO SWITCHES (ip, sysname, last_updated, locked, poll_frequency, community, lldp_chassis_id, secondary_ip, placement,subnet4,subnet6,distro) VALUES ($template{'ip'}, $template{'sysname'}, $template{'last_updated'}, $template{'locked'}, $template{'poll_frequency'}, $template{'community'}, $template{'lldp_chassis_id'}, $template{'secondary_ip'}, $template{'placement'},$template{'subnet4'},$template{'subnet6'},$template{'distro'});"); push @added, $switch{'sysname'}; } else { if (defined($switch{'placement'})) { diff --git a/web/nms.gathering.org/api/public/switch-state b/web/nms.gathering.org/api/public/switch-state index 62d0078..6f7573c 100755 --- a/web/nms.gathering.org/api/public/switch-state +++ b/web/nms.gathering.org/api/public/switch-state @@ -20,7 +20,7 @@ while ( my $ref = $q->fetchrow_hashref() ) { my %port = %{$data{'ports'}{$porti}}; my $smallport = $porti; $smallport =~ s/[0-9-].*$//; - if ($porti =~ /ge-0\/0\/4[4-7]/ or $porti eq 'eth0') { + if ($porti =~ /ge-0\/0\/4[4-7]/) { $json{'switches'}{$sysname}{'uplinks'}{'ifHCInOctets'} += $port{'ifHCInOctets'}; $json{'switches'}{$sysname}{'uplinks'}{'ifHCOutOctets'} += $port{'ifHCOutOctets'}; if ($port{'ifOperStatus'} eq "up") { @@ -29,12 +29,15 @@ while ( my $ref = $q->fetchrow_hashref() ) { $json{'switches'}{$sysname}{'uplinks'}{'total'} += 1; } - $json{'switches'}{$sysname}{$smallport}{'ifHCInOctets'} += $port{'ifHCInOctets'}; - $json{'switches'}{$sysname}{$smallport}{'ifHCOutOctets'} += $port{'ifHCOutOctets'}; + $json{'switches'}{$sysname}{ifs}{$smallport}{'ifHCInOctets'} += $port{'ifHCInOctets'}; + $json{'switches'}{$sysname}{ifs}{$smallport}{'ifHCOutOctets'} += $port{'ifHCOutOctets'}; + $json{'switches'}{$sysname}{totals}{'ifHCInOctets'} += $port{'ifHCInOctets'}; + $json{'switches'}{$sysname}{totals}{'ifHCOutOctets'} += $port{'ifHCOutOctets'}; if ($port{'ifOperStatus'} eq "up") { - $json{'switches'}{$sysname}{$smallport}{'live'} += 1; + $json{'switches'}{$sysname}{ifs}{$smallport}{'live'} += 1; + $json{'switches'}{$sysname}{totals}{'live'} += 1; } - $json{'switches'}{$sysname}{$smallport}{'total'} += 1; + $json{'switches'}{$sysname}{totals}{'total'} += 1; } $json{'switches'}{$sysname}{'time'} = $ref->{'time'}; } diff --git a/web/nms.gathering.org/api/public/switches b/web/nms.gathering.org/api/public/switches index 8447b2b..7e7f10b 100755 --- a/web/nms.gathering.org/api/public/switches +++ b/web/nms.gathering.org/api/public/switches @@ -12,14 +12,13 @@ use Data::Dumper; $nms::web::cc{'max-age'} = "60"; -my $q2 = $nms::web::dbh->prepare('select switch,sysname,placement,ip,switchtype,poll_frequency,community,last_updated from switches where placement is not null'); +my $q2 = $nms::web::dbh->prepare('select switch,sysname,placement,ip,poll_frequency,community,last_updated from switches where placement is not null'); $q2->execute(); while (my $ref = $q2->fetchrow_hashref()) { $ref->{'placement'} =~ /\((-?\d+),(-?\d+)\),\((-?\d+),(-?\d+)\)/; my ($x1, $y1, $x2, $y2) = ($1, $2, $3, $4); my $sysname = $ref->{'sysname'}; - $nms::web::json{'switches'}{$ref->{'sysname'}}{'switchtype'} = $ref->{'switchtype'}; $nms::web::json{'switches'}{$ref->{'sysname'}}{'placement'}{'x'} = $x2; $nms::web::json{'switches'}{$ref->{'sysname'}}{'placement'}{'y'} = $y2; $nms::web::json{'switches'}{$ref->{'sysname'}}{'placement'}{'width'} = $x1 - $x2; diff --git a/web/nms.gathering.org/js/nms-info-box.js b/web/nms.gathering.org/js/nms-info-box.js index 8527a03..cbdf942 100644 --- a/web/nms.gathering.org/js/nms-info-box.js +++ b/web/nms.gathering.org/js/nms-info-box.js @@ -393,33 +393,37 @@ nmsInfoBox._makeCommentTable = function(content) { } nmsInfoBox._searchSmart = function(id, sw) { - if (nmsData.smanagement.switches[sw].distro == id) { - console.log("ieh"); - return true; - } - if (id.match("[a-z]+.active")) { - console.log("hei: " + sw); - var family = id.match("[a-z]+"); - var limit = id; - limit = limit.replace(family + ".active>",""); - limit = limit.replace(family + ".active<",""); - limit = limit.replace(family + ".active=",""); - var operator = id.replace(family + ".active","")[0]; - if (limit == parseInt(limit)) { - if (operator == ">" ) { - if (nmsData.switchstate.switches[sw][family].live > limit) { - return true; - } - } else if (operator == "<") { - if (nmsData.switchstate.switches[sw][family].live < limit) { - return true; - } - } else if (operator == "=") { - if (nmsData.switchstate.switches[sw][family].live == limit) { - return true; + try { + if (nmsData.smanagement.switches[sw].distro == id) { + return true; + } + if (id.match("active")) { + var limit = id; + limit = limit.replace("active>",""); + limit = limit.replace("active<",""); + limit = limit.replace("active=",""); + var operator = id.replace("active","")[0]; + if (limit == parseInt(limit)) { + if (operator == ">" ) { + if (nmsData.switchstate.switches[sw]['totals'].live > limit) { + return true; + } + } else if (operator == "<") { + if (nmsData.switchstate.switches[sw]['totals'].live < limit) { + return true; + } + } else if (operator == "=") { + if (nmsData.switchstate.switches[sw]['totals'].live == limit) { + return true; + } } } } + if (nmsData.snmp.snmp[sw].misc.sysDescr[0].match(id)) { + return true; + } + } catch (e) { + return false; } return false; } |