Forum Discussion
It does seem like Sarah's idea would work, just have to aggregate results across all devices to find datasources that have no associated device instances (except it looks like instanceNumber is the field). That said, sometimes the indication of no instances found for a DS is itself a problem and this is hard to know this within LM currently. I have a script I am working on that will evaluate what LM discovers against a template, specified by a property. This will allow detection of faulty AD logic or problems on the device itself. For example, a switch should discover interfaces, preferably all of them, but at least one. If for some reason SNMP is busted (happens due to platform issues, or in LM when a device produces too many results and discovery times out due to lack of bulkwalk support), I would want to know that and not be surprised later when the data is needed and not available.
I wrote this Perl snippet for yours, which shows the instance count for each device/datasource pair, and a final report of any datasource with no instances:
my $lmapi = WM::LMAPI->new(company => $COMPANY) or die;
my %foundanyinstances;
if (my $devices = $lmapi->get_all(path => "/device/devices", fields => "id,displayName")) {
for my $device (@$devices) {
if (my $devicedatasources = $lmapi->get_all(path => "/device/devices/$device->{id}/devicedatasources", fields => "id,dataSourceName,instanceNumber")) {
for my $devicedatasource (@$devicedatasources) {
my $dsname = $devicedatasource->{dataSourceName};
$foundanyinstances{$dsname} = 0 if not exists $foundanyinstances{$dsname};
my $numinstances = $devicedatasource->{instanceNumber};
$foundanyinstances{$dsname} = 1 if $numinstances > 0;
next if defined $MININSTANCES and $numinstances < $MININSTANCES;
next if defined $MAXINSTANCES and $numinstances > $MAXINSTANCES;
printf "%s: %s: %d\n", $device->{displayName}, $devicedatasource->{dataSourceName}, $numinstances;
}
}
}
}
for my $dsname (keys %foundanyinstances) {
print "$dsname: NO INSTANCES\n" if $foundanyinstances{$dsname} == 0;
}
65,1 Bot