diff options
Diffstat (limited to 'web/nms.gathering.org/api')
14 files changed, 319 insertions, 67 deletions
diff --git a/web/nms.gathering.org/api/API.rst b/web/nms.gathering.org/api/API.rst index 61fbb5a..7d5c88b 100644 --- a/web/nms.gathering.org/api/API.rst +++ b/web/nms.gathering.org/api/API.rst @@ -19,6 +19,58 @@ Currently error handling sucks. This document is in no way complete, but it's a start. It will be updated as time permits and API's stabilize. +Public +...... + +Use URL https://nms-public.tg16.gathering.org/api/public + +/api/public/dhcp +---------------- + +Methods: GET +Update frequency: every second or so. + +Used to report time since last dhcp lease. + +/api/public/dhcp-summary +------------------------ + +Methods: GET +Update frequency: every second or so. + +Used to report dhcp lease stats. Both recent stats, and total stats. + +/api/public/ping +---------------- + +Methods: GET +Update frequency: every second or so. + +Used to report linknet latency. + +The switch latency is being integrated into switch-state.pl and linknet +latency will similarly be moved. + +/api/public/switches +-------------------- + +Methods: GET +Update frequency: Infrequent (on topology/config changes) + +List all switches and map positions. + +Used to draw switches on a map and provide static information. + +/api/public/switch-state +------------------------ + +Methods: GET +Update frequency: Every second + +Provides state for each switch, including total port speed, uplink port +speed, latency and temperature. + + Private ....... @@ -77,37 +129,3 @@ Accepts an array of switches. Magic: If you set placement to be "reset", it will re-calculate placement based on sysname. For new switches, this is redundant as an empty placement-field will trigger the same behavior. - - -Public -...... - -/api/public/ping ----------------- - -Methods: GET -Update frequency: every second or so. - -Used to report linknet latency. - -The switch latency is being integrated into switch-state.pl and linknet -latency will similarly be moved. - -/api/public/switches --------------------- - -Methods: GET -Update frequency: Infrequent (on topology/config changes) - -List all switches and map positions. - -Used to draw switches on a map and provide static information. - -/api/public/switch-state ------------------------- - -Methods: GET -Update frequency: Every second - -Provides state for each switch, including total port speed, uplink port -speed, latency and temperature. diff --git a/web/nms.gathering.org/api/public/dhcp b/web/nms.gathering.org/api/public/dhcp new file mode 100755 index 0000000..7b048d1 --- /dev/null +++ b/web/nms.gathering.org/api/public/dhcp @@ -0,0 +1,20 @@ +#! /usr/bin/perl +# vim:ts=8:sw=8 + +use lib '../../../../include'; +use nms::web qw (%json finalize_output); +use strict; +use warnings; +use Data::Dumper; + +nms::web::setwhen('60m'); +my $q = $nms::web::dbh->prepare('select distinct on (sysname) extract(epoch from date_trunc(\'second\',time)) as time,sysname from dhcp join switches on dhcp.switch = switches.switch where ' . $nms::web::when . ' order by sysname,time desc;'); +$q->execute(); +while ( my $ref = $q->fetchrow_hashref() ) { + my $sysname = $ref->{'sysname'}; + $json{'dhcp'}{$ref->{'sysname'}} = $ref->{'time'}; +} + +$nms::web::cc{'max-age'} = "10"; +$nms::web::cc{'stale-while-revalidate'} = "30"; +finalize_output(); diff --git a/web/nms.gathering.org/api/public/dhcp-summary b/web/nms.gathering.org/api/public/dhcp-summary new file mode 100755 index 0000000..a0e5609 --- /dev/null +++ b/web/nms.gathering.org/api/public/dhcp-summary @@ -0,0 +1,16 @@ +#! /usr/bin/perl +use lib '../../../../include'; +use strict; +use warnings; +use nms::web; + +nms::web::setwhen('2h'); + +my $q2 = $nms::web::dbh->prepare("select count(distinct mac) as clients,count(distinct ip) as addresses,count(mac) as acks from dhcp where $nms::web::when;"); +$q2->execute(); +while (my $ref = $q2->fetchrow_hashref()) { + $nms::web::json{'dhcp'} = $ref; +} +$nms::web::cc{'max-age'} = "10"; +$nms::web::cc{'stale-while-revalidate'} = "15"; +finalize_output(); diff --git a/web/nms.gathering.org/api/public/location b/web/nms.gathering.org/api/public/location new file mode 100755 index 0000000..b940007 --- /dev/null +++ b/web/nms.gathering.org/api/public/location @@ -0,0 +1,44 @@ +#! /usr/bin/perl +# vim:ts=8:sw=8 + +use lib '../../../../include'; +use nms::web; +use strict; +use warnings; +use Data::Dumper; + +#my $query = $nms::web::dbh->prepare("select * from switches where '185.110.150.7' << subnet4"); +my $query = $nms::web::dbh->prepare("select * from switches where ? << subnet4 or ? << subnet6"); + +print "Cache-Control: max-age=0"; +print "Content-Type: text/html"; +print "\n\n"; + +# get user ip from somewhere. +# HTTP_X_FORWARDED_FOR is set by varnish. When using varnish, the REMOTE_ADDR will always be localhost. + +my @xff = split(",",$ENV{HTTP_X_FORWARDED_FOR}); +my $addr = $xff[0] // $ENV{REMOTE_ADDR}; + +$query->execute($addr,$addr); + +# add start html: header + body etc. +print " +<html> + <body style=\"text-align: center; font-size: 50pt;\"> +"; + +# print address +print "" . $addr ."<br \>"; + +# print switch name and distroname. +while ( my $ref = $query->fetchrow_hashref() ) { + print $ref->{sysname}. " @ " . $ref->{distro}; + print "<br />"; +} + +# add end html +print " + </body> +</html> +"; diff --git a/web/nms.gathering.org/api/public/ping b/web/nms.gathering.org/api/public/ping index bf92440..db46b00 100755 --- a/web/nms.gathering.org/api/public/ping +++ b/web/nms.gathering.org/api/public/ping @@ -1,33 +1,37 @@ #! /usr/bin/perl use lib '../../../../include'; +use strict; +use warnings; use nms::web; -#nms::web::setwhen('1s'); +nms::web::setwhen('10s'); + +my $q = $nms::web::dbh->prepare("SELECT DISTINCT ON (sysname) (now() - time) as age,sysname, latency_ms FROM ping NATURAL JOIN switches WHERE time in (select max(time) from ping where " + . $nms::web::when . " group by switch)"); -my $q = $nms::web::dbh->prepare("SELECT DISTINCT ON (sysname) (now() - time) as age,sysname, latency_ms FROM ping NATURAL JOIN switches WHERE time in (select max(time) from ping where " . $nms::web::when . " group by switch)"); $q->execute(); while (my $ref = $q->fetchrow_hashref()) { - $nms::web::json{'switches'}{$ref->{'sysname'}}{'latency'} = $ref->{'latency_ms'}; - # This isn't pretty, feel free to fix, but I want age == seconds - # without decimals. - my ($h,$m,$ss) = split(':', $ref->{'age'}); - my ($s,undef) = split('\.', "$ss"); - - $nms::web::json{'switches'}{$ref->{'sysname'}}{'age'} = ($h*60*60) + ($m*60) + $s;# $$ref->{'age'}; + $nms::web::json{'switches'}{$ref->{'sysname'}}{'latency'} = $ref->{'latency_ms'}; + # Get seconds, without decimlas, from timestamp. + # '00:01:01.435601' => 61 seconds. + my ( $h, $m, $s ) = split( ':|\.', $ref->{'age'} ); + $nms::web::json{'switches'}{$ref->{'sysname'}}{'age'} = ($h*60*60) + ($m*60) + $s; # $$ref->{'age'}; } -my $qs = $nms::web::dbh->prepare("SELECT DISTINCT ON (switch) switch, latency_ms FROM ping_secondary_ip WHERE " . $nms::web::when . " ORDER BY switch, time DESC;"); +my $qs = $nms::web::dbh->prepare("SELECT DISTINCT ON (switch) switch, latency_ms FROM ping_secondary_ip WHERE " + . $nms::web::when . " ORDER BY switch, time DESC;"); $qs->execute(); -while (my $ref = $qs->fetchrow_hashref()) { - $nms::web::json{'switches'}{$ref->{'switch'}}{'latency_secondary'} = $ref->{'latency_ms'}; +while ( my $ref = $qs->fetchrow_hashref() ) { + $nms::web::json{'switches'}{$ref->{'switch'}}{'latency_secondary'} = $ref->{'latency_ms'}; } -my $lq = $nms::web::dbh->prepare("SELECT DISTINCT ON (linknet) linknet, latency1_ms, latency2_ms FROM linknet_ping WHERE ". $nms::web::when . " ORDER BY linknet, time DESC;"); +my $lq = $nms::web::dbh->prepare("SELECT DISTINCT ON (linknet) linknet, latency1_ms, latency2_ms FROM linknet_ping WHERE " + . $nms::web::when . " ORDER BY linknet, time DESC;"); $lq->execute(); -while (my $ref = $lq->fetchrow_hashref()) { - $nms::web::json{'linknets'}{$ref->{'linknet'}} = [ $ref->{'latency1_ms'}, $ref->{'latency2_ms'} ]; +while ( my $ref = $lq->fetchrow_hashref() ) { + $nms::web::json{'linknets'}{$ref->{'linknet'}} = [ $ref->{'latency1_ms'}, $ref->{'latency2_ms'} ]; } -$nms::web::cc{'max-age'} = "1"; -$nms::web::cc{'stale-while-revalidate'} = "5"; +$nms::web::cc{'max-age'} = "2"; +$nms::web::cc{'stale-while-revalidate'} = "15"; finalize_output(); diff --git a/web/nms.gathering.org/api/public/switch-state b/web/nms.gathering.org/api/public/switch-state index 38f4c57..a6caea9 100755 --- a/web/nms.gathering.org/api/public/switch-state +++ b/web/nms.gathering.org/api/public/switch-state @@ -7,10 +7,11 @@ use strict; use warnings; use Data::Dumper; -my $q = $nms::web::dbh->prepare('select sysname,extract(epoch from date_trunc(\'second\',time)) as time,data from snmp natural join switches where id in (select max(id) from snmp where ' . $nms::web::when . 'group by switch);'); +my $q = $nms::web::dbh->prepare('select sysname,extract(epoch from date_trunc(\'second\',time)) as time,data from snmp natural join switches where id in (select max(id) from snmp where ' + . $nms::web::when . 'group by switch);'); $q->execute(); -while (my $ref = $q->fetchrow_hashref()) { +while ( my $ref = $q->fetchrow_hashref() ) { my $sysname = $ref->{'sysname'}; my %data = %{JSON::XS::decode_json($ref->{'data'})}; @@ -18,8 +19,15 @@ while (my $ref = $q->fetchrow_hashref()) { for my $porti (keys %{$data{'ports'}}) { 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 =~ m/\.0$/) { + next; + } + if (not $smallport =~ m/^ae/ and not $smallport =~ m/^et/) { + $smallport =~ s/[0-9-].*$//; + } else { + $json{'switches'}{$sysname}{ifs}{$smallport}{'ifAlias'} = $port{'ifAlias'}; + } + 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") { @@ -27,16 +35,63 @@ 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}{'temp'} = $data{'misc'}{'jnxOperatingTemp'}{'7.1.0.0'}; $json{'switches'}{$sysname}{'time'} = $ref->{'time'}; } + +nms::web::setwhen('15m','10m'); +my $q2 = $nms::web::dbh->prepare('select sysname,extract(epoch from date_trunc(\'second\',time)) as time,data from snmp natural join switches where id in (select max(id) from snmp where ' + . $nms::web::when . 'group by switch);'); + +$q2->execute(); +while ( my $ref = $q2->fetchrow_hashref() ) { + my $sysname = $ref->{'sysname'}; + + my %data = %{JSON::XS::decode_json($ref->{'data'})}; + + for my $porti (keys %{$data{'ports'}}) { + my %port = %{$data{'ports'}{$porti}}; + my $smallport = $porti; + if ($porti =~ m/\.0$/) { + next; + } + if (not $smallport =~ m/^ae/ and not $smallport =~ m/^et/) { + $smallport =~ s/[0-9-].*$//; + } else { + $json{'then'}{$sysname}{ifs}{$smallport}{'ifAlias'} = $port{'ifAlias'}; + } + if ($porti =~ /ge-0\/0\/4[4-7]$/) { + $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}{ifs}{$smallport}{'ifHCInOctets'} += $port{'ifHCInOctets'}; + $json{'then'}{$sysname}{ifs}{$smallport}{'ifHCOutOctets'} += $port{'ifHCOutOctets'}; + $json{'then'}{$sysname}{totals}{'ifHCInOctets'} += $port{'ifHCInOctets'}; + $json{'then'}{$sysname}{totals}{'ifHCOutOctets'} += $port{'ifHCOutOctets'}; + if ($port{'ifOperStatus'} eq "up") { + $json{'then'}{$sysname}{ifs}{$smallport}{'live'} += 1; + $json{'then'}{$sysname}{totals}{'live'} += 1; + } + $json{'then'}{$sysname}{totals}{'total'} += 1; + } + $json{'then'}{$sysname}{'temp'} = $data{'misc'}{'enterprises.2636.3.1.13.1.7.7.1.0.0'}{''}; + $json{'then'}{$sysname}{'time'} = $ref->{'time'}; +} $nms::web::cc{'max-age'} = "5"; $nms::web::cc{'stale-while-revalidate'} = "30"; finalize_output(); diff --git a/web/nms.gathering.org/api/public/switches b/web/nms.gathering.org/api/public/switches index 8447b2b..890b7d7 100755 --- a/web/nms.gathering.org/api/public/switches +++ b/web/nms.gathering.org/api/public/switches @@ -12,18 +12,18 @@ 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,distro_name,placement,mgmt_v4_addr,mgmt_v6_addr,mgmt_v4_gw,mgmt_v6_gw,mgmt_vlan,traffic_vlan,last_config_fetch,current_mac,poll_frequency,community,last_updated,switchtype 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; $nms::web::json{'switches'}{$ref->{'sysname'}}{'placement'}{'height'} = $y1 - $y2; + $nms::web::json{'switches'}{$ref->{'sysname'}}{'distro_name'} = $ref->{'distro_name'}; } my $q4 = $nms::web::dbh->prepare('select linknet, (select sysname from switches where switch = switch1) as sysname1, (select sysname from switches where switch = switch2) as sysname2 from linknets'); diff --git a/web/nms.gathering.org/api/private/comments b/web/nms.gathering.org/api/read/comments index 4adfb2b..4adfb2b 100755 --- a/web/nms.gathering.org/api/private/comments +++ b/web/nms.gathering.org/api/read/comments diff --git a/web/nms.gathering.org/api/private/snmp b/web/nms.gathering.org/api/read/snmp index 4779659..f69ca62 100755 --- a/web/nms.gathering.org/api/private/snmp +++ b/web/nms.gathering.org/api/read/snmp @@ -13,7 +13,8 @@ use Data::Dumper; $nms::web::cc{'max-age'} = "10"; -my $q = $nms::web::dbh->prepare('select sysname,data from snmp natural join switches where id in (select max(id) from snmp where ' . $nms::web::when . 'group by switch);'); +my $q = $nms::web::dbh->prepare('select sysname,data from snmp natural join switches where id in (select max(id) from snmp where ' + . $nms::web::when . 'group by switch);'); $q->execute(); while (my $ref = $q->fetchrow_hashref()) { diff --git a/web/nms.gathering.org/api/private/switches-management b/web/nms.gathering.org/api/read/switches-management index 6b5fdcd..4461a90 100755 --- a/web/nms.gathering.org/api/private/switches-management +++ b/web/nms.gathering.org/api/read/switches-management @@ -12,7 +12,7 @@ use Data::Dumper; $nms::web::cc{'max-age'} = "60"; -my $q2 = $nms::web::dbh->prepare('select sysname,ip,poll_frequency,community,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,distro_phy_port from switches where placement is not null'); $q2->execute(); while (my $ref = $q2->fetchrow_hashref()) { diff --git a/web/nms.gathering.org/api/private/comment-add b/web/nms.gathering.org/api/write/comment-add index 26ff734..bcea6dc 100755 --- a/web/nms.gathering.org/api/private/comment-add +++ b/web/nms.gathering.org/api/write/comment-add @@ -20,5 +20,5 @@ $nms::web::cc{'max-age'} = '0'; $nms::web::cc{'stale-while-revalidate'} = '0'; $nms::web::json{'state'} = 'ok'; -print "X-ban: /api/private/comments\n"; +print "X-ban: /api/read/comments\n"; finalize_output(); diff --git a/web/nms.gathering.org/api/private/comment-change b/web/nms.gathering.org/api/write/comment-change index fb7da54..0bdabc0 100755 --- a/web/nms.gathering.org/api/private/comment-change +++ b/web/nms.gathering.org/api/write/comment-change @@ -21,4 +21,5 @@ $nms::web::cc{'max-age'} = '0'; $nms::web::cc{'stale-while-revalidate'} = '0'; $nms::web::json{'state'} = 'ok'; +print "X-ban: /api/read/comments\n"; finalize_output(); diff --git a/web/nms.gathering.org/api/write/switch-add b/web/nms.gathering.org/api/write/switch-add new file mode 100755 index 0000000..0051111 --- /dev/null +++ b/web/nms.gathering.org/api/write/switch-add @@ -0,0 +1,92 @@ +#! /usr/bin/perl +# vim:ts=8:sw=8 + +#use CGI qw(fatalsToBrowser); +use DBI; +use lib '../../../../include'; +use nms; +use nms::web qw(%get_params %json finalize_output get_input $dbh); +use nms::util qw(guess_placement); +use strict; +use warnings; +use JSON; +use Data::Dumper; + +$nms::web::cc{'max-age'} = "0"; + +my $in = get_input(); +my @tmp = @{JSON::XS::decode_json($in)}; + +my @added; +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_v6_addr', 'mgmt_v6_gw', 'mgmt_vlan', 'placement', 'poll_frequency', 'subnet4', 'subnet6', 'switchtype', 'sysname', 'traffic_vlan'); + +sub convertplace +{ + my %in = %{$_[0]}; + my %out = (); + + if (not defined $in{'x1'} and defined($in{'x'})) { + $out{'x1'} = int($in{'x'}); + $out{'y1'} = int($in{'y'}); + $out{'xx'} = int($in{'x'} + $in{'width'}); + $out{'yy'} = int($in{'y'} + $in{'height'}); + } else { + return \%in; + } + return \%out; +} + +foreach my $tmp2 (@tmp) { + my %switch = %{$tmp2}; + my $affected = 0; + my %template = (); + map { $template{$_} = 'DEFAULT' } @fields; + if (not defined($switch{'sysname'})) { + next; + } + + $sth->execute( $switch{'sysname'}); + while ( my @row = $sth->fetchrow_array ) { + $affected += 1; + } + + if ($affected == 0) { + my %placement; + if (not defined ($switch{'placement'})) { + %placement = guess_placement($switch{'sysname'}); + } else { + %placement = %{convertplace($switch{'placement'})}; + } + if (not defined($switch{'ip'}) and defined($switch{'mgtmt4'})) { + $switch{'ip'} = $switch{'mgtmt4'}; + } + if (not defined($switch{'secondary_ip'}) and defined($switch{'mgtmt6'})) { + $switch{'secondary_ip'} = $switch{'mgtmt6'}; + } + my ($x1,$x2,$y1,$y2); + $x1 = $placement{'x1'}; + $y1 = $placement{'y1'}; + $x2 = $placement{'xx'}; + $y2 = $placement{'yy'}; + $switch{'placement'} = "(($x1,$y1),($x2,$y2))"; + + map { + if (defined ($template{$_})) { + $template{$_} = $dbh->quote($switch{$_}); + } + } keys %switch; + + + $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'}; + } +} + +$json{'switches_addded'} = \@added; + +print "X-ban: /api/.*switches.*\n"; +finalize_output(); diff --git a/web/nms.gathering.org/api/private/switch-add b/web/nms.gathering.org/api/write/switch-update index 3d7b119..14c8773 100755 --- a/web/nms.gathering.org/api/private/switch-add +++ b/web/nms.gathering.org/api/write/switch-update @@ -22,7 +22,8 @@ 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 = ( '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'); sub convertplace { @@ -81,7 +82,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'})) { |