From fc34b37f2ab2919303d1a98bbb57f1024c21f8a2 Mon Sep 17 00:00:00 2001 From: Tomas Dabasinskas Date: Fri, 25 Jan 2019 07:58:15 +0200 Subject: [PATCH 1/5] Add gitIgnore --- .gitignore | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ed7a98c --- /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 \ No newline at end of file From 7aafd0d61ca6d26f98b42dca342afded1c13c81a Mon Sep 17 00:00:00 2001 From: Tomas Dabasinskas Date: Fri, 25 Jan 2019 08:05:17 +0200 Subject: [PATCH 2/5] Fix the example target --- ssl_exporter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ssl_exporter.go b/ssl_exporter.go index c1a76dd..18ba9ec 100644 --- a/ssl_exporter.go +++ b/ssl_exporter.go @@ -249,7 +249,7 @@ func main() { SSL Exporter

SSL Exporter

-

Probe example.com:443 for SSL cert metrics

+

Probe https://example.com for SSL cert metrics

Metrics

`)) From b992e2c30778faf9ece7c876c16098d7b6fb3856 Mon Sep 17 00:00:00 2001 From: Tomas Dabasinskas Date: Fri, 25 Jan 2019 08:14:56 +0200 Subject: [PATCH 3/5] Support organization units --- ssl_exporter.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ssl_exporter.go b/ssl_exporter.go index 18ba9ec..ad20815 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() + 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(ous) > 0 { + ch <- prometheus.MustNewConstMetric( + subjectOrganizationUnits, prometheus.GaugeValue, 1, serial_no, issuer_cn, ","+strings.Join(ous, ",")+",", + ) + } } } From 41450add27ea78b4c828c36e670d0308cb15a185 Mon Sep 17 00:00:00 2001 From: Tomas Dabasinskas Date: Fri, 25 Jan 2019 08:23:41 +0200 Subject: [PATCH 4/5] Update docs --- README.md | 1 + 1 file changed, 1 insertion(+) 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 From 0abd32fac67689eeae9a06022773db8d0616099c Mon Sep 17 00:00:00 2001 From: Tomas Dabasinskas Date: Fri, 25 Jan 2019 10:34:41 +0200 Subject: [PATCH 5/5] Rename ou variable --- .gitignore | 2 +- ssl_exporter.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index ed7a98c..2e20d54 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,4 @@ *.out # KetBrains IDEs files -.idea \ No newline at end of file +.idea diff --git a/ssl_exporter.go b/ssl_exporter.go index ad20815..ed8b43b 100644 --- a/ssl_exporter.go +++ b/ssl_exporter.go @@ -125,7 +125,7 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) { subject_emails := cert.EmailAddresses subject_ips := cert.IPAddresses serial_no := cert.SerialNumber.String() - ous := cert.Subject.OrganizationalUnit + subject_ous := cert.Subject.OrganizationalUnit if !cert.NotAfter.IsZero() { ch <- prometheus.MustNewConstMetric( @@ -167,9 +167,9 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) { ) } - if len(ous) > 0 { + if len(subject_ous) > 0 { ch <- prometheus.MustNewConstMetric( - subjectOrganizationUnits, prometheus.GaugeValue, 1, serial_no, issuer_cn, ","+strings.Join(ous, ",")+",", + subjectOrganizationUnits, prometheus.GaugeValue, 1, serial_no, issuer_cn, ","+strings.Join(subject_ous, ",")+",", ) } }