cmd

package
v0.0.0-...-69375e5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2021 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "hana_sql_exporter",
	Short: "The purpose of this hana_sql_exporter is to support monitoring SAP and SAP HanaDB instances with Prometheus and Grafana.",
	Long:  `The purpose of the hana_sql_exporter is to support monitoring SAP and SAP HanaDB instances with Prometheus and Grafana. As the name suggests, with the hana_sql_exporter a sql select is responsible for the data retrieval. By definition the first column must represent the value of the metric. The following columns are used as labels and must be string values.`,
}

RootCmd represents the base command when called without any subcommands

Functions

func ContainsString

func ContainsString(str string, slice []string) bool

ContainsString - true, if slice contains string

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func FirstValueInSlice

func FirstValueInSlice(subSlice []string, slice []string) string

FirstValueInSlice - return first sublice value that exists in slice

func GetPassword

func GetPassword(secret internal.Secret, tenant string) (string, error)

GetPassword - decrypt password

func GetSecretKey

func GetSecretKey() ([]byte, error)

GetSecretKey - create secret key once

func PwDecrypt

func PwDecrypt(encrypted, byteSecret []byte) (string, error)

PwDecrypt - decrypt tenant password

func PwEncrypt

func PwEncrypt(bytePw, byteSecret []byte) ([]byte, error)

PwEncrypt - encrypt tenant password

func RootHandler

func RootHandler(w http.ResponseWriter, r *http.Request)

RootHandler - message, when calling mithout /metrics

func SubSliceInSlice

func SubSliceInSlice(subSlice []string, slice []string) bool

SubSliceInSlice - true, if every item in sublice exists in slice or sublice is empty

Types

type Config

type Config struct {
	Secret   []byte
	Tenants  []TenantInfo
	Metrics  []MetricInfo
	DataFunc func(mPos, tPos int) []MetricRecord
	Timeout  uint
	// contains filtered or unexported fields
}

Config struct with config file infos

func (*Config) AdaptSchemaFilter

func (config *Config) AdaptSchemaFilter()

AdaptSchemaFilter - add sys schema to SchemaFilter if it does not exists

func (*Config) AddSecret

func (config *Config) AddSecret(tenants string, pw []byte) ([]byte, error)

AddSecret - create encrypted secret for tenant(s)

func (*Config) CollectMetric

func (config *Config) CollectMetric(mPos int) []MetricRecord

CollectMetric - collecting one metric for every tenants

func (*Config) CollectMetrics

func (config *Config) CollectMetrics() []MetricData

CollectMetrics - collecting all metrics and fetch the results

func (*Config) FindTenant

func (config *Config) FindTenant(cmpTenant string) TenantInfo

FindTenant - check if cmpTenant already exists in configfile

func (*Config) GetMetricData

func (config *Config) GetMetricData(mPos, tPos int) []MetricRecord

GetMetricData - metric data for one tenant

func (*Config) GetSecretMap

func (config *Config) GetSecretMap() (internal.Secret, error)

GetSecretMap - unmarshal secret bytes

func (*Config) GetSelection

func (config *Config) GetSelection(mPos, tPos int) string

GetSelection - prepare the db selection

func (*Config) GetTestData1

func (config *Config) GetTestData1(mPos, tPos int) []MetricRecord

GetTestData1 - for testing purpose only

func (*Config) GetTestData2

func (config *Config) GetTestData2(mPos, tPos int) []MetricRecord

GetTestData2 - for testing purpose only

func (*Config) SetPw

func (config *Config) SetPw(cmd *cobra.Command) error

SetPw - save password(s) of tenant(s) database user to the config file

func (*Config) Web

func (config *Config) Web() error

Web - start collector and web server

type MetricData

type MetricData struct {
	Name       string
	Help       string
	MetricType string
	Stats      []MetricRecord
}

MetricData - metric data

type MetricInfo

type MetricInfo struct {
	Name         string
	Help         string
	MetricType   string
	TagFilter    []string
	SchemaFilter []string
	SQL          string
}

MetricInfo - metric data

type MetricRecord

type MetricRecord struct {
	Value       float64
	Labels      []string
	LabelValues []string
}

MetricRecord - metric stats record

type TenantInfo

type TenantInfo struct {
	Name    string
	Tags    []string
	ConnStr string
	User    string
	Usage   string
	Schemas []string
	// contains filtered or unexported fields
}

TenantInfo - tennant data

func (*TenantInfo) GetMetricRows

func (tenant *TenantInfo) GetMetricRows(rows *sql.Rows) ([]MetricRecord, error)

GetMetricRows - return the metric values

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL