Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
sap hana: add units to metadata, make tls fields configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
pmcollins committed Oct 29, 2021
1 parent 379a1a9 commit 0c68eee
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 80 deletions.
54 changes: 30 additions & 24 deletions docs/monitors/hana.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ monitors: # All monitor config goes under this key
Configuration](../monitor-config.md#common-configuration).**
This monitor has no configuration options.
| Config option | Required | Type | Description |
| --- | --- | --- | --- |
| `tlsServerName` | no | `string` | ServerName to verify the hostname. Defaults to Host if not specified. |
| `insecureSkipVerify` | no | `bool` | Controls whether a client verifies the server's certificate chain and host name. Defaults to false. (**default:** `false`) |
| `rootCAFiles` | no | `list of strings` | Path to root certificate(s) (optional) |


## Metrics

These are the metrics available for this monitor.
Expand All @@ -56,21 +62,21 @@ Metrics that are categorized as

- ***`sap.hana.connection.message.sent.size`*** (*gauge*)<br> Total size of messages sent

- ***`sap.hana.connection.record.affected`*** (*gauge*)<br> The sum of the record count affected by DML/DDL statements.
- ***`sap.hana.connection.record.affected`*** (*gauge*)<br> The sum of the record count affected by DML/DDL statements

- ***`sap.hana.connection.record.fetched`*** (*gauge*)<br> Number of records fetched by select statements.
- ***`sap.hana.connection.record.fetched`*** (*gauge*)<br> Number of records fetched by select statements

- `sap.hana.host.cpu.idle` (*counter*)<br> CPU idle time
- `sap.hana.host.cpu.idle` (*counter*)<br> CPU idle time in milliseconds

- `sap.hana.host.cpu.system` (*counter*)<br> CPU time spent in kernel mode

- ***`sap.hana.host.cpu.user`*** (*counter*)<br> CPU time spent in user mode
- ***`sap.hana.host.cpu.user`*** (*counter*)<br> CPU time spent in user mode in milliseconds

- `sap.hana.host.cpu.wio` (*counter*)<br> CPU time spent in wait IO (Linux only, Windows always 0)
- `sap.hana.host.cpu.wio` (*counter*)<br> CPU time spent in wait IO (Linux only, Windows always 0) in milliseconds

- ***`sap.hana.host.file.open`*** (*gauge*)<br> Number of open files

- ***`sap.hana.host.memory.shared`*** (*gauge*)<br> Shared memory size of instance processes
- ***`sap.hana.host.memory.shared`*** (*gauge*)<br> Shared memory size of instance processes in bytes

- `sap.hana.io.append.count` (*counter*)<br> Number of appends

Expand All @@ -80,45 +86,45 @@ Metrics that are categorized as

- ***`sap.hana.io.read.failed`*** (*counter*)<br> Number of failed reads

- `sap.hana.io.read.size` (*counter*)<br> Size of read data
- `sap.hana.io.read.size` (*counter*)<br> Size of read data in bytes

- ***`sap.hana.io.read.time`*** (*counter*)<br> Total read time
- ***`sap.hana.io.read.time`*** (*counter*)<br> Total read time in microseconds

- ***`sap.hana.io.total.time`*** (*counter*)<br> Total write time
- ***`sap.hana.io.total.time`*** (*counter*)<br> Total write time in microseconds

- ***`sap.hana.io.write.async.count`*** (*counter*)<br> Number of triggered asynchronous writes

- ***`sap.hana.io.write.count`*** (*counter*)<br> Number of synchronous writes

- ***`sap.hana.io.write.failed`*** (*counter*)<br> Number of failed writes

- `sap.hana.io.write.size` (*counter*)<br> Size of written data
- `sap.hana.io.write.size` (*counter*)<br> Size of written data in bytes

- ***`sap.hana.io.write.time`*** (*counter*)<br> Total write time
- ***`sap.hana.io.write.time`*** (*counter*)<br> Total write time in microseconds

- ***`sap.hana.service.component.memory.used`*** (*gauge*)<br> Amount of memory from the memory pool currently in use by component

- ***`sap.hana.service.memory.allocation_limit`*** (*gauge*)<br> Maximum configured memory pool size
- ***`sap.hana.service.memory.allocation_limit`*** (*gauge*)<br> Maximum configured memory pool size in bytes

- `sap.hana.service.memory.allocation_limit_effective` (*gauge*)<br> Effective maximum memory pool size, considering the pool sizes of other processes
- `sap.hana.service.memory.allocation_limit_effective` (*gauge*)<br> Effective maximum memory pool size in bytes, considering the pool sizes of other processes

- ***`sap.hana.service.memory.code`*** (*gauge*)<br> Code size, including shared libraries
- ***`sap.hana.service.memory.code`*** (*gauge*)<br> Code size, including shared libraries in bytes

- ***`sap.hana.service.memory.heap.allocated`*** (*gauge*)<br> Heap part of the memory pool
- ***`sap.hana.service.memory.heap.allocated`*** (*gauge*)<br> Heap part of the memory pool in bytes

- ***`sap.hana.service.memory.heap.used`*** (*gauge*)<br> Amount of pool heap memory in use
- ***`sap.hana.service.memory.heap.used`*** (*gauge*)<br> Amount of pool heap memory in use in bytes

- ***`sap.hana.service.memory.logical`*** (*gauge*)<br> Virtual memory size
- ***`sap.hana.service.memory.logical`*** (*gauge*)<br> Virtual memory size in bytes

- ***`sap.hana.service.memory.physical`*** (*gauge*)<br> Physical memory size
- ***`sap.hana.service.memory.physical`*** (*gauge*)<br> Physical memory size in bytes

- ***`sap.hana.service.memory.shared.allocated`*** (*gauge*)<br> Shared memory part of the memory pool
- ***`sap.hana.service.memory.shared.allocated`*** (*gauge*)<br> Shared memory part of the memory pool in bytes

- ***`sap.hana.service.memory.shared.used`*** (*gauge*)<br> Amount of pool shared memory in use
- ***`sap.hana.service.memory.shared.used`*** (*gauge*)<br> Amount of shared memory pool in use in bytes

- ***`sap.hana.service.memory.stack`*** (*gauge*)<br> Stack size

- ***`sap.hana.service.memory.total_used`*** (*gauge*)<br> Amount of memory in use from the memory pool.
- ***`sap.hana.service.memory.total_used`*** (*gauge*)<br> Amount of memory in use from the memory pool

- ***`sap.hana.statement.active.count`*** (*gauge*)<br> Number of active statements

Expand All @@ -136,9 +142,9 @@ Metrics that are categorized as

- ***`sap.hana.statement.expensive.count`*** (*counter*)<br> Number of occurances of the statement

- ***`sap.hana.statement.expensive.cpu_time`*** (*counter*)<br> CPU time consumed to compute the statement
- ***`sap.hana.statement.expensive.cpu_time`*** (*counter*)<br> CPU time consumed to compute the statement in microseconds

- ***`sap.hana.statement.expensive.duration`*** (*counter*)<br> Time elapsed during execution of the statement
- ***`sap.hana.statement.expensive.duration`*** (*counter*)<br> Time elapsed during execution of the statement in microseconds

- ***`sap.hana.statement.expensive.errors`*** (*counter*)<br> Number of errors

Expand Down
46 changes: 23 additions & 23 deletions pkg/monitors/hana/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ monitors:
sap.hana.connection.record.affected:
default: true
description: |
The sum of the record count affected by DML/DDL statements.
The sum of the record count affected by DML/DDL statements
type: gauge
sap.hana.connection.record.fetched:
default: true
description: |
Number of records fetched by select statements.
Number of records fetched by select statements
type: gauge
sap.hana.host.cpu.idle:
default: false
description: |
CPU idle time
CPU idle time in milliseconds
type: counter
sap.hana.host.cpu.system:
default: false
Expand All @@ -87,12 +87,12 @@ monitors:
sap.hana.host.cpu.user:
default: true
description: |
CPU time spent in user mode
CPU time spent in user mode in milliseconds
type: counter
sap.hana.host.cpu.wio:
default: false
description: |
CPU time spent in wait IO (Linux only, Windows always 0)
CPU time spent in wait IO (Linux only, Windows always 0) in milliseconds
type: counter
sap.hana.host.file.open:
default: true
Expand All @@ -102,7 +102,7 @@ monitors:
sap.hana.host.memory.shared:
default: true
description: |
Shared memory size of instance processes
Shared memory size of instance processes in bytes
type: gauge
sap.hana.io.append.count:
default: false
Expand All @@ -127,17 +127,17 @@ monitors:
sap.hana.io.read.size:
default: false
description: |
Size of read data
Size of read data in bytes
type: counter
sap.hana.io.read.time:
default: true
description: |
Total read time
Total read time in microseconds
type: counter
sap.hana.io.total.time:
default: true
description: |
Total write time
Total write time in microseconds
type: counter
sap.hana.io.write.async.count:
default: true
Expand All @@ -157,12 +157,12 @@ monitors:
sap.hana.io.write.size:
default: false
description: |
Size of written data
Size of written data in bytes
type: counter
sap.hana.io.write.time:
default: true
description: |
Total write time
Total write time in microseconds
type: counter
sap.hana.service.component.memory.used:
default: true
Expand All @@ -172,47 +172,47 @@ monitors:
sap.hana.service.memory.allocation_limit:
default: true
description: |
Maximum configured memory pool size
Maximum configured memory pool size in bytes
type: gauge
sap.hana.service.memory.allocation_limit_effective:
default: false
description: |
Effective maximum memory pool size, considering the pool sizes of other processes
Effective maximum memory pool size in bytes, considering the pool sizes of other processes
type: gauge
sap.hana.service.memory.code:
default: true
description: |
Code size, including shared libraries
Code size, including shared libraries in bytes
type: gauge
sap.hana.service.memory.heap.allocated:
default: true
description: |
Heap part of the memory pool
Heap part of the memory pool in bytes
type: gauge
sap.hana.service.memory.heap.used:
default: true
description: |
Amount of pool heap memory in use
Amount of pool heap memory in use in bytes
type: gauge
sap.hana.service.memory.logical:
default: true
description: |
Virtual memory size
Virtual memory size in bytes
type: gauge
sap.hana.service.memory.physical:
default: true
description: |
Physical memory size
Physical memory size in bytes
type: gauge
sap.hana.service.memory.shared.allocated:
default: true
description: |
Shared memory part of the memory pool
Shared memory part of the memory pool in bytes
type: gauge
sap.hana.service.memory.shared.used:
default: true
description: |
Amount of pool shared memory in use
Amount of shared memory pool in use in bytes
type: gauge
sap.hana.service.memory.stack:
default: true
Expand All @@ -222,7 +222,7 @@ monitors:
sap.hana.service.memory.total_used:
default: true
description: |
Amount of memory in use from the memory pool.
Amount of memory in use from the memory pool
type: gauge
sap.hana.statement.active.count:
default: true
Expand Down Expand Up @@ -267,12 +267,12 @@ monitors:
sap.hana.statement.expensive.cpu_time:
default: true
description: |
CPU time consumed to compute the statement
CPU time consumed to compute the statement in microseconds
type: counter
sap.hana.statement.expensive.duration:
default: true
description: |
Time elapsed during execution of the statement
Time elapsed during execution of the statement in microseconds
type: counter
sap.hana.statement.expensive.errors:
default: true
Expand Down
46 changes: 37 additions & 9 deletions pkg/monitors/hana/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ package hana

import (
"fmt"
"net/url"
"strconv"

"github.com/SAP/go-hdb/driver"
"github.com/signalfx/signalfx-agent/pkg/core/config"
"github.com/signalfx/signalfx-agent/pkg/monitors"
"github.com/signalfx/signalfx-agent/pkg/monitors/sql"
Expand All @@ -20,9 +23,17 @@ type Config struct {
Host string
Username string
Password string
Port int
LogQueries bool
MaxExpensiveQueries int

// ServerName to verify the hostname. Defaults to Host if not specified.
TLSServerName string `yaml:"tlsServerName"`
// Controls whether a client verifies the server's certificate chain and host name. Defaults to false.
TLSInsecureSkipVerify bool `yaml:"insecureSkipVerify"`
// Path to root certificate(s) (optional)
TLSRootCAFiles []string `yaml:"rootCAFiles"`

Port int
LogQueries bool
MaxExpensiveQueries int
}

// Monitor that collects SAP Hana stats
Expand Down Expand Up @@ -51,18 +62,35 @@ func cfgToConnString(c *Config) string {
if c.ConnectionString != "" {
return c.ConnectionString
}
return connString(c.Host, c.Port, c.Username, c.Password)
}

func connString(host string, port int, username string, password string) string {
host := c.Host
if host == "" {
host = "localhost"
}
port := c.Port
if port == 0 {
port = 443
}
const format = "hdb://%s:%s@%s:%d?TLSInsecureSkipVerify=false&TLSServerName=%s"
return fmt.Sprintf(format, username, password, host, port, host)
tlsServerName := c.TLSServerName
if tlsServerName == "" {
tlsServerName = host
}
return createDSN(host, c.Username, c.Password, tlsServerName, port, c.TLSInsecureSkipVerify, c.TLSRootCAFiles)
}

func createDSN(host, username, password, tlsServerName string, port int, tlsInsecureSkipVerify bool, rootCAFiles []string) string {
query := url.Values{}
query.Add(driver.DSNTLSServerName, tlsServerName)
query.Add(driver.DSNTLSInsecureSkipVerify, strconv.FormatBool(tlsInsecureSkipVerify))
for _, f := range rootCAFiles {
query.Add(driver.DSNTLSRootCAFile, f)
}
u := &url.URL{
Scheme: "hdb",
User: url.UserPassword(username, password),
Host: fmt.Sprintf("%s:%d", host, port),
RawQuery: query.Encode(),
}
return u.String()
}

func configureSQLMonitor(output types.Output, monCfg config.MonitorConfig, connStr string, logQueries bool, maxExpensiveQueries int) (*sql.Monitor, error) {
Expand Down
Loading

0 comments on commit 0c68eee

Please sign in to comment.