Compare commits

..

4 Commits

Author SHA1 Message Date
a336225ac8 Add Dockerfile
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-10-27 01:12:06 +02:00
32517b4e41 fix: I forgot to start the scheduler...
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-01-08 22:53:01 +01:00
5321a86b2c feat: Update README
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-01-07 17:16:16 +01:00
1fc12339ba feat: Add CI
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-01-07 17:05:57 +01:00
4 changed files with 44 additions and 6 deletions

10
.woodpecker.yml Normal file
View File

@@ -0,0 +1,10 @@
steps:
build:
image: "golang:1.21.5-alpine"
commands:
- go build main.go
lint:
image: "golang:1.21.5-alpine"
commands:
- go fmt ./main.go
- go vet ./main.go

9
Dockerfile Normal file
View File

@@ -0,0 +1,9 @@
FROM golang@sha256:fe5bea2e1ab3ffebe0267393fea88fcb197e2dbbb1e2dbabeec6dd9ccb0e1871 AS builder
COPY . /build
WORKDIR /build
RUN go build -o cert-exporter main.go
FROM alpine@sha256:beefdbd8a1da6d2915566fde36db9db0b524eb737fc57cd1367effd16dc0d06d
COPY --from=builder /build/cert-exporter /opt/cert-exporter
ENTRYPOINT ["/opt/cert-exporter"]

View File

@@ -1,4 +1,23 @@
# certs-status-exporter # cert-status-exporter
A Prometheus exporter that checks the expiry and validity of configured domains A Prometheus exporter that checks the expiry and validity of configured domains
once a day. once a day.
## Usage
To export certificate status metrics, run `cert-status-exporter --domain <domain>:<port>:<alpn>[:<name>]`.
The format means: "Connect to `<domain>` on port `<port>` while advertising `<alpn>` as ALPN during the
TLS negotiations. If `<name>` is specified, then the metric will be labeled as `<name>`, instead of `<domain>`.
`<alpn>` is a semi-colon separated list of ALPN protocols.
By default, `cert-status-exporter` will bind to `0.0.0.0:8888` and expose the metrics at `0.0.0.0:8888/metrics`. To change
the binding address, you can specify `--host` and `--port` to change how `cert-status-exporter` binds the socket.
### Example
- `cert-status-exporter --host 127.0.0.1 --port 8383 --domain "gnu.org:443:http/1.1;http/1.0;http/0.9"`: Check the certificate of `gnu.org:443`, while presenting the HTTP ALPN protocol names during the TLS negotiation. The metrics are exported with the label `name` equal to `gnu.org`.
- `cert-status-exporter --domain "example.org:5223:xmpp-client:xmpp"`: Check the certificate of `example.org:5223`, while presenting `xmpp-client` as the ALPN protocol during the TLS negotiation. Moreover, export the certificate state with the label `name` equal to `xmpp`.
## License
See `LICENSE`.

View File

@@ -166,17 +166,17 @@ func run(ctx *cli.Context) error {
updateMetrics(&metrics, lastUpdatedMetric) updateMetrics(&metrics, lastUpdatedMetric)
}, },
), ),
gocron.WithStartAt(gocron.WithStartImmediately()),
) )
if err != nil { if err != nil {
log.Error("Failed to create periodic task") log.Error("Failed to create periodic task")
return err return err
} }
// Perform an initial run to populate the metrics // Start the scheduler
log.Info("Performing initial requests...") scheduler.Start()
updateMetrics(&metrics, lastUpdatedMetric)
log.Debug("Done")
// Handle HTTP requests
http.Handle( http.Handle(
"/metrics", promhttp.HandlerFor( "/metrics", promhttp.HandlerFor(
registry, registry,