checks

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2020 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Status = map[string]datadog.Status{
	"ok":       datadog.OK,
	"warning":  datadog.WARNING,
	"critical": datadog.CRITICAL,
	"unknow":   datadog.UNKNOWN,
}

Functions

func AWSSessions

func AWSSessions(region string) *session.Session

AWSSessions initiate a new aws session

Types

type Client

type Client struct {
	Datadog   *datadog.Client
	S3        s3iface.S3API
	Snapshots []*rds.DBSnapshot
	RDS       rdsiface.RDSAPI
	DB        *sql.DB
}

func (*Client) ChangeDBpassword

func (c *Client) ChangeDBpassword(snapshot *rds.DBSnapshot, DBArn, password string) error

ChangeDBpassword changes the database password of a rds instance

func (*Client) CheckIfDatabaseSubnetGroupExist

func (c *Client) CheckIfDatabaseSubnetGroupExist(snapshot *rds.DBSnapshot) bool

CheckIfDatabaseSubnetGroupExist return true if the Subnet Group already exist

func (*Client) CheckRegexAgainstRow

func (c *Client) CheckRegexAgainstRow(query, regex string) bool

CheckRegexAgainstRow will compare the regex and queries set in the yaml configuration file against each others

func (*Client) CheckTag

func (c *Client) CheckTag(arn, key, value string) bool

CheckTag checks the value of a specific tag (key) on a AWS resource

func (*Client) CleanArn added in v0.0.3

func (c *Client) CleanArn(snapshot *rds.DBSnapshot) string

func (*Client) CopySnapshots

func (c *Client) CopySnapshots(snapshot *rds.DBSnapshot, destination, kmsid, preSignedUrl, cleanArn string) error

CopySnapshots copies the snapshots either to the same region as the original or to a new region

func (*Client) CreateDBFromSnapshot

func (c *Client) CreateDBFromSnapshot(snapshot *rds.DBSnapshot, instancetype string, vpcsecuritygroupids []string) error

CreateDBFromSnapshot creates the RDS instance from a snapshot

func (*Client) CreateDatabaseSubnetGroup

func (c *Client) CreateDatabaseSubnetGroup(snapshot *rds.DBSnapshot, subnetids []string) error

CreateDatabaseSubnetGroup creates the Subnet Group if it doesnt already exist

func (*Client) DataDogSession

func (c *Client) DataDogSession(apiKey, applicationKey string) *datadog.Client

DataDogSession creates a new datadog session

func (*Client) DeleteDB

func (c *Client) DeleteDB(snapshot *rds.DBSnapshot) error

Delete the RDS instance created from a specific snapshot

func (*Client) DeleteDatabaseSubnetGroup

func (c *Client) DeleteDatabaseSubnetGroup(snapshot *rds.DBSnapshot) error

DeleteDatabaseSubnetGroup deletes the subnet group created for a rds instance

func (*Client) DeleteOldSnapshot added in v0.0.9

func (c *Client) DeleteOldSnapshot(snapshot *rds.DBSnapshot) error

DeleteOldSnapshot deletes snapshots returned by GetOldSnapshots

func (*Client) GetDBInstanceInfo

func (c *Client) GetDBInstanceInfo(snapshot *rds.DBSnapshot) (*rds.DBInstance, error)

GetDBInstanceInfo returns informations about a rds instance

func (*Client) GetDBInstanceStatus

func (c *Client) GetDBInstanceStatus(snapshot *rds.DBSnapshot) string

GetDBInstanceStatus returns the status of a rds instance

func (*Client) GetOldSnapshots

func (c *Client) GetOldSnapshots(snapshots []*rds.DBSnapshot, retentionDays int) ([]*rds.DBSnapshot, error)

GetOldSnapshots gets old snapshots based on the retention policy retentionDays is a integer of the number of days we want to keep the snapshots.

func (*Client) GetSnapshots

func (c *Client) GetSnapshots(DBInstanceIdentifier string) ([]*rds.DBSnapshot, error)

GetSnapshots gets the latest snapshots of a RDS instance

func (*Client) GetTagValue

func (c *Client) GetTagValue(arn, key string) string

GetTagValue returns the value of a specific tag on a AWS resource

func (*Client) GetYamlFileFromS3

func (c *Client) GetYamlFileFromS3(bucket, key string) (io.Reader, error)

GetYamlFileFromS3 reads a file from s3 and returns its body

func (*Client) InitDb

func (c *Client) InitDb(db *rds.DBInstance, password, dbname string) error

InitDb initialize the database connection

func (*Client) PostDatadogChecks

func (c *Client) PostDatadogChecks(snapshot *rds.DBSnapshot, metricName, status, cmdName string) error

PostDatadogChecks posts to datadog the status of a check

func (*Client) PreSignUrl added in v0.0.3

func (c *Client) PreSignUrl(destinationRegion, snapshotArn, kmsid, cleanArn string) (string, error)

PreSignUrl presigned an aws url so that we can copy an encrypted snapshot from a region to another

func (*Client) SetSessions

func (c *Client) SetSessions(region string)

SetSessions init datadog, RDS and S3 sessions

func (*Client) UnmarshalYamlFile

func (c *Client) UnmarshalYamlFile(body io.Reader) (Doc, error)

UnmarshalYamlFile unmarshal the yaml file dowmloaded from s3

func (*Client) UpdateTag

func (c *Client) UpdateTag(snapshot *rds.DBSnapshot, key, value string) error

UpdateTag updates a tag value on a snapshot

type DefaultChecks

type DefaultChecks interface {
	SetSessions(region string)
	GetYamlFileFromS3(bucket, key string) (io.Reader, error)
	UnmarshalYamlFile(body io.Reader) (Doc, error)
	DataDogSession(apiKey, applicationKey string) *datadog.Client
	PostDatadogChecks(snapshot *rds.DBSnapshot, metricName, status, cmdName string) error
	GetSnapshots(DBInstanceIdentifier string) ([]*rds.DBSnapshot, error)
	CopySnapshots(snapshot *rds.DBSnapshot, destination, kmsid, preSignedUrl, cleanArn string) error
	GetOldSnapshots(snapshots []*rds.DBSnapshot, retention int) ([]*rds.DBSnapshot, error)
	DeleteOldSnapshot(snapshot *rds.DBSnapshot) error
	CheckIfDatabaseSubnetGroupExist(snapshot *rds.DBSnapshot) bool
	CreateDatabaseSubnetGroup(snapshot *rds.DBSnapshot, subnetids []string) error
	CreateDBFromSnapshot(snapshot *rds.DBSnapshot, instancetype string, vpcsecuritygroupids []string) error
	DeleteDB(snapshot *rds.DBSnapshot) error
	UpdateTag(snapshot *rds.DBSnapshot, key, value string) error
	CheckTag(arn, key, value string) bool
	GetDBInstanceInfo(snapshot *rds.DBSnapshot) (*rds.DBInstance, error)
	DeleteDatabaseSubnetGroup(snapshot *rds.DBSnapshot) error
	ChangeDBpassword(snapshot *rds.DBSnapshot, DBArn, password string) error
	GetDBInstanceStatus(snapshot *rds.DBSnapshot) string
	GetTagValue(arn, key string) string
	InitDb(db *rds.DBInstance, password, dbname string) error
	CheckRegexAgainstRow(query, regex string) bool
	PreSignUrl(destinationRegion, snapshotArn, kmsid, cleanArn string) (string, error)
	CleanArn(snapshot *rds.DBSnapshot) string
}

func New

func New() DefaultChecks

type Doc

type Doc struct {
	Instances []Instances
}

type Instances

type Instances struct {
	Name        string
	Database    string
	Type        string
	Password    string
	Retention   int
	Destination string
	KmsID       string
	Queries     []Queries
}

type Queries

type Queries struct {
	Query string
	Regex string
}

Jump to

Keyboard shortcuts

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