You are not logged in.
Hello,
I am currently working on a perl script, which gathers information about a connected docking station. The collected data, should be presented in the USB device section in GLPI, but I don't get it to work that way.
The perl script looks like this:
#!/bin/env perl
package FusionInventory::Agent::Task::Inventory::Win32::USB::Dock;
use Win32::OLE;
use English qw(-no_match_vars);
use strict;
use warnings;
sub isEnabled {
return 1;
}
sub doInventory {
my (%params) = @_;
my $inventory = $params{inventory};
my $dell = Win32::OLE->GetObject("winmgmts://./root/dell/sysinv")
or die "Failed getobject dell";
my $dlist, my $value;
$dlist = $dell->InstancesOf("dell_softwareidentity")
or die "Failed getobject Dell\n";
my $name, my $serial;
foreach $value (in $dlist) {
my $elementname = $value->{ElementName};
$serial = $value->{SerialNumber};
if ($elementname =~ m/(WD1[5|9]TB).*/) {
$name = $1;
print "Name: $1\%\n";
print "SerialNumber: $serial\%\n";
}
}
#Call this function to add an XML block
addDell(inventory => $inventory, entry => {
'CAPTION' => "",
'NAME' => $name,
'VENDORID' => "DELL",
'PRODUCTID' => $name,
'SERIAL' => $serial
});
}
sub addDell {
my (%params) = @_;
my $entry = $params{entry};
$params{inventory}->addEntry(section => 'USBDEVICES', entry => $entry);
}
1;
I have tried to use the package FusionInventory::Agent::Task::Inventory::Win32::USB; instead, but that also did not work.
Can you tell me, what I have to do, to push an additional USB device to GLPI?
Offline
Hi ECaricato,
first don't use Win32::OLE here, the agent provides common API to access WMI informations. Check other modules that does the same kind of request.
Indeed, you seem to use the right API to add a new USB device, even if you can merge addDell() in doInventory() as you seem to only expect one device.
If this doesn't work, I can only suspect you have an issue using Win32::OLE in place of provided APIs as this library is not thread safe and so may crash the module. You should check agent log to see if the module is run and if it fails.
Instead of using "print" for debugging, you should use "$params{logger}->debug()" and check the agent log.
Eventually can you share the output of:
wmic /NAMESPACE:\\root\\dell\\sysinv Path dell_softwareidentity Get /FORMAT:list
I'm not sure this is the right command to dump the WMI instance you're trying to analyse.
Anyway if you share it, I'll be able to also implement this support on GLPI Agent and you may be able to backport it for FI-Agent as they have the same code base.
GLPI-Agent developer from Teclib' and GLPI-Network team
Previously FusionInventory-Agent maintainer
Offline