Error in log: Error discovering services module

Hello,

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
Database Schema 2021_11_17_105321_device_add_display_field (226)
Web Server Apache/2.4.37 (rocky)
PHP 7.3.20
Python 3.6.8
MySQL 10.6.5-MariaDB
Laravel 8.65.0
RRDtool 1.7.0
1 Like

Same error is now happening with latest update:

[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 = ?))

====================================

Component Version
LibreNMS 21.11.0-69-ga04642088
DB Schema 2021_11_29_165436_improve_ports_search_index (229)
PHP 7.3.20
Python 3.6.8
MySQL 10.6.5-MariaDB
RRDTool 1.7.0
SNMP 5.8
====================================

[OK] Composer Version: 2.1.14
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct

1 Like

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

1 Like

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 :slight_smile:

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:

#0 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Connection.php(663): Illuminate\Database\Connection->runQueryCallback('select * from `...', Array, Object(Closure))
#1 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Connection.php(367): Illuminate\Database\Connection->run('select * from `...', Array, Object(Closure))
#2 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2351): Illuminate\Database\Connection->select('select * from `...', Array, true)
#3 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2339): Illuminate\Database\Query\Builder->runSelect()
#4 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2873): Illuminate\Database\Query\Builder->Illuminate\Database\Query\{closure}()
#5 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2340): Illuminate\Database\Query\Builder->onceWithColumns(Array, Object(Closure))
#6 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(615): Illuminate\Database\Query\Builder->get(Array)
#7 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(599): Illuminate\Database\Eloquent\Builder->getModels(Array)
#8 /opt/librenms/app/Http/Controllers/ServiceTemplateController.php(324): Illuminate\Database\Eloquent\Builder->get()
#9 /opt/librenms/app/Http/Controllers/ServiceTemplateController.php(305): App\Http\Controllers\ServiceTemplateController->apply(Object(App\Models\ServiceTemplate))
#10 /opt/librenms/includes/discovery/services.inc.php(7): App\Http\Controllers\ServiceTemplateController->applyAll()
#11 /opt/librenms/includes/discovery/functions.inc.php(157): include('/opt/librenms/i...')
#12 /opt/librenms/discovery.php(118): discover_device(Array, true)
#13 {main}  
1 Like

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 = ?))

1 Like

Are there any more updates to this?

1 Like

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.

2 Likes

LibreNMS increased error reporting recently. So likely this “issue” has been there for MUCH longer without any ill effects. Just now it is visible.

Would be happy to see someone contribute a cleanup to avoid the error message.

2 Likes

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”.

4 Likes

I have same error. :frowning:

1 Like

What are the effects of the bug? If the error message was not there would you know it exists?

I’m not saying it shouldn’t be fixed, just trying to get an idea of the impact.

1 Like

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:

librenms@host:~/logs$ zgrep -c 'Error discovering services module' librenms.log*
librenms.log:756
librenms.log.1:3019
librenms.log.2.gz:2993
librenms.log.3.gz:2976
librenms.log.4.gz:2994
librenms.log.5.gz:2997
librenms.log.6.gz:2990
librenms@host:~/logs$

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.

1 Like

Bump: Error still showing up in Web Portal, with latest updates:

[librenms@librenms ~]$ ./validate.php

Component Version
LibreNMS 22.3.0-3-g9c127bfd4
DB Schema 2022_02_03_164059_increase_auth_id_length (235)
PHP 7.3.20
Python 3.6.8
MySQL 10.6.7-MariaDB
RRDTool 1.7.0
SNMP 5.8

====================================

[OK] Composer Version: 2.2.9
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct
[librenms@librenms ~]$

1 Like

[librenms@librenms logs]$ zgrep -c ‘Error discovering services module’ librenms.log*
librenms.log:110
librenms.log-20220213.gz:560
librenms.log-20220222.gz:480
librenms.log-20220227.gz:373
librenms.log-20220306.gz:610
librenms.log-20220313.gz:620
librenms.log-20220320:616

1 Like

bump:
./validate.php

Component Version
LibreNMS 22.3.0-50-g9c126572a
DB Schema 2022_04_08_085504_isis_adjacencies_table_add_index (236)
PHP 7.3.20
Python 3.6.8
MySQL 10.6.7-MariaDB
RRDTool 1.7.0
SNMP 5.8

====================================

[OK] Composer Version: 2.3.5
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct
[librenms@librenms ~]$ cd logs/
[librenms@librenms logs]$ zgrep -c ‘Error discovering services module’ librenms.log*
librenms.log:240
librenms.log-20220313.gz:620
librenms.log-20220320.gz:616
librenms.log-20220327.gz:631
librenms.log-20220403.gz:647
librenms.log-20220410.gz:645
librenms.log-20220417:670
[librenms@librenms logs]$

1 Like

I too am having this error on all my polled devices.

2 Likes

Still having the problem:

[librenms@librenms logs]$ zgrep -c ‘Error discovering services module’ librenms.log*
librenms.log:297
librenms.log-20220417.gz:670
librenms.log-20220502.gz:505
librenms.log-20220508.gz:568
librenms.log-20220515.gz:709
librenms.log-20220522.gz:746
librenms.log-20220529:757

[librenms@librenms ~]$ ./validate.php

Component Version
LibreNMS 22.5.0-14-g32f1ce494
DB Schema 2022_05_25_090027_drop_widgets_table (241)
PHP 7.3.20
Python 3.6.8
MySQL 10.8.3-MariaDB
RRDTool 1.7.0
SNMP 5.8

====================================

[OK] Composer Version: 2.3.5
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct

1 Like

Hey, I upgraded yesterday to 22.5.0 and I have the same issue, it even gets in the event logs.

Here’s my validate.php output :

[librenms@lnms01~]$ ./validate.php

====================================
Component | Version
--------- | -------
LibreNMS  | 22.5.0
DB Schema | 2022_04_08_085504_isis_adjacencies_table_add_index (236)
PHP       | 7.3.20
Python    | 3.6.8
MySQL     | 10.3.28-MariaDB
RRDTool   | 1.7.0
SNMP      | 5.8
====================================

[OK]    Composer Version: 2.3.5
[OK]    Dependencies up-to-date.
[OK]    Database connection successful
[OK]    Database schema correct

Thanks.

3 Likes

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.

1 Like

@Peter_Hess Did the error stop throwing once you reinstalled fresh?

1 Like