aboutsummaryrefslogtreecommitdiffstats
path: root/clients
diff options
context:
space:
mode:
Diffstat (limited to 'clients')
-rwxr-xr-xclients/ping.pl30
-rwxr-xr-xclients/update-public-nms.sh12
2 files changed, 30 insertions, 12 deletions
diff --git a/clients/ping.pl b/clients/ping.pl
index 6968b4d..b41febd 100755
--- a/clients/ping.pl
+++ b/clients/ping.pl
@@ -13,7 +13,7 @@ my $dbh = nms::db_connect();
$dbh->{AutoCommit} = 0;
$dbh->{RaiseError} = 1;
-my $q = $dbh->prepare("SELECT switch,ip FROM switches WHERE ip<>'127.0.0.1'");
+my $q = $dbh->prepare("SELECT switch,ip,secondary_ip FROM switches WHERE ip<>'127.0.0.1'");
my $lq = $dbh->prepare("SELECT linknet,addr1,addr2 FROM linknets");
while (1) {
@@ -23,11 +23,19 @@ while (1) {
$q->execute;
my %ip_to_switch = ();
+ my %secondary_ip_to_switch = ();
while (my $ref = $q->fetchrow_hashref) {
my $switch = $ref->{'switch'};
+
my $ip = $ref->{'ip'};
$ping->host_add($ip);
$ip_to_switch{$ip} = $switch;
+
+ my $secondary_ip = $ref->{'secondary_ip'};
+ if (defined($secondary_ip)) {
+ $ping->host_add($secondary_ip);
+ $secondary_ip_to_switch{$secondary_ip} = $switch;
+ }
}
my $result = $ping->ping();
die $ping->get_error if (!defined($result));
@@ -35,13 +43,23 @@ while (1) {
$dbh->do('COPY ping (switch, latency_ms) FROM STDIN'); # date is implicitly now.
while (my ($ip, $latency) = each %$result) {
my $switch = $ip_to_switch{$ip};
- if (!defined($latency)) {
- $dbh->pg_putcopydata("$switch\t\\N\n");
- } else {
- $dbh->pg_putcopydata("$switch\t$latency\n");
- }
+ next if (!defined($switch));
+
+ $latency //= "\\N";
+ $dbh->pg_putcopydata("$switch\t$latency\n");
}
$dbh->pg_putcopyend();
+
+ $dbh->do('COPY ping_secondary_ip (switch, latency_ms) FROM STDIN'); # date is implicitly now.
+ while (my ($ip, $latency) = each %$result) {
+ my $switch = $secondary_ip_to_switch{$ip};
+ next if (!defined($switch));
+
+ $latency //= "\\N";
+ $dbh->pg_putcopydata("$switch\t$latency\n");
+ }
+ $dbh->pg_putcopyend();
+
$dbh->commit;
# ping linknets
diff --git a/clients/update-public-nms.sh b/clients/update-public-nms.sh
index ed1807c..535d02d 100755
--- a/clients/update-public-nms.sh
+++ b/clients/update-public-nms.sh
@@ -1,12 +1,12 @@
#!/bin/sh
-DIR=/srv/www/nms-public.tg13.gathering.org
+DIR=/root/tgmanage/web/nms-public.gathering.org
-wget -qO$DIR/nettkart-trafikk.png.new http://nms.tg13.gathering.org/nettkart.pl
-wget -qO$DIR/nettkart-dhcp.png.new http://nms.tg13.gathering.org/dhcpkart.pl
-wget -qO$DIR/led.txt.new http://nms.tg13.gathering.org/led.pl
+wget -qO$DIR/nettkart-trafikk.png.new http://nms.tg14.gathering.org/nettkart.pl
+wget -qO$DIR/nettkart-dhcp.png.new http://nms.tg14.gathering.org/dhcpkart.pl
+wget -qO$DIR/led.txt.new http://nms.tg14.gathering.org/led.pl
mv $DIR/nettkart-trafikk.png.new $DIR/nettkart-trafikk.png
mv $DIR/nettkart-dhcp.png.new $DIR/nettkart-dhcp.png
mv $DIR/led.txt.new $DIR/led.txt
-/usr/bin/perl -i -pe 'use POSIX qw(strftime); my $timestamp = strftime("%a, %d %b %Y %H:%M:%S %z", localtime(time())); s/Sist oppdatert:.*/Sist oppdatert: $timestamp/g;' /srv/www/nms-public.tg13.gathering.org/dhcp.html
-/usr/bin/perl -i -pe 'use POSIX qw(strftime); my $timestamp = strftime("%a, %d %b %Y %H:%M:%S %z", localtime(time())); s/Sist oppdatert:.*/Sist oppdatert: $timestamp/g;' /srv/www/nms-public.tg13.gathering.org/trafikk.html
+/usr/bin/perl -i -pe 'use POSIX qw(strftime); my $timestamp = strftime("%a, %d %b %Y %H:%M:%S %z", localtime(time())); s/Sist oppdatert:.*/Sist oppdatert: $timestamp/g;' $DIR/dhcp.html
+/usr/bin/perl -i -pe 'use POSIX qw(strftime); my $timestamp = strftime("%a, %d %b %Y %H:%M:%S %z", localtime(time())); s/Sist oppdatert:.*/Sist oppdatert: $timestamp/g;' $DIR/trafikk.html