Hello,
Trying to move from fusioninventory (FI) to OCS. I used FI to add custom softwares to the agent report. Trying to do the same with OCS.
So I wrote a plugin, starting from the Example.pm plugin. Here's the inventory_handler function :
sub freepbx_inventory_handler { #Use this hook to add or modify entries in the inventory XML
my $self = shift;
my $logger = $self->{logger};
$logger->debug("Yeah you are in freepbx_inventory_handler :)");
my $json = JSON->new->utf8->boolean_values(0, 1); # false → 0, true → 1
# JSON string
my $json_text = `/usr/sbin/fwconsole ma list --format json | tail -n1`;
# Decode JSON to perl object
my $decoded = $json->decode($json_text);
my @modules;
foreach my $entry (@{$decoded->{data}}) {
push @modules, {
NAME => $entry->[0],
VERSION => $entry->[1],
PUBLISHER => $entry->[4],
FROM => 'freepbx'
};
}
my $data_for_xml = {
SOFTWARES => \@modules
};
# Convert to XML
my $xml = XMLout($data_for_xml, XMLDecl => 0, NoAttr => 1, RootName => undef);
my $xml = XMLout($data);
$logger->debug($xml);
push @{ $inventory->{xmlroot}->{'CONTENT'} },{ $xml };
}
When running this part of script standalone, it returns stuff like :
<SOFTWARES>
<FROM>freepbx</FROM>
<NAME>userman</NAME>
<PUBLISHER>Sangoma</PUBLISHER>
<VERSION>16.0.44</VERSION>
</SOFTWARES>
<SOFTWARES>
<FROM>freepbx</FROM>
<NAME>voicemail</NAME>
<PUBLISHER>Sangoma</PUBLISHER>
<VERSION>16.0.49</VERSION>
</SOFTWARES>
<SOFTWARES>
<FROM>freepbx</FROM>
<NAME>webrtc</NAME>
<PUBLISHER>Sangoma</PUBLISHER>
<VERSION>16.0.17</VERSION>
</SOFTWARES>
But when running ocsinventory-agent -l=./, I don't see this output in the generated .ocs file
What am I doing wrong ? Is there some doc somewhere ?
Regards