aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolai Tellefsen <niccofyren@gmail.com>2016-03-23 10:09:34 +0100
committerNicolai Tellefsen <niccofyren@gmail.com>2016-03-23 10:09:34 +0100
commita974e356decee205806f366fba776f2d770bd220 (patch)
treeb5d8a8046c734c5b067ce35bf285bb4e4720e003
parent1f88d1f2ba1e304abe4cd20f0bd3aae9347f4be8 (diff)
parent65c8e3fca802155828626898ede0d08beccfe579 (diff)
Merge branch 'master' of ssh://github.com/tech-server/tgmanage
-rwxr-xr-xweb/nms.gathering.org/api/read/switches-management3
-rwxr-xr-xweb/nms.gathering.org/api/write/switch-add4
-rw-r--r--web/nms.gathering.org/index.html5
-rw-r--r--web/nms.gathering.org/js/nms-map-handlers.js30
-rw-r--r--web/nms.gathering.org/js/nms.js5
5 files changed, 42 insertions, 5 deletions
diff --git a/web/nms.gathering.org/api/read/switches-management b/web/nms.gathering.org/api/read/switches-management
index 292a6fb..9e12337 100755
--- a/web/nms.gathering.org/api/read/switches-management
+++ b/web/nms.gathering.org/api/read/switches-management
@@ -12,8 +12,7 @@ use Data::Dumper;
$nms::web::cc{'max-age'} = "60";
-#my $q2 = $nms::web::dbh->prepare('select sysname,ip,poll_frequency,subnet4,subnet6,distro,last_updated from switches ');
-my $q2 = $nms::web::dbh->prepare('select switch,sysname,mgmt_v4_addr,subnet4,subnet6,mgmt_v6_addr,mgmt_v4_gw,mgmt_v6_gw,mgmt_vlan,traffic_vlan,last_config_fetch,current_mac,poll_frequency,last_updated,switchtype from switches where placement is not null');
+my $q2 = $nms::web::dbh->prepare('select switch,sysname,mgmt_v4_addr,subnet4,subnet6,mgmt_v6_addr,mgmt_v4_gw,mgmt_v6_gw,mgmt_vlan,traffic_vlan,last_config_fetch,current_mac,poll_frequency,last_updated from switches where placement is not null');
$q2->execute();
while (my $ref = $q2->fetchrow_hashref()) {
diff --git a/web/nms.gathering.org/api/write/switch-add b/web/nms.gathering.org/api/write/switch-add
index 411a76b..0051111 100755
--- a/web/nms.gathering.org/api/write/switch-add
+++ b/web/nms.gathering.org/api/write/switch-add
@@ -22,7 +22,7 @@ my @dups;
my $sth = $nms::web::dbh->prepare("SELECT sysname FROM switches WHERE sysname=?");
-my @fields = ( 'community', 'current_mac', 'distro_name', 'distro_phy_port', 'lldp_chassis_id', 'mgmt_v4_addr', 'mgmt_v4_gw', 'mgmt_v4_netsize', 'mgmt_v6_addr', 'mgmt_v6_gw', 'mgmt_v6_netsize', 'mgmt_vlan', 'placement', 'poll_frequency', 'subnet4', 'subnet6', 'switchtype', 'sysname', 'traffic_vlan');
+my @fields = ( 'community', 'current_mac', 'distro_name', 'distro_phy_port', 'lldp_chassis_id', 'mgmt_v4_addr', 'mgmt_v4_gw', 'mgmt_v6_addr', 'mgmt_v6_gw', 'mgmt_vlan', 'placement', 'poll_frequency', 'subnet4', 'subnet6', 'switchtype', 'sysname', 'traffic_vlan');
sub convertplace
{
@@ -81,7 +81,7 @@ foreach my $tmp2 (@tmp) {
} keys %switch;
- $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'});");
+ $nms::web::dbh->do("INSERT INTO SWITCHES (mgmt_v4_addr, sysname, poll_frequency, community, lldp_chassis_id, mgmt_v6_addr, placement,subnet4,subnet6,distro_name) VALUES ($template{'mgmt_v4_addr'}, $template{'sysname'}, $template{'poll_frequency'}, $template{'community'}, $template{'lldp_chassis_id'}, $template{'mgmt_v6_addr'}, $template{'placement'},$template{'subnet4'},$template{'subnet6'},$template{'distro_name'});");
push @added, $switch{'sysname'};
}
}
diff --git a/web/nms.gathering.org/index.html b/web/nms.gathering.org/index.html
index da76f53..a10d1dc 100644
--- a/web/nms.gathering.org/index.html
+++ b/web/nms.gathering.org/index.html
@@ -67,6 +67,7 @@
<li><a href="#temp" onclick="setUpdater(handler_temp)">Temperature map</a></li>
<li><a href="#traffic" onclick="setUpdater(handler_traffic)">Traffic map</a></li>
<li><a href="#traffictot" onclick="setUpdater(handler_traffic_tot)">Total switch traffic</a></li>
+ <li><a href="#snmp" onclick="setUpdater(handler_snmp)">SNMP map</a></li>
<li><a href="#disco" onclick="setUpdater(handler_disco)">DISCO</a></li>
<li class="divider"> </li>
<li><a href="#" onclick="toggleLayer('nowPickerBox');startNowPicker();">Travel in time</a></li>
@@ -169,6 +170,10 @@
<td>View total switch traffic map</td>
</tr>
<tr>
+ <td>8</td>
+ <td>View SNMP map</td>
+ </tr>
+ <tr>
<td>9</td>
<td>View Disco map</td>
</tr>
diff --git a/web/nms.gathering.org/js/nms-map-handlers.js b/web/nms.gathering.org/js/nms-map-handlers.js
index 82d0c4a..6de2943 100644
--- a/web/nms.gathering.org/js/nms-map-handlers.js
+++ b/web/nms.gathering.org/js/nms-map-handlers.js
@@ -67,6 +67,12 @@ var handler_comment = {
name:"Fresh comment spotter"
};
+var handler_snmp = {
+ init:snmpInit,
+ tag:"snmp",
+ name:"SNMP state"
+};
+
var handlers = [
handler_uplinks,
handler_temp,
@@ -75,7 +81,8 @@ var handlers = [
handler_disco,
handler_comment,
handler_traffic_tot,
- handler_dhcp
+ handler_dhcp,
+ handler_snmp
];
/*
@@ -424,3 +431,24 @@ function discoInit()
setLegend(5,"white","!");
}
+function snmpUpdater() {
+ for (var sw in nmsData.switches.switches) {
+ if (nmsData.snmp.snmp[sw] == undefined || nmsData.snmp.snmp[sw].misc == undefined) {
+ nmsMap.setSwitchColor(sw, red);
+ } else if (nmsData.snmp.snmp[sw].misc.sysName[0] != sw) {
+ nmsMap.setSwitchColor(sw, orange);
+ } else {
+ nmsMap.setSwitchColor(sw, green);
+ }
+ }
+}
+function snmpInit() {
+ nmsData.addHandler("snmp", "mapHandler", snmpUpdater);
+
+ setLegend(1,green,"OK");
+ setLegend(2,orange, "Sysname mismatch");
+ setLegend(3,red,"No SNMP data");
+ setLegend(4,green, "");
+ setLegend(5,green,"");
+
+}
diff --git a/web/nms.gathering.org/js/nms.js b/web/nms.gathering.org/js/nms.js
index 964c73f..1c750b8 100644
--- a/web/nms.gathering.org/js/nms.js
+++ b/web/nms.gathering.org/js/nms.js
@@ -38,6 +38,8 @@ var nms = {
'5':setMapModeFromN,
'6':setMapModeFromN,
'7':setMapModeFromN,
+ '8':setMapModeFromN,
+ '9':setMapModeFromN,
'c':toggleConnect,
'h':moveTimeFromKey,
'j':moveTimeFromKey,
@@ -544,6 +546,9 @@ function setMapModeFromN(e,key)
case '7':
setUpdater(handler_traffic_tot);
break;
+ case '8':
+ setUpdater(handler_snmp);
+ break;
case '9':
setUpdater(handler_disco);
break;