Commit bf5abb0e authored by Gary Wong's avatar Gary Wong

Update the timestamp _inside_ the main loop, not before it.

parent 7794437b
...@@ -101,9 +101,6 @@ use Interface; ...@@ -101,9 +101,6 @@ use Interface;
use Node; use Node;
use OSinfo; use OSinfo;
my $ts = time() . "000000";
my $expire = ( time() - 24 * 60 * 60 ) . "000000";
# Connect to the monitoring DB. # Connect to the monitoring DB.
my $db = emdbi::NewTBDBHandle( "monitoring" ); my $db = emdbi::NewTBDBHandle( "monitoring" );
my $tbdb = emdbi::NewTBDBHandle( $DBNAME ); my $tbdb = emdbi::NewTBDBHandle( $DBNAME );
...@@ -138,7 +135,7 @@ $SIG{HUP} = \&handler; ...@@ -138,7 +135,7 @@ $SIG{HUP} = \&handler;
sub AddInterfaces($$) { sub AddInterfaces($$) {
my ($n, $node) = @_; my ($n, $node, $ts) = @_;
my @interfaces; my @interfaces;
Interface->LookupAll( $node, \@interfaces ); Interface->LookupAll( $node, \@interfaces );
...@@ -180,6 +177,9 @@ sub AddInterfaces($$) { ...@@ -180,6 +177,9 @@ sub AddInterfaces($$) {
my %portcounters; my %portcounters;
while (1) { while (1) {
my $ts = time() . "000000";
my $expire = ( time() - 24 * 60 * 60 ) . "000000";
# Add the local CM. # Add the local CM.
emdbi::DBQueryWarnN( $db, "DELETE FROM ops_aggregate WHERE ts < $expire" ); emdbi::DBQueryWarnN( $db, "DELETE FROM ops_aggregate WHERE ts < $expire" );
emdbi::DBQueryWarnN( $db, "INSERT INTO ops_aggregate SET " . emdbi::DBQueryWarnN( $db, "INSERT INTO ops_aggregate SET " .
...@@ -229,7 +229,7 @@ while (1) { ...@@ -229,7 +229,7 @@ while (1) {
"urn='urn:publicid:IDN+$DOMAIN+node+$n'," . "urn='urn:publicid:IDN+$DOMAIN+node+$n'," .
"selfRef='$URL/info/node/${DOMAIN}_node_$n'" ); "selfRef='$URL/info/node/${DOMAIN}_node_$n'" );
AddInterfaces( $n, $node ); AddInterfaces( $n, $node, $ts );
} }
my @fakenodenames = (); my @fakenodenames = ();
...@@ -256,7 +256,7 @@ while (1) { ...@@ -256,7 +256,7 @@ while (1) {
"urn='urn:publicid:IDN+$DOMAIN+node+$n'," . "urn='urn:publicid:IDN+$DOMAIN+node+$n'," .
"selfRef='$URL/info/node/${DOMAIN}_node_$n'" ); "selfRef='$URL/info/node/${DOMAIN}_node_$n'" );
AddInterfaces( $n, $node ); AddInterfaces( $n, $node, $ts );
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment