mirror of
https://github.com/ribbybibby/ssl_exporter.git
synced 2026-02-14 17:49:58 +00:00
Support organization units
This commit is contained in:
@@ -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, ",")+",",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user