diff options
author | Kristian Lyngstol <kly@kly@.no> | 2016-03-26 03:48:32 +0100 |
---|---|---|
committer | Kristian Lyngstol <kly@kly@.no> | 2016-03-26 03:48:32 +0100 |
commit | cda4d1235486dc74c5d3630fc5e85307f277c5f3 (patch) | |
tree | 0e59890e8afcf09024079d0e3a596e16b63250af /examples/historical/tools/make-switches.pl | |
parent | 004f4efcfd0779f4307b90fed139dc87d01ad0b9 (diff) | |
parent | a791ca16c787672ea534dbde39f926d0341aa2e6 (diff) |
Merge branch 'master' of github.com:tech-server/tgmanage
Diffstat (limited to 'examples/historical/tools/make-switches.pl')
-rwxr-xr-x | examples/historical/tools/make-switches.pl | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/examples/historical/tools/make-switches.pl b/examples/historical/tools/make-switches.pl new file mode 100755 index 0000000..c0c842a --- /dev/null +++ b/examples/historical/tools/make-switches.pl @@ -0,0 +1,36 @@ +#! /usr/bin/perl + +use strict; +use warnings; + +my $switchtype = "ex2200"; + +print "begin;\n"; +print "delete from temppoll;\n"; +print "delete from dhcp;\n"; +print "delete from switches where switchtype = '$switchtype';\n"; +#print "SELECT pg_catalog.setval('switches_switch_seq', 1, false);\n"; +print "SELECT pg_catalog.setval('polls_poll_seq', 1, false);\n"; + +my %ip; +my $i = 1; +while (<STDIN>) { + chomp; + my @info = split(/ /); + + if (scalar @info < 5) { + die "Unknown line: $_"; + } + + my $name = $info[0]; + my $range = $info[1]; + my $ip = $info[3]; + $ip =~ s/\/.*$//; + + + print "insert into switches (ip, sysname, switchtype) values ('$ip', '$name', '$switchtype');\n"; + print "insert into dhcp select switch, '$range' from switches where sysname = '$name';\n"; +} +close HOSTS; + +print "end;\n"; |