compiliere den prometheus oracledb-exporter

to get a oracle db exporter for prometheus running on windows 64bit.

prepare

oracle insta client

c++ compiler

  • download https://www.msys2.org/

  • install msys2-x86_64-20220503.exe

  • run pacman -S mingw64/mingw-w64-x86_64-pkg-config mingw64/mingw-w64-x86_64-

C:\msys64\mingw64\lib\pkgconfig\oci8.pc
prefix=C:\_data\projects\oracle-exporter\instantclient_21_3/sdk
version=21.3
build=client64
libdir=C:/_data/projects/oracle-exporter/instantclient_21_3/sdk/lib/msvc
includedir=C:/_data/projects/oracle-exporter/instantclient_21_3/sdk/include
glib_genmarshal=glib-genmarshal
gobject_query=gobject-query
glib_mkenums=glib-mkenums
Name: oci8
Description: Oracle database engine
Version: ${version}
Libs: -L${libdir} -loci
Libs.private:
Cflags: -I${includedir}

experiment with front and backslashes where needed.

go environment

  • download https://go.dev/dl/

  • install go1.13.15.windows-amd64.msi (go1.18.2 did not work, faults on run)

compile

setx CGO_CFLAGS "C:/_data/projects/oracle-exporter/instantclient_21_3/sdk/include"
setx CGO_LDFLAGS "-LC:/_data/projects/oracle-exporter/instantclient_21_3 -loci"
setx PKG_CONFIG_PATH "C:/msys64/mingw64/lib/pkgconfig"
setx path "%path%;C:\msys64\mingw64\bin"

check configuration:

pkg-config --cflags --libs oci8

build binary:

go build ./...

use

use oracledb_exporter.exe and default-metrics.toml lumped together with insta-client in one directory.

>set DATA_SOURCE_NAME=usr/pw@//host:port/instance
>oracledb_exporter.exe --web.listen-address 0.0.0.0:9333

INFO[0000] Starting oracledb_exporter 0.0.0.dev          source="main.go:588"
INFO[0000] Successfully loaded default metrics from: default-metrics.toml  source="main.go:563"
INFO[0000] No custom metrics defined.                    source="main.go:578"
INFO[0000] Listening on 0.0.0.0:9333                     source="main.go:625"