Closed NetItUp-FrancescoPasqualatto closed 1 year ago
Hi @NetItUp-FrancescoPasqualatto
your inventory task task is based on IPRange or on asset ?
I've tried both approaches but the result is the same: with glpi-injector the inventory is imported(or with changes on the ip table).
Hi @NetItUp-FrancescoPasqualatto have you checked the glpi-agent log to see which ip it finally uses during netinventory ? Just to be sure what ip was sent by the plugin.
Yes, this is part of the log that prove my point:
from IPRange
target I can easily check the list of IPs
and only (first) use the one that corresponds to the IPRange
from Asset
target i can't compare with IPRange
(logic !)
At one point we tried to keep a record of the IP that responded to the SNMP discovery, but it was much more complex than we expected.
Can you try this (try only with IPRAnge
target)
https://github.com/glpi-project/glpi-inventory-plugin/pull/416
with your code it gave me: Error "device has no ip": [debug] WakeOnLan task execution not requested [error] invalid device: no address defined [error] invalid job: no valid device defined [error] no valid job found, aborting
Once I have programmed this bad code:
$ip_a = PluginGlpiinventoryToolbox::getIPforDevice( $jobstate->fields['itemtype'], $jobstate->fields['items_id'] ); $ip = ''; if(count($ip_a) > 1) { $ip1 = current($ip_a); $ip2 = next($ip_a); if($ip2 != '') { $ip = $ip2; } else { $ip = $ip1; } } else { $ip = current($ip_a); }
It update everything but works only if the snmp address is in the second place. (I don't know if it can be useful)
Are you sure you tested with an IPRAnge?
It seems not, I've adjusted the PR to keep the same behaviour as now (first IP is used) when the target is an Asset
I've used IPRange as target for the task...
Can you run this SQL query and past here the result
SELECT * FROM glpi_plugin_glpiinventory_taskjobstates WHERE plugin_glpiinventory_taskjobs_id = ID_OF_TASK
I've used the id of the IPRange task.
You should look at my last comment on #416 . I guess there was a mistake in the proposal.
The problem is that an SNMP inventory task creates a job for each asset (and not a job with the IP Range).
So I can't check the IP from Range
I don't know if I can do any better.
Since I can't compare the asset IPs with the IPRange and since we don't keep the contact IP, it's impossible for me to deduce the correct IP.
Perhaps you could add unwanted IPs to the black list to prevent them from being back
What If we try all Ip address? or keep the contact IP in a new field?
What If we try all Ip address?
When Agent want a JOB configuration plugin return one IP (and XML body have only one IP node)
keep the contact IP in a new field
It's going to take a lot of effort for a single reported issue
@NetItUp-FrancescoPasqualatto And to amend @stonebuzz comment, we will probably rewrite that code in a near future, mayby making it native to glpi. So we don't want to pass too much time on this legacy code. Indeed, identifying such problem can just help us to start the rewrite earlier than actually expected.
Ok, thanks. I understand that there isn't a quick solution to this problem. I think it should be pretty common because it's easy to have IP addresses in the wrong order.
Perhaps you could add unwanted IPs to the black list to prevent them from being back
Should solved this issue.
not being able to go any further for the moment I take the liberty of closing this issue
Best regards
Describe the bug
Hi, I've found a bug that when you run an inventory task on known snmp device, it will use the first IP address in the alphabetical order in the ip address table(it may not be the same address used for the snmp discovery).
To reproduce
Expected behavior
It import inventory information for the device.
Operating system
Windows, Linux
GLPI Agent version
1.5, 1.4
GLPI version
10.0.9, 10.0.7
GLPIInventory plugin
1.2.3
Additional context
I've found it with many devices but I'll use Synolgy as an example. When I run the inventory task and force inventory I see this and the device entry don't update with inventory information; If you go on network ports tab you can see that the first ip address is not the one used for snmp(and if I remove that the inventory works fine): I also checked this by packet capture: