Compare commits
4 Commits
4ceb2023db
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| a336225ac8 | |||
| 32517b4e41 | |||
| 5321a86b2c | |||
| 1fc12339ba |
10
.woodpecker.yml
Normal file
10
.woodpecker.yml
Normal 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
9
Dockerfile
Normal 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"]
|
||||
21
README.md
21
README.md
@@ -1,4 +1,23 @@
|
||||
# certs-status-exporter
|
||||
# cert-status-exporter
|
||||
|
||||
A Prometheus exporter that checks the expiry and validity of configured domains
|
||||
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`.
|
||||
8
main.go
8
main.go
@@ -166,17 +166,17 @@ func run(ctx *cli.Context) error {
|
||||
updateMetrics(&metrics, lastUpdatedMetric)
|
||||
},
|
||||
),
|
||||
gocron.WithStartAt(gocron.WithStartImmediately()),
|
||||
)
|
||||
if err != nil {
|
||||
log.Error("Failed to create periodic task")
|
||||
return err
|
||||
}
|
||||
|
||||
// Perform an initial run to populate the metrics
|
||||
log.Info("Performing initial requests...")
|
||||
updateMetrics(&metrics, lastUpdatedMetric)
|
||||
log.Debug("Done")
|
||||
// Start the scheduler
|
||||
scheduler.Start()
|
||||
|
||||
// Handle HTTP requests
|
||||
http.Handle(
|
||||
"/metrics", promhttp.HandlerFor(
|
||||
registry,
|
||||
|
||||
Reference in New Issue
Block a user