Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 7 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: '1.22'
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
- name: Build
run: make commit
12 changes: 8 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ jobs:
name: "Tagged Release"
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: '1.22'
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
- name: Build
run: make commit
- name: Automatic Releases
uses: marvinpinto/action-automatic-releases@v1.2.0
uses: marvinpinto/action-automatic-releases@v1.2.1
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
Expand Down
21 changes: 8 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
GITCOMMIT := $(shell git rev-parse --short HEAD 2>/dev/null)
GIT_TAG := $(shell git describe --tags 2>/dev/null)

LDFLAGS := -s -w -X github.com/tomcz/openldap_exporter.commit=${GITCOMMIT}
LDFLAGS := ${LDFLAGS} -X github.com/tomcz/openldap_exporter.tag=${GIT_TAG}
LDFLAGS := -s -w -X main.commit=${GITCOMMIT}
LDFLAGS := ${LDFLAGS} -X main.tag=${GIT_TAG}
OUTFILE ?= openldap_exporter

.PHONY: precommit
precommit: clean format lint compile

.PHONY: build
build: clean compile

.PHONY: commit
commit: clean cross-compile
ls -lha target/
Expand All @@ -21,23 +24,15 @@ target:

.PHONY: format
format:
ifeq (, $(shell which goimports))
go install golang.org/x/tools/cmd/goimports@latest
endif
@echo "Running goimports ..."
@goimports -w -local github.com/tomcz/openldap_exporter $(shell find . -type f -name '*.go' | grep -v '/vendor/')
goimports -w main.go

.PHONY: lint
lint:
ifeq (, $(shell which staticcheck))
go install honnef.co/go/tools/cmd/staticcheck@latest
endif
@echo "Running staticcheck ..."
@staticcheck $(shell go list ./... | grep -v /vendor/)
golangci-lint run

.PHONY: compile
compile: target
go build -ldflags "${LDFLAGS}" -o target/${OUTFILE} ./cmd/openldap_exporter/...
go build -ldflags "${LDFLAGS}" -o target/${OUTFILE} main.go
gzip -c < target/${OUTFILE} > target/${OUTFILE}.gz

.PHONY: cross-compile
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ _slapd_ supports an optional LDAP monitoring interface you can use to obtain inf

To enable the backend add the following to the bottom of your `slapd.conf` file:

```
```ldif
database monitor
rootdn "cn=monitoring,cn=Monitor"
rootpw YOUR_MONITORING_ROOT_PASSWORD
Expand All @@ -20,13 +20,13 @@ Technically you don't need `rootdn` or `rootpw`, but having unauthenticated acce

You may need to also load the monitoring backend module if your _slapd_ installation needs to load backends as modules by adding this to your `slapd.conf`:

```
```ldif
moduleload back_monitor
```

Once you've built the exporter (see below), or downloaded the [latest release](https://github.com/tomcz/openldap_exporter/releases), you can install it on the same server as your _slapd_ instance, and run it as a service. You can then configure Prometheus to pull metrics from the exporter's `/metrics` endpoint on port 9330, and check to see that it is working via curl:

```
```sh
$> curl -s http://localhost:9330/metrics
...
# HELP openldap_monitor_counter_object cn=Monitor (objectClass=monitorCounterObject) monitorCounter
Expand Down Expand Up @@ -79,7 +79,7 @@ The precedence of these configuration sources is as follows (from the highest to
3. YAML configuration file parameters
4. Default values

```
```sh
NAME:
openldap_exporter - Export OpenLDAP metrics to Prometheus

Expand Down Expand Up @@ -107,7 +107,7 @@ GLOBAL OPTIONS:

Example:

```
```sh
INTERVAL=10s /usr/sbin/openldap_exporter --promAddr ":8080" --config /etc/slapd/exporter.yaml
```

Expand All @@ -126,5 +126,5 @@ NOTES:

## Build

1. Install Go 1.18 from https://golang.org/
1. Install Go 1.22 from https://golang.org/
2. Build the binaries: `make build`
169 changes: 0 additions & 169 deletions cmd/openldap_exporter/main.go

This file was deleted.

17 changes: 9 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
module github.com/tomcz/openldap_exporter
module github.com/tomcz/openldap_exporter/v2

go 1.18
go 1.22

require (
github.com/go-kit/log v0.2.0
github.com/prometheus/client_golang v1.12.1
github.com/prometheus/exporter-toolkit v0.7.3
github.com/sirupsen/logrus v1.8.1
github.com/tomcz/gotools v0.4.3
github.com/urfave/cli/v2 v2.4.0
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
gopkg.in/ldap.v2 v2.5.1
)

Expand All @@ -27,11 +26,13 @@ require (
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
golang.org/x/crypto v0.0.0-20210915214749-c084706c2272 // indirect
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/exp v0.0.0-20221114191408-850992195362 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c // indirect
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/asn1-ber.v1 v1.5.4 // indirect
Expand Down
Loading