mirror of
https://github.com/ribbybibby/ssl_exporter.git
synced 2026-03-17 00:20:17 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
380d1bf2f9 | ||
|
|
0abd32fac6 | ||
|
|
41450add27 | ||
|
|
b992e2c307 | ||
|
|
7aafd0d61c | ||
|
|
fc34b37f2a |
15
.gitignore
vendored
Normal file
15
.gitignore
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
*.test
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
# KetBrains IDEs files
|
||||
.idea
|
||||
@@ -36,6 +36,7 @@ I considered having a series for each ```ssl_cert_subject_alternative_*``` value
|
||||
| ssl_cert_subject_alternative_dnsnames | The subject alternative names (if any). Always has a value of 1 | issuer_cn, serial_no, dnsnames |
|
||||
| ssl_cert_subject_alternative_emails | The subject alternative email addresses (if any). Always has a value of 1 | issuer_cn, serial_no, emails |
|
||||
| ssl_cert_subject_alternative_ips | The subject alternative IP addresses (if any). Always has a value of 1 | issuer_cn, serial_no, ips |
|
||||
| ssl_cert_subject_organization_units | The subject organization names (if any). Always has a value of 1. | issuer_cn, serial_no, subject_ou |
|
||||
| ssl_https_connect_success | Was the HTTPS connection successful? Boolean. | |
|
||||
|
||||
## Prometheus
|
||||
|
||||
@@ -56,6 +56,11 @@ var (
|
||||
"Subject Alternative DNS Names",
|
||||
[]string{"serial_no", "issuer_cn", "emails"}, nil,
|
||||
)
|
||||
subjectOrganizationUnits = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(namespace, "", "cert_subject_organization_units"),
|
||||
"Subject Organization Units",
|
||||
[]string{"serial_no", "issuer_cn", "subject_ou"}, nil,
|
||||
)
|
||||
)
|
||||
|
||||
type Exporter struct {
|
||||
@@ -71,6 +76,7 @@ func (e *Exporter) Describe(ch chan<- *prometheus.Desc) {
|
||||
ch <- subjectAlernativeDNSNames
|
||||
ch <- subjectAlernativeIPs
|
||||
ch <- subjectAlernativeEmailAddresses
|
||||
ch <- subjectOrganizationUnits
|
||||
}
|
||||
|
||||
func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
|
||||
@@ -119,6 +125,7 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
|
||||
subject_emails := cert.EmailAddresses
|
||||
subject_ips := cert.IPAddresses
|
||||
serial_no := cert.SerialNumber.String()
|
||||
subject_ous := cert.Subject.OrganizationalUnit
|
||||
|
||||
if !cert.NotAfter.IsZero() {
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
@@ -159,6 +166,12 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
|
||||
subjectAlernativeIPs, prometheus.GaugeValue, 1, serial_no, issuer_cn, i,
|
||||
)
|
||||
}
|
||||
|
||||
if len(subject_ous) > 0 {
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
subjectOrganizationUnits, prometheus.GaugeValue, 1, serial_no, issuer_cn, ","+strings.Join(subject_ous, ",")+",",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,7 +262,7 @@ func main() {
|
||||
<head><title>SSL Exporter</title></head>
|
||||
<body>
|
||||
<h1>SSL Exporter</h1>
|
||||
<p><a href="` + *probePath + `?target=example.com:443">Probe example.com:443 for SSL cert metrics</a></p>
|
||||
<p><a href="` + *probePath + `?target=https://example.com">Probe https://example.com for SSL cert metrics</a></p>
|
||||
<p><a href='` + *metricsPath + `'>Metrics</a></p>
|
||||
</body>
|
||||
</html>`))
|
||||
|
||||
Reference in New Issue
Block a user