@cryptotaxi247 / netdata-1 / commits / ea485bed7

SQL Chain (Windows.plugin) (#21582)

thiagoftsm committed Jan 16, 2026 at 19:21 UTC ea485bed72e5992fd18a25515c2fe9a3d98bf261
3 files changed +14 -2
src/collectors/windows.plugin/MonitorSQL.c
+9 -2
@@ -1352,14 +1352,13 @@ void dict_mssql_insert_jobs_cb(const DICTIONARY_ITEM *item __maybe_unused, void
1352 // Options
1353 void netdata_mount_mssql_connection_string(struct netdata_mssql_conn *dbInput)
1354 {
1355 - SQLCHAR conn[1024];
1355 + SQLCHAR conn[2048];
1356 const char *serverAddress;
1357 const char *serverAddressArg;
1358 if (unlikely(!dbInput)) {
1359 return;
1360 }
1361
1362 - char auth[512];
1362 if (likely(dbInput->server && dbInput->address)) {
1363 nd_log(
1364 NDLS_COLLECTORS,
@@ -1377,6 +1376,7 @@ void netdata_mount_mssql_connection_string(struct netdata_mssql_conn *dbInput)
1376 serverAddress = dbInput->address;
1377 }
1378
1379 + char auth[1024];
1380 if (likely(dbInput->windows_auth))
1381 snprintfz(auth, sizeof(auth) - 1, "Trusted_Connection = yes");
1382 else if (unlikely(!dbInput->username || !dbInput->password)) {
@@ -1390,6 +1390,11 @@ void netdata_mount_mssql_connection_string(struct netdata_mssql_conn *dbInput)
1390 snprintfz(auth, sizeof(auth) - 1, "UID=%s;PWD=%s;", dbInput->username, dbInput->password);
1391 }
1392
1393 + if (likely(dbInput->trust_server_certificate)) {
1394 + size_t length = strlen(auth);
1395 + snprintfz(&auth[length], sizeof(auth) - length, ";TrustServerCertificate=True;");
1396 + }
1397 +
1398 snprintfz(
1399 (char *)conn, sizeof(conn) - 1, "Driver={%s};%s=%s;%s", dbInput->driver, serverAddress, serverAddressArg, auth);
1400 dbInput->connectionString = (SQLCHAR *)strdupz((char *)conn);
@@ -1457,6 +1462,8 @@ static void netdata_read_config_options()
1462 dbconn->collect_blocked_processes =
1463 inicfg_get_boolean(&netdata_config, section_name, "collect blocked processes", true);
1464 dbconn->is_connected = FALSE;
1465 + dbconn->trust_server_certificate = inicfg_get_boolean(&netdata_config, section_name, "trust server certificate",
1466 + true);
1467
1468 netdata_mount_mssql_connection_string(dbconn);
1469 }
src/collectors/windows.plugin/metadata.yaml
+4
@@ -2255,6 +2255,10 @@ modules:
2255 description: Set to yes to use Windows credentials instead of SQL Server authentication.
2256 default_value: no
2257 required: false
2258 + - name: trust server certificate
2259 + description: Set to yes to trust the server's SSL certificate chain.
2260 + default_value: yes
2261 + required: false
2262 - name: express
2263 description: Set to yes when running SQL Express version.
2264 default_value: no
src/collectors/windows.plugin/perflib-mssql-queries.h
+1
@@ -656,6 +656,7 @@ struct netdata_mssql_conn {
656 const char *password;
657 int instances;
658 bool windows_auth;
659 + bool trust_server_certificate;
660 bool is_sqlexpress;
661
662 SQLCHAR *connectionString;