librenms/librenms-agent

Portactivity adds all connection to the first service

dfpho opened this issue · 0 comments

dfpho commented

When using multiple services after -p, all data will be added to the first service, and the rest will stay empty

This modification seem to fix the issue

--- portactivity-org    2020-06-12 06:58:45.569904973 +0200
+++ portactivity        2020-06-15 12:08:32.306136524 +0200
@@ -269,14 +269,15 @@
                ){
                $protos_array_int=0;
                my $service;
+               undef $service;
                while(
                        ( defined( $protos_array[ $protos_array_int ] ) ) &&
                        ( !defined( $service ) ) #stop once we find it
                        ){
                        #check if this matches either ports
                        if (
-                               ( defined($proto_lookup{ $conn->{'local_port'} }) ) ||
-                               ( defined($proto_lookup{ $conn->{'foreign_port'} }) )
+                               (( defined($proto_lookup{ $conn->{'local_port'} } ) && ( $proto_lookup{ $conn->{'local_port'} } eq $protos_array[ $protos_array_int ] ))) ||
+                               (( defined($proto_lookup{ $conn->{'foreign_port'} } ) && ( $proto_lookup{ $conn->{'foreign_port'}} eq $protos_array[ $protos_array_int ] )))
                                ){
                                $service=$protos_array[ $protos_array_int ];