diff --git a/README.md b/README.md index fdfc609..f045af3 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ These metrics are exported by `monit_exporter`: | monit_service_mem_bytes | Monit service mem info with following labels:
`check_name`
Name of monit check
`type`
Specifies value type whereas value can be `kilobyte` or `kilobyte_total`
| monit_service_network_link_state | Monit service link states
`check_name`
Name of monit check

Value can be either `-1` = Not available, `0` = down and `1` = up | monit_service_network_link_statistics | Monit service link statistics
`check_name`
Name of monit check
`direction`
Specifies link direction (upload / download)
`unit`
Spcifies unit of metrics (bytes, errors, packets)
`type`
Specifies the type with either now or total. Whereas now means "per second"
-| monit_service_port_response_times | Monit service port checks response times
`check_name`
Name of monit check
`hostname`
Specifies hostname checked
`port`
Specifies port to check
`protocol`
Specifies protocol used for checking service (e.g. POP, IMAP, REDIS, etc.). Default is a RAW check.
`type`
Specifies protocol type (e.g. TCP, UDP, etc.)
+| monit_service_port_response_times | Monit service port and unix socket checks response times
`check_name`
Name of monit check
`hostname`
Specifies hostname checked
`path`
Specifies a unix socket path
`port`
Specifies port to check
`protocol`
Specifies protocol used for checking service (e.g. POP, IMAP, REDIS, etc.). Default is a RAW check.
`type`
Specifies protocol type (e.g. TCP, UDP, UNIX)
`uri`
Gives full URI for the service check including type, host and port or path.
| monit_service_read_bytes | Monit service Disk Read Bytes
`check_name`
Name of monit check
`type`
Specifies type of read / write. Possible values: read_count, read_count_total. Value is given in bytes.
| monit_service_write_bytes | Monit service Disk Writes Bytes
`check_name`
Name of monit check
`type`
Specifies type of read / write. Possible values: write_count, write_count_total. Value is given in bytes.
| monit_up | Monit status availability. `0` = not available and `1` = available diff --git a/monit_exporter.go b/monit_exporter.go index 4a7f3ef..8fcc0de 100644 --- a/monit_exporter.go +++ b/monit_exporter.go @@ -60,6 +60,7 @@ type monitService struct { DiskRead monitServiceDisk `xml:"read"` ServiceTimes monitServiceTime `xml:"servicetime"` Ports []monitServicePort `xml:"port"` + UnixSockets []monitServicePort `xml:"unix"` Link monitServiceLink `xml:"link"` } @@ -88,6 +89,7 @@ type monitServiceTime struct { type monitServicePort struct { Hostname string `xml:"hostname"` + Path string `xml:"path"` Portnumber string `xml:"portnumber"` Protocol string `xml:"protocol"` Type string `xml:"type"` @@ -273,9 +275,9 @@ func NewExporter(c *Config) (*Exporter, error) { checkPortRespTimes: prometheus.NewGaugeVec(prometheus.GaugeOpts{ Namespace: namespace, Name: "service_port_response_times", - Help: "Monit service port checks response times", + Help: "Monit service port and unix socket checks response times", }, - []string{"check_name", "hostname", "port", "protocol", "type"}, + []string{"check_name", "hostname", "path", "port", "protocol", "type", "uri"}, ), checkLinkState: prometheus.NewGaugeVec(prometheus.GaugeOpts{ Namespace: namespace, @@ -392,13 +394,31 @@ func (e *Exporter) scrape() error { // Port checks for _, port := range service.Ports { + var uri = fmt.Sprintf("%s://%s:%s", strings.ToLower(port.Type), port.Hostname, port.Portnumber) e.checkPortRespTimes.With( prometheus.Labels{ "check_name": service.Name, "type": port.Type, "hostname": port.Hostname, + "path": "", "port": port.Portnumber, "protocol": port.Protocol, + "uri": uri, + }).Set(float64(port.Responsetime)) + } + + // Unix socket checks + for _, port := range service.UnixSockets { + var uri = fmt.Sprintf("unix://%s", port.Path) + e.checkPortRespTimes.With( + prometheus.Labels{ + "check_name": service.Name, + "type": "UNIX", + "hostname": "", + "path": port.Path, + "port": "", + "protocol": port.Protocol, + "uri": uri, }).Set(float64(port.Responsetime)) } }