diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2e20d54 --- /dev/null +++ b/.gitignore @@ -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 diff --git a/README.md b/README.md index 9c70af5..2b4ae6b 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/ssl_exporter.go b/ssl_exporter.go index c1a76dd..ed8b43b 100644 --- a/ssl_exporter.go +++ b/ssl_exporter.go @@ -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() {
Probe example.com:443 for SSL cert metrics
+