- my $self = shift;
- my $router = shift;
- my $find_serviceid = shift;
- my $found_serviceid = 0;
- my $ddx_hash = $self->ddx2hash;
- if($ddx_hash->{host}){
- my @hosts = @{$ddx_hash->{host}};
- foreach my $host ( @hosts ) {
- my $param = $host->{param};
- if($param && $param->{'snmp-host'}
- && (!$router || $param->{'snmp-host'}->{'value'} eq $router)
- && $param->{'RFC2863_IF_MIB::external-serviceid'}) {
- my $serviceids = $param->{'RFC2863_IF_MIB::external-serviceid'}->{'content'};
- my %hash = ();
- if($serviceids) {
- my @serviceids = split(',',$serviceids);
- foreach my $serviceid ( @serviceids ) {
- $serviceid =~ s/^\s+|\s+$//g;
- my @s = split(':',$serviceid);
- next unless scalar(@s) == 4;
- $hash{$s[1]} = $s[0] if $router;
- if ($find_serviceid && $find_serviceid eq $s[0]) {
- $hash{$param->{'snmp-host'}->{'value'}} = $s[1];
- $found_serviceid = 1;
- }
- }
- }
- return \%hash if ($router || $found_serviceid);
- }
- }
+ my $self = shift;
+ my $router = shift;
+ my $find_serviceid = shift;
+ my $found_serviceid = 0;
+ my $ddx_hash = $self->ddx2hash;
+ return '' unless $ddx_hash->{'host'};
+
+ my @hosts = @{$ddx_hash->{host}};
+ foreach my $host ( @hosts ) {
+ my $param = $host->{param};
+ if($param && $param->{'snmp-host'}
+ && (!$router || $param->{'snmp-host'}->{'value'} eq $router)
+ && $param->{'RFC2863_IF_MIB::external-serviceid'}) {
+ my $serviceids =
+ $param->{'RFC2863_IF_MIB::external-serviceid'}->{'content'};
+ my %hash = ();
+ if ($serviceids) {
+ my @serviceids = split(',',$serviceids);
+ foreach my $serviceid ( @serviceids ) {
+ $serviceid =~ s/^\s+|\s+$//g;
+ my @s = split(':',$serviceid);
+ next unless scalar(@s) == 4;
+ $hash{$s[1]} = $s[0] if $router;
+ if ($find_serviceid && $find_serviceid eq $s[0]) {
+ $hash{$param->{'snmp-host'}->{'value'}} = $s[1];
+ $found_serviceid = 1;
+ }
+ }
+ }
+ return \%hash if ($router || $found_serviceid);
+ }
+ }
+ '';
+}
+
+#false laziness and probably should be merged w/above, but didn't want to mess
+# that up
+sub all_router_serviceids {
+ my $self = shift;
+ my $ddx_hash = $self->ddx2hash;
+ return () unless $ddx_hash->{'host'};
+
+ my %hash = ();
+ my @hosts = @{$ddx_hash->{host}};
+ foreach my $host ( @hosts ) {
+ my $param = $host->{param};
+ if($param && $param->{'snmp-host'}
+ && $param->{'RFC2863_IF_MIB::external-serviceid'}) {
+ my $serviceids =
+ $param->{'RFC2863_IF_MIB::external-serviceid'}->{'content'};
+ if ($serviceids) {
+ my @serviceids = split(',',$serviceids);
+ foreach my $serviceid ( @serviceids ) {
+ $serviceid =~ s/^\s+|\s+$//g;
+ my @s = split(':',$serviceid);
+ next unless scalar(@s) == 4;
+ $hash{$s[0]}=1;
+ }
+ }