Documentation ¶
Index ¶
- Constants
- Variables
- func EvaluateHCErrors(hcerrors []HCError) (int, int, bool)
- func StatusHealthchecks(errors int, warnings int, fatal bool) string
- func SubjectHealthcheck(name string, dbName string, hostname string, level string, errors int, ...) string
- type Format
- type HCError
- type SQLHealthCheck
- func (healthCheck *SQLHealthCheck) EvaluateHealthCheck() (err HCError)
- func (healthCheck SQLHealthCheck) GetHeaders() []string
- func (healthCheck SQLHealthCheck) GetValue(key string) string
- func (healthCheck *SQLHealthCheck) RunHealthCheck(cxn *sql.DB)
- func (healthCheck SQLHealthCheck) ValidateHealthCheck() bool
Constants ¶
FooterHealthcheck footer for healthchecks
const TemplateHealthcheckHTML = `` /* 2004-byte string literal not displayed */
TemplateHealthcheckHTML pongo2 template for healthchecks
const TemplateHealthcheckPostgres = `
CREATE TABLE IF NOT EXISTS {{metadata.schema}}.{{metadata.table}}
(
title text,
query text,
executed text,
expected text,
operation text,
actual text,
equal text,
severity text,
"timestamp" timestamp with time zone
);
INSERT INTO "{{metadata.schema}}"."{{metadata.table}}" ("title", "query", "executed", "expected", "operation", "actual", "equal", "severity", "timestamp") VALUES
{% for element in elements %}
('{{ element.Title }}', '{{ element.Query | safe | addquote }}', '{{ element.Passed}}', '{{ element.Expected | safe | addquote }}', '{{ element.Operation | safe | addquote }}', '{{ element.Actual | safe | addquote }}', '{{ element.Equal | safe | addquote }}', '{{ element.Severity }}', '{{ metadata.timestamp }}') ` +
`{% if forloop.Last%};{%else%},{%endif%}` +
`{% endfor %}`
TemplateHealthcheckPostgres pongo2 template for healthchecks INSERT
Variables ¶
var HealthCheckReportHeaders = []string{"Title", "Query", "Passed", "Expected", "Actual", "Equal", "Severity", "Operation"}
HealthCheckReportHeaders headers used for GetHeaders
Functions ¶
func EvaluateHCErrors ¶
EvaluateHCErrors given a slice of HCErrors, determine if error or early exit
func StatusHealthchecks ¶
StatusHealthchecks returns a simple summary for all healthchecks
Types ¶
type Format ¶
type Format struct { Name string `yaml:"name"` Distribution []string `yaml:"distribution"` Tests []SQLHealthCheck `yaml:"tests"` }
Format is for unmarshiling a healthcheck file and contains control information for a set of SQLHealthChecks
func ReadHealthCheckYAMLFromFile ¶
ReadHealthCheckYAMLFromFile loads healthcheck data from a YAML file
func (*Format) PreformHealthChecks ¶
func (healthChecks *Format) PreformHealthChecks(cxn *sql.DB) (results []SQLHealthCheck, errors []HCError)
PreformHealthChecks runs and evaluates healthChecks one at a time
func (*Format) RejectBadHealthChecks ¶
func (healthChecks *Format) RejectBadHealthChecks()
RejectBadHealthChecks validates all healthchecks in specified file
func (*Format) RunHealthChecks ¶
RunHealthChecks executes all health checks in the specified file
func (*Format) ValidateHealthChecks ¶
ValidateHealthChecks validates all healthchecks in specified file
type SQLHealthCheck ¶
type SQLHealthCheck struct { Expected string `yaml:"expected"` Query string `yaml:"query"` Title string `yaml:"title"` Severity string `yaml:"severity"` Operation string `yaml:"operation,omitempty"` Passed bool Actual string Equal bool }
SQLHealthCheck is a data type for storing the definition and results of a SQL based health check
func (*SQLHealthCheck) EvaluateHealthCheck ¶
func (healthCheck *SQLHealthCheck) EvaluateHealthCheck() (err HCError)
EvaluateHealthCheck runs through a single healthcheck and acts on the result
func (SQLHealthCheck) GetHeaders ¶
func (healthCheck SQLHealthCheck) GetHeaders() []string
GetHeaders Implementation for report.Element
func (SQLHealthCheck) GetValue ¶
func (healthCheck SQLHealthCheck) GetValue(key string) string
GetValue Implementation for report.Element
func (*SQLHealthCheck) RunHealthCheck ¶
func (healthCheck *SQLHealthCheck) RunHealthCheck(cxn *sql.DB)
RunHealthCheck runs through a single healthcheck and saves the result
func (SQLHealthCheck) ValidateHealthCheck ¶
func (healthCheck SQLHealthCheck) ValidateHealthCheck() bool
ValidateHealthCheck makes sure a helathcheck has all the fields populated