6 Commits

Author SHA1 Message Date
Rob Best
380d1bf2f9 Merge pull request #2 from tdabasinskas/org
Add support for Organization Unit field
2019-01-25 08:41:15 +00:00
Tomas Dabasinskas
0abd32fac6 Rename ou variable 2019-01-25 10:34:41 +02:00
Tomas Dabasinskas
41450add27 Update docs 2019-01-25 09:56:38 +02:00
Tomas Dabasinskas
b992e2c307 Support organization units 2019-01-25 08:14:56 +02:00
Tomas Dabasinskas
7aafd0d61c Fix the example target 2019-01-25 08:05:17 +02:00
Tomas Dabasinskas
fc34b37f2a Add gitIgnore 2019-01-25 07:58:15 +02:00
3 changed files with 30 additions and 1 deletions

15
.gitignore vendored Normal file
View 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

View File

@@ -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

View File

@@ -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>`))