This started happening on 11/24/2021 when polling a server: “Error discovering services module. Check log file for more details.” In the I do not see anything in daily.log or discovery_wrapper… In librenms.log, i see the following sql message:
[2021-11-26T18:35:35.105509-05:00] production.ERROR: Error discovering services module for console.america.local. SQLSTATE[HY093]: Invalid parameter number (SQL: select * from devices where devices.device_id not in (select device_id from service_templates_device where service_template_id = 1) and devices.device_id not in (select device_id from device_group_device where device_group_id = ?))
My setup is as follows:
Version
21.11.0-46-g99fbdeef0 - Fri Nov 26 2021 12:54:29 GMT-0500
[2021-12-07T18:34:21.611843-05:00] production.ERROR: Error discovering services module for console.america.local. SQLSTATE[HY093]: Invalid parameter number (SQL: select * from devices whe
re devices.device_id not in (select device_id from service_templates_device where service_template_id = 1) and devices.device_id not in (select device_id from device_group_ device where device_group_id = ?))
The error when I dump the sql command in mariadb is as follows:
MariaDB [librenms]> select * from devices where devices.device_id not in (select device_id from service_templates_device where service_template_id = 1) and devices.device_id not in (select device_id from device_group_device where device_group_id = ?);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘?)’ at line 1
Same problem here. If I see that correctly, it’s the wrong number of arguments. At the end of ./app/Models/ServiceTemplate.php there’s a BelongsToMany function for service_templates_device but that one has three arguments while the sql query string only has one question mark.
Not sure if I’m right, though
librenms.log:[2021-12-14T08:02:16.652864+01:00] production.ERROR:
Error discovering services module for hostname.domain.tld.
SQLSTATE[HY093]: Invalid parameter number
(SQL: select * from `devices` where `devices`.`device_id` not in
(select `device_id` from `service_templates_device`
where `service_template_id` = 1)
and `devices`.`device_id` not in
(select `device_id` from `device_group_device`
where `device_group_id` = ?))
[reformatted for better readability]
When calling the module on the commandline (e.g. ./discovery.php -h hostname.domain.tld -m services -d -v), this is the stack trace:
Glad to see I’m not the only one having this problem…
SQL[select * from service_templates [] 1.31ms]
SQL[select * from devices where devices.device_id in (select device_id from service_templates_device where service_template_id = ?) [
1] 1.44ms]
SQL[select * from services where services.device_id = ? and services.device_id is not null and (service_template_id = ?) limit 1 [2,1
] 0.77ms]
SQL[select * from services where services.device_id = ? and services.device_id is not null and (service_template_id = ?) limit 1 [6,1
] 0.7ms]
SQL[select * from device_groups where device_groups.id in (select device_group_id from service_templates_device_group where service_template _id = ?) [1] 0.98ms]
SQL[select device_groups.*, service_templates_device_group.service_template_id as pivot_service_template_id, service_templates_device_group. device_group_id as pivot_device_group_id from device_groups inner join service_templates_device_group on device_groups.id = service_templates_dev ice_group.device_group_id where service_templates_device_group.service_template_id = ? [1] 1.13ms]
Error discovering services module for console.america.local. SQLSTATE[HY093]: Invalid parameter number (SQL: select * from devices where devices
.device_id not in (select device_id from service_templates_device where service_template_id = 1) and devices.device_id not in (select device_id
from device_group_device where device_group_id = ?))
Doesn’t seem so. I’m quite confused that such a bug keeps present for months. I got a private message from a team member some days ago stating that they identified this as a bug, but I don’t know why that’s not been stated in this ticket. Also, I requested that this ticket is moved from help into bugreports where it belongs, but this has also not been done yet.
Well, critical or non-critical bug, either way the first thing should be moving this ticket from help to bugreports to get enough attention from people that are able to identify and fix the bug. I would fix it by myself if I had appropriate skills and knowledge of the librenms code, but the only thing I can do is to try to convince someone to agree with me that this is actually a bug and not just an “issue”.
I don’t get what you’re trying to mean, @murrant. There are several posts in this ticket that contain the error message, like this one for example. This is also present in the “autodiscovery log” widget on the dashboard. And it’s not occationally, like the counts say:
oh, wait, I think I get what you ask… No, if the error message would not be there, I would not notice this problem. Which comes from the fact that I have no clue what this “services module” does, so I have no idea what to check. I don’t know if somethings missing within my librenms data as long as I don’t know what the services module is used for.
Not solved, and the upgrade to php 8.1 killed my installation. Rather than troubleshoot that, I started from fresh with a new installation. I’m slowly getting my setup back in order.