aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolai Tellefsen <niccofyren@gmail.com>2016-03-26 07:30:07 +0100
committerNicolai Tellefsen <niccofyren@gmail.com>2016-03-26 07:30:07 +0100
commit5755c9a0ef2d72549aa6eb281c6769c8c171421d (patch)
treef13317e4903ec7de43e6fb46b6181a5730c27016
parent04b13311cedf90f57db5d53feea7349a008f628b (diff)
parentec0d348139403d7caba4ee4cbb99d893d8c741b8 (diff)
Merge branch 'master' of ssh://github.com/tech-server/tgmanage
-rwxr-xr-xclients/ping.pl2
-rwxr-xr-xclients/snmpfetchng.pl2
-rwxr-xr-xinclude/nms/web.pm4
-rw-r--r--nms/nms-dump.sql149
-rw-r--r--nms/postgresql.conf10
-rwxr-xr-xweb/nms-public.gathering.org/api/public/dhcp-summary7
-rwxr-xr-xweb/nms-public.gathering.org/api/public/ping6
-rwxr-xr-xweb/nms.gathering.org/api/public/dhcp2
-rwxr-xr-xweb/nms.gathering.org/api/public/dhcp-summary7
-rwxr-xr-xweb/nms.gathering.org/api/public/ping6
-rwxr-xr-xweb/nms.gathering.org/api/public/switch-state6
-rw-r--r--web/nms.gathering.org/js/nms-info-box.js10
-rw-r--r--web/stats.gathering.org/index.html3
13 files changed, 176 insertions, 38 deletions
diff --git a/clients/ping.pl b/clients/ping.pl
index 1ad7b95..d945917 100755
--- a/clients/ping.pl
+++ b/clients/ping.pl
@@ -16,7 +16,7 @@ $dbh->{AutoCommit} = 0;
$dbh->{RaiseError} = 1;
my $q = $dbh->prepare("SELECT switch,host(mgmt_v4_addr) as ip,host(mgmt_v6_addr) as secondary_ip FROM switches WHERE mgmt_v4_addr is not null ORDER BY random()");
-my $lq = $dbh->prepare("SELECT linknet,addr1,addr2 FROM linknets");
+my $lq = $dbh->prepare("SELECT linknet,addr1,addr2 FROM linknets WHERE addr1 is not null and addr2 is not null");
while (1) {
# ping loopbacks
diff --git a/clients/snmpfetchng.pl b/clients/snmpfetchng.pl
index bbdb00d..2f5e785 100755
--- a/clients/snmpfetchng.pl
+++ b/clients/snmpfetchng.pl
@@ -10,9 +10,9 @@ use lib '../include';
use nms;
SNMP::initMib();
-SNMP::addMibDirs("/srv/tgmanage/mibs");
SNMP::addMibDirs("/srv/tgmanage/mibs/StandardMibs");
SNMP::addMibDirs("/srv/tgmanage/mibs/JuniperMibs");
+SNMP::addMibDirs("/srv/tgmanage/mibs");
SNMP::loadModules('ALL');
our $dbh = nms::db_connect();
diff --git a/include/nms/web.pm b/include/nms/web.pm
index c9f7236..889e774 100755
--- a/include/nms/web.pm
+++ b/include/nms/web.pm
@@ -57,7 +57,7 @@ sub db_safe_quote {
# endpoints it is better to return no data than old data (e.g.: ping).
sub setwhen {
$now = "now()";
- my $window = '15m';
+ my $window = '8m';
my $offset = '0s';
if (@_ > 0) {
$window = $_[0];
@@ -86,6 +86,8 @@ sub finalize_output {
printcc;
print "Etag: $hash\n";
+ print "Access-Control-Allow-Origin: *\n";
+ print "Access-Control-Allow-Methods: HEAD, GET\n";
print "Content-Type: text/json; charset=utf-8\n\n";
print JSON::XS::encode_json(\%json);
print "\n";
diff --git a/nms/nms-dump.sql b/nms/nms-dump.sql
index 335a3b0..25ba3ac 100644
--- a/nms/nms-dump.sql
+++ b/nms/nms-dump.sql
@@ -49,7 +49,7 @@ SET default_with_oids = false;
CREATE TABLE dhcp (
switch integer,
- "time" timestamp without time zone,
+ "time" timestamp with time zone,
mac macaddr,
ip inet
);
@@ -78,9 +78,11 @@ ALTER TABLE linknet_ping OWNER TO nms;
CREATE TABLE linknets (
linknet integer NOT NULL,
switch1 integer NOT NULL,
- addr1 inet NOT NULL,
+ addr1 inet,
switch2 integer NOT NULL,
- addr2 inet NOT NULL
+ addr2 inet,
+ port1 character varying(10),
+ port2 character varying(10)
);
@@ -253,19 +255,26 @@ ALTER TABLE switch_temp OWNER TO nms;
CREATE TABLE switches (
switch integer DEFAULT nextval(('"switches_switch_seq"'::text)::regclass) NOT NULL,
- ip inet,
+ mgmt_v4_addr inet,
sysname character varying NOT NULL,
switchtype character varying DEFAULT 'ex2200'::character varying NOT NULL,
last_updated timestamp with time zone,
locked boolean DEFAULT false NOT NULL,
poll_frequency interval DEFAULT '00:01:00'::interval NOT NULL,
- community character varying DEFAULT 'public'::character varying NOT NULL,
+ community character varying DEFAULT 'FullPuppTilNMS'::character varying NOT NULL,
lldp_chassis_id character varying,
- secondary_ip inet,
+ mgmt_v6_addr inet,
placement box,
subnet4 cidr,
subnet6 cidr,
- distro character varying
+ distro_name character varying,
+ distro_phy_port character varying(100),
+ mgmt_v6_gw inet,
+ mgmt_v4_gw inet,
+ mgmt_vlan integer DEFAULT 666,
+ traffic_vlan integer,
+ last_config_fetch timestamp with time zone,
+ current_mac macaddr
);
@@ -286,6 +295,17 @@ CREATE SEQUENCE switches_switch_seq
ALTER TABLE switches_switch_seq OWNER TO nms;
--
+-- Name: test_table; Type: TABLE; Schema: public; Owner: nms; Tablespace:
+--
+
+CREATE TABLE test_table (
+ test timestamp with time zone
+);
+
+
+ALTER TABLE test_table OWNER TO nms;
+
+--
-- Name: linknet; Type: DEFAULT; Schema: public; Owner: nms
--
@@ -355,6 +375,20 @@ ALTER TABLE ONLY switches
--
+-- Name: dhcp_ip; Type: INDEX; Schema: public; Owner: nms; Tablespace:
+--
+
+CREATE INDEX dhcp_ip ON dhcp USING btree (ip);
+
+
+--
+-- Name: dhcp_mac; Type: INDEX; Schema: public; Owner: nms; Tablespace:
+--
+
+CREATE INDEX dhcp_mac ON dhcp USING btree (mac);
+
+
+--
-- Name: dhcp_switch; Type: INDEX; Schema: public; Owner: nms; Tablespace:
--
@@ -376,6 +410,13 @@ CREATE INDEX ping_index ON ping USING btree ("time");
--
+-- Name: ping_secondary_index; Type: INDEX; Schema: public; Owner: nms; Tablespace:
+--
+
+CREATE INDEX ping_secondary_index ON ping_secondary_ip USING btree ("time");
+
+
+--
-- Name: polls_ifname; Type: INDEX; Schema: public; Owner: nms; Tablespace:
--
@@ -514,6 +555,67 @@ REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;
+GRANT ALL ON SCHEMA public TO fap;
+
+
+--
+-- Name: dhcp; Type: ACL; Schema: public; Owner: nms
+--
+
+REVOKE ALL ON TABLE dhcp FROM PUBLIC;
+REVOKE ALL ON TABLE dhcp FROM nms;
+GRANT ALL ON TABLE dhcp TO nms;
+GRANT ALL ON TABLE dhcp TO fap;
+
+
+--
+-- Name: linknet_ping; Type: ACL; Schema: public; Owner: nms
+--
+
+REVOKE ALL ON TABLE linknet_ping FROM PUBLIC;
+REVOKE ALL ON TABLE linknet_ping FROM nms;
+GRANT ALL ON TABLE linknet_ping TO nms;
+GRANT ALL ON TABLE linknet_ping TO fap;
+
+
+--
+-- Name: linknets; Type: ACL; Schema: public; Owner: nms
+--
+
+REVOKE ALL ON TABLE linknets FROM PUBLIC;
+REVOKE ALL ON TABLE linknets FROM nms;
+GRANT ALL ON TABLE linknets TO nms;
+GRANT ALL ON TABLE linknets TO fap;
+
+
+--
+-- Name: ping; Type: ACL; Schema: public; Owner: nms
+--
+
+REVOKE ALL ON TABLE ping FROM PUBLIC;
+REVOKE ALL ON TABLE ping FROM nms;
+GRANT ALL ON TABLE ping TO nms;
+GRANT ALL ON TABLE ping TO fap;
+
+
+--
+-- Name: ping_secondary_ip; Type: ACL; Schema: public; Owner: nms
+--
+
+REVOKE ALL ON TABLE ping_secondary_ip FROM PUBLIC;
+REVOKE ALL ON TABLE ping_secondary_ip FROM nms;
+GRANT ALL ON TABLE ping_secondary_ip TO nms;
+GRANT ALL ON TABLE ping_secondary_ip TO fap;
+
+
+--
+-- Name: polls; Type: ACL; Schema: public; Owner: nms
+--
+
+REVOKE ALL ON TABLE polls FROM PUBLIC;
+REVOKE ALL ON TABLE polls FROM nms;
+GRANT ALL ON TABLE polls TO nms;
+GRANT ALL ON TABLE polls TO fap;
--
@@ -523,6 +625,7 @@ GRANT ALL ON SCHEMA public TO PUBLIC;
REVOKE ALL ON TABLE seen_mac FROM PUBLIC;
REVOKE ALL ON TABLE seen_mac FROM nms;
GRANT ALL ON TABLE seen_mac TO nms;
+GRANT ALL ON TABLE seen_mac TO fap;
--
@@ -533,6 +636,7 @@ REVOKE ALL ON TABLE snmp FROM PUBLIC;
REVOKE ALL ON TABLE snmp FROM nms;
GRANT ALL ON TABLE snmp TO nms;
GRANT ALL ON TABLE snmp TO postgres;
+GRANT ALL ON TABLE snmp TO fap;
--
@@ -546,12 +650,43 @@ GRANT ALL ON SEQUENCE snmp_id_seq TO postgres;
--
+-- Name: switch_comments; Type: ACL; Schema: public; Owner: nms
+--
+
+REVOKE ALL ON TABLE switch_comments FROM PUBLIC;
+REVOKE ALL ON TABLE switch_comments FROM nms;
+GRANT ALL ON TABLE switch_comments TO nms;
+GRANT ALL ON TABLE switch_comments TO fap;
+
+
+--
+-- Name: switch_temp; Type: ACL; Schema: public; Owner: nms
+--
+
+REVOKE ALL ON TABLE switch_temp FROM PUBLIC;
+REVOKE ALL ON TABLE switch_temp FROM nms;
+GRANT ALL ON TABLE switch_temp TO nms;
+GRANT ALL ON TABLE switch_temp TO fap;
+
+
+--
-- Name: switches; Type: ACL; Schema: public; Owner: nms
--
REVOKE ALL ON TABLE switches FROM PUBLIC;
REVOKE ALL ON TABLE switches FROM nms;
GRANT ALL ON TABLE switches TO nms;
+GRANT ALL ON TABLE switches TO fap;
+
+
+--
+-- Name: test_table; Type: ACL; Schema: public; Owner: nms
+--
+
+REVOKE ALL ON TABLE test_table FROM PUBLIC;
+REVOKE ALL ON TABLE test_table FROM nms;
+GRANT ALL ON TABLE test_table TO nms;
+GRANT ALL ON TABLE test_table TO fap;
--
diff --git a/nms/postgresql.conf b/nms/postgresql.conf
index 23241a7..dee1129 100644
--- a/nms/postgresql.conf
+++ b/nms/postgresql.conf
@@ -113,19 +113,19 @@ ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key' # (change requires rest
# - Memory -
-shared_buffers = 2048MB # min 128kB
+shared_buffers = 76GB # min 128kB
# (change requires restart)
#huge_pages = try # on, off, or try
# (change requires restart)
-#temp_buffers = 8MB # min 800kB
+temp_buffers = 32MB # min 800kB
#max_prepared_transactions = 0 # zero disables the feature
# (change requires restart)
# Note: Increasing max_prepared_transactions costs ~600 bytes of shared memory
# per transaction slot, plus lock space (see max_locks_per_transaction).
# It is not advisable to set max_prepared_transactions nonzero unless you
# actively intend to use prepared transactions.
-#work_mem = 4MB # min 64kB
-#maintenance_work_mem = 64MB # min 1MB
+work_mem = 16MB # min 64kB
+maintenance_work_mem = 256MB # min 1MB
#autovacuum_work_mem = -1 # min 1MB, or -1 to use maintenance_work_mem
#max_stack_depth = 2MB # min 100kB
dynamic_shared_memory_type = posix # the default is the first option
@@ -173,7 +173,7 @@ dynamic_shared_memory_type = posix # the default is the first option
# - Settings -
-#wal_level = minimal # minimal, archive, hot_standby, or logical
+wal_level = archive # minimal, archive, hot_standby, or logical
# (change requires restart)
#fsync = on # turns forced synchronization on or off
#synchronous_commit = on # synchronization level;
diff --git a/web/nms-public.gathering.org/api/public/dhcp-summary b/web/nms-public.gathering.org/api/public/dhcp-summary
index dd643b2..a0e5609 100755
--- a/web/nms-public.gathering.org/api/public/dhcp-summary
+++ b/web/nms-public.gathering.org/api/public/dhcp-summary
@@ -5,16 +5,11 @@ use warnings;
use nms::web;
nms::web::setwhen('2h');
-my $q = $nms::web::dbh->prepare("select count(distinct mac) as clients,count(distinct ip) as addresses,count(mac) as acks from dhcp;");
-$q->execute();
-while (my $ref = $q->fetchrow_hashref()) {
- $nms::web::json{'dhcp'}{'total'} = $ref;
-}
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'}{'recent'} = $ref;
+ $nms::web::json{'dhcp'} = $ref;
}
$nms::web::cc{'max-age'} = "10";
$nms::web::cc{'stale-while-revalidate'} = "15";
diff --git a/web/nms-public.gathering.org/api/public/ping b/web/nms-public.gathering.org/api/public/ping
index ba572af..db46b00 100755
--- a/web/nms-public.gathering.org/api/public/ping
+++ b/web/nms-public.gathering.org/api/public/ping
@@ -4,7 +4,7 @@ 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)");
@@ -32,6 +32,6 @@ 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/dhcp b/web/nms.gathering.org/api/public/dhcp
index 91d52af..7b048d1 100755
--- a/web/nms.gathering.org/api/public/dhcp
+++ b/web/nms.gathering.org/api/public/dhcp
@@ -15,6 +15,6 @@ while ( my $ref = $q->fetchrow_hashref() ) {
$json{'dhcp'}{$ref->{'sysname'}} = $ref->{'time'};
}
-$nms::web::cc{'max-age'} = "5";
+$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
index dd643b2..a0e5609 100755
--- a/web/nms.gathering.org/api/public/dhcp-summary
+++ b/web/nms.gathering.org/api/public/dhcp-summary
@@ -5,16 +5,11 @@ use warnings;
use nms::web;
nms::web::setwhen('2h');
-my $q = $nms::web::dbh->prepare("select count(distinct mac) as clients,count(distinct ip) as addresses,count(mac) as acks from dhcp;");
-$q->execute();
-while (my $ref = $q->fetchrow_hashref()) {
- $nms::web::json{'dhcp'}{'total'} = $ref;
-}
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'}{'recent'} = $ref;
+ $nms::web::json{'dhcp'} = $ref;
}
$nms::web::cc{'max-age'} = "10";
$nms::web::cc{'stale-while-revalidate'} = "15";
diff --git a/web/nms.gathering.org/api/public/ping b/web/nms.gathering.org/api/public/ping
index ba572af..db46b00 100755
--- a/web/nms.gathering.org/api/public/ping
+++ b/web/nms.gathering.org/api/public/ping
@@ -4,7 +4,7 @@ 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)");
@@ -32,6 +32,6 @@ 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 0e28cfd..a6caea9 100755
--- a/web/nms.gathering.org/api/public/switch-state
+++ b/web/nms.gathering.org/api/public/switch-state
@@ -19,6 +19,9 @@ while ( my $ref = $q->fetchrow_hashref() ) {
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 {
@@ -59,6 +62,9 @@ while ( my $ref = $q2->fetchrow_hashref() ) {
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 {
diff --git a/web/nms.gathering.org/js/nms-info-box.js b/web/nms.gathering.org/js/nms-info-box.js
index 42ed505..01bac94 100644
--- a/web/nms.gathering.org/js/nms-info-box.js
+++ b/web/nms.gathering.org/js/nms-info-box.js
@@ -742,6 +742,7 @@ nmsInfoBox._searchSmart = function(id, sw) {
return true;
}
} catch (e) {}
+ try {
if (id.match("active")) {
var limit = id;
limit = limit.replace("active>","");
@@ -749,21 +750,24 @@ nmsInfoBox._searchSmart = function(id, sw) {
limit = limit.replace("active=","");
var operator = id.replace("active","")[0];
if (limit == parseInt(limit)) {
+ var ports = parseInt(nmsData.switchstate.switches[sw].ifs.ge.live);
+ limit = parseInt(limit);
if (operator == ">" ) {
- if (nmsData.switchstate.switches[sw]['totals'].live > limit) {
+ if (ports > limit) {
return true;
}
} else if (operator == "<") {
- if (nmsData.switchstate.switches[sw]['totals'].live < limit) {
+ if (ports < limit) {
return true;
}
} else if (operator == "=") {
- if (nmsData.switchstate.switches[sw]['totals'].live == limit) {
+ if (ports == limit) {
return true;
}
}
}
}
+ } catch (e) {}
try {
if (nmsData.smanagement.switches[sw].mgmt_v4_addr.match(id)) {
return true;
diff --git a/web/stats.gathering.org/index.html b/web/stats.gathering.org/index.html
index 2a9d1f0..9455945 100644
--- a/web/stats.gathering.org/index.html
+++ b/web/stats.gathering.org/index.html
@@ -30,7 +30,8 @@
<br />
<ul id="menu">
<li><a href="http://tg16.sorlanet.net/TG16.html">Weathermap</a></li>
- <li><a href="http://tg16.sorlanet.net:3000">Live network stats</a></li>
+ <li><a href="http://live.tg16.sorlanet.net">Live network stats</a></li>
+ <li><a href="http://monitor.tg16.sorlanet.net">Switch Graphs</a></li>
</ul>
<br />