From a076375cc886d97ccc50cd150158baf5cdd88b27 Mon Sep 17 00:00:00 2001 From: Mir Ansar Date: Thu, 14 Mar 2024 22:24:54 +0530 Subject: [PATCH] Added support for SAP Sybase Database. (#463) --- examples/sybase-database-example.yml | 19 +++++++++++++++++++ go.mod | 4 ++++ go.sum | 9 +++++++++ internal/inputs/database.go | 3 +++ internal/inputs/database_test.go | 1 + internal/load/load.go | 1 + 6 files changed, 37 insertions(+) create mode 100644 examples/sybase-database-example.yml diff --git a/examples/sybase-database-example.yml b/examples/sybase-database-example.yml new file mode 100644 index 00000000..6e30cd6f --- /dev/null +++ b/examples/sybase-database-example.yml @@ -0,0 +1,19 @@ +# NOTE: 'database' is an experimental API at this time +# ref: https://github.com/newrelic/nri-flex/blob/master/docs/experimental/db.md +--- +integrations: + - name: nri-flex + # interval: 30s + config: + name: sybaseDbFlex + apis: + - database: sybase + db_conn: ase://user:pass@host:port/ + logging: + open: true + custom_attributes: # applies to all queries + host: myDbServer + db_async: true # process queries async + db_queries: + - name: sybaseExample + run: select * from data diff --git a/go.mod b/go.mod index db065596..246729b8 100644 --- a/go.mod +++ b/go.mod @@ -40,6 +40,8 @@ require ( github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect + github.com/SAP/go-ase v0.0.0-20230911093826-e06baafeece3 // indirect + github.com/SAP/go-dblib v0.0.0-20220825075032-c1f3f4d6e7b3 // indirect github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 // indirect github.com/bitly/go-simplejson v0.5.0 // indirect github.com/cloudflare/circl v1.3.7 // indirect @@ -60,6 +62,8 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.6.0 // indirect + github.com/hashicorp/errwrap v1.1.0 // indirect + github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/itchyny/timefmt-go v0.1.5 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect diff --git a/go.sum b/go.sum index d906d176..60a91d52 100644 --- a/go.sum +++ b/go.sum @@ -54,6 +54,10 @@ github.com/MonetDB/MonetDB-Go v1.0.2 h1:ovqY//8De9OzoJJbc1YkW4peNfGdLTgQhjc+fhBr github.com/MonetDB/MonetDB-Go v1.0.2/go.mod h1:camniXrjGJnMoXXgZWhUY+2nKPVfjKmcA5mmrjuV2+A= github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg= github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= +github.com/SAP/go-ase v0.0.0-20230911093826-e06baafeece3 h1:S2BdRIWytdt7gHV+39ZC9Fl8PbQlhlnWmBfQTy7iSUg= +github.com/SAP/go-ase v0.0.0-20230911093826-e06baafeece3/go.mod h1:RJNsL+XbiV4Ux3aTLlk5WIQy6kq6VW7OvAasNkq3j4U= +github.com/SAP/go-dblib v0.0.0-20220825075032-c1f3f4d6e7b3 h1:bX6dkWrQMTAO8IwVGZqXoNdWjZVQ3YnRU01p+x4X+Jw= +github.com/SAP/go-dblib v0.0.0-20220825075032-c1f3f4d6e7b3/go.mod h1:pyB1BEipxjxMcCYlymW+x6sgucc0N45V7LVPUnpDr/I= github.com/SAP/go-hdb v0.107.3 h1:tX7CI+fsUFVNzR9LIAuX1mzyzRtuMiUkvuVVUgNSGss= github.com/SAP/go-hdb v0.107.3/go.mod h1:EAlLPK5So38imnv2/aBADHZBjl76RVIWvu9Tkiu6LbY= github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 h1:MzBOUgng9orim59UnfUTLRjMpd09C5uEVQ6RPGeCaVI= @@ -199,6 +203,11 @@ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5m github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= +github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= +github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= diff --git a/internal/inputs/database.go b/internal/inputs/database.go index bdd2ae0c..a1bddabe 100644 --- a/internal/inputs/database.go +++ b/internal/inputs/database.go @@ -25,6 +25,7 @@ import ( //Database Drivers _ "github.com/MonetDB/MonetDB-Go/src" //MonetDB + _ "github.com/SAP/go-ase" //Sybase _ "github.com/SAP/go-hdb/driver" //SAP HANA _ "github.com/denisenkom/go-mssqldb" //mssql | sql-server _ "github.com/go-sql-driver/mysql" //mysql @@ -227,6 +228,8 @@ func setDatabaseDriver(database, driver string, yml *load.Config, api load.API) return load.DefaultMySQL case "oracle": return load.DefaultOracle + case "sybase": + return load.DefaultSybase case "monetdb": return load.DefaultMonetDB case "hana", "go-hdb", "hdb": diff --git a/internal/inputs/database_test.go b/internal/inputs/database_test.go index c69cc2f2..3873b7f5 100644 --- a/internal/inputs/database_test.go +++ b/internal/inputs/database_test.go @@ -26,6 +26,7 @@ func TestDrivers(t *testing.T) { "mariadb": load.DefaultMySQL, "hana": load.DefaultHANA, "oracle": load.DefaultOracle, + "ase": load.DefaultSybase, "monetdb": load.DefaultMonetDB, "unknown": "", } diff --git a/internal/load/load.go b/internal/load/load.go index 7174678c..d47d39c8 100644 --- a/internal/load/load.go +++ b/internal/load/load.go @@ -115,6 +115,7 @@ const ( DefaultMSSQLServer = "sqlserver" DefaultMySQL = "mysql" DefaultOracle = "oracle" + DefaultSybase = "ase" DefaultMonetDB = "monetdb" DefaultVertica = "vertica" DefaultJmxHost = "127.0.0.1"