hanautil

package module
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

README

hanautil

Go Go Coverage

A helper utility for the HANA database written in golang.

hanautil aims to provide helper functions for the monitoring and maintenance of the SAP HANA databases.

The library provides an abstraction from SQL, meaning that, as a user, you don't need to understand the SQL required to perform the tasks, preventing users creating SQL statements that don't behave as intended. However, some of the functions contained in this library are destructive. Destructive functions are all documented appropriately and should be used with extreme caution.

This module is still in beta but a full production release is expected soon.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackupSummary

type BackupSummary struct {
	BackupCatalogEntries      uint64
	FullBackups               uint64
	LogBackups                uint64
	IncrementalBackups        uint64
	DifferentialBackups       uint64
	LogMissing                uint64
	DataSnapshots             uint64
	SizeOfFullBackupsBytes    uint64
	SizeOfLogBackupBytes      uint64
	SizeOfIncrementalBackups  uint64
	SizeOfDifferentialBackups uint64
	SizeOfLogMissing          uint64
	SizeOfDataSnapshots       uint64
	SizeOfBackupCatalog       uint64
	OldestFullBackupDate      time.Time
	OldestLogBackupDate       time.Time
	CurrentDbTime             time.Time
}

BackupSummary is a struct that contains information regarding HANA backups

func (*BackupSummary) GetAllBytes added in v0.1.6

func (bs *BackupSummary) GetAllBytes() uint64

type HanaUtilClient

type HanaUtilClient struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(dsn string) *HanaUtilClient

func (*HanaUtilClient) Close

func (h *HanaUtilClient) Close() error

func (*HanaUtilClient) Connect

func (h *HanaUtilClient) Connect() error

func (*HanaUtilClient) GetBackupSummary

func (h *HanaUtilClient) GetBackupSummary() (BackupSummary, error)

GetBackupSummary provides a summary of the number of backups along aggregated backup size data found in the backup catalog. The dates of the oldest full and log backups in the catalog are also supplied.

func (*HanaUtilClient) GetBackupSummaryBeforeBackupID added in v0.1.2

func (h *HanaUtilClient) GetBackupSummaryBeforeBackupID(b string) (BackupSummary, error)

GetBackupSummaryBeforeBackupID provides a summary of the number of backups aggregated backup size data found in the backup catalog that occur before a given backup ID. The dates of the oldest full and log backups in the catalog are also supplied.

func (*HanaUtilClient) GetFullBackupId added in v0.1.3

func (h *HanaUtilClient) GetFullBackupId(days int) (string, error)

GetFullBackupID returns the latest full backup that is older than the given days in the days argument. The output of this may then be used by GetBackupSummaryBeforeBackupID for information about data that could be removed if a truncation is applied.

func (*HanaUtilClient) GetLogSegmentStats

func (h *HanaUtilClient) GetLogSegmentStats() (LogSegmentsStats, error)

GetLogSegmentStats provides information about the free and non-free log segments in the HANA log volume

func (*HanaUtilClient) GetStatServerAlerts

func (h *HanaUtilClient) GetStatServerAlerts(days uint) (uint, error)

GetStatServerAlerts is a function that reports the number of historic alerts that are stored in the _SYS_STATISTICS.STATISTICS_ALERTS_BASE table. SAP HANA minichecks will flag any database where there are alerts in the tables that are older than 42 days. This function will return the number of alerts that are more than the 'days' argument old. Errors returned are either 'UnexpectedDbReturn', when the query produces an unexpected value or a DB driver error promoted directly from the DB.

func (*HanaUtilClient) GetTraceFiles

func (h *HanaUtilClient) GetTraceFiles(days uint) ([]TraceFile, error)

GetTraceFiles retrieves information about HANA database traces. It returns a slice of the type 'TraceFiles' and an error. The argument 'days' is used to filter the returned results to trace files that that have a modification date the exceeds the argument 'days'. For example, if days were set to '1', only the returned slice would only include details of trace files where the modification date is was longer that 24 hours ago.

func (*HanaUtilClient) GetVersion

func (h *HanaUtilClient) GetVersion() (string, error)

GetVersion returns the version of the the HANA database and an error.

func (*HanaUtilClient) ReclaimLog

func (h *HanaUtilClient) ReclaimLog() (uint64, error)

ReclaimLog removes all log segments in the log volume that are marked as 'Free'. Freeing log segments lowers the amount of used space on the log volume which is especially import in MDC environments. The function will return the number of bytes removed from the log volumes and an error. If an error occurs the returned uint64 will be zero and the error will be populated

func (*HanaUtilClient) RemoveStatServerAlerts

func (h *HanaUtilClient) RemoveStatServerAlerts(days uint) (uint64, error)

RemoveStatServerAlerts removes entries from the SYS_STATISTICS.STATISTICS_ALERTS_BASE table that are older than the number of days given in the 'days' argument. The function returns a uint64 which

func (*HanaUtilClient) RemoveTraceFile

func (h *HanaUtilClient) RemoveTraceFile(host, filename string) error

RemoveTraceFile deletes HANA trace files. Use the the GetTraceFiles function to find candidates for removal. The function takes two arguments, the HANA host that the trace files resides upon and the trace file name.

hanautil will first check to ascertain if the file requested for delete exists. If it does not, the error 'TraceFileNotFound' will be returned. If the requested file is currently open, it will not be removed, in such a case the error 'TraceFileNotRemoved' will be returned. Any database errors discovered will be promoted as the returned error of this function. If the returned error is 'nil', then the file was successfully removed.

In the unlikely occurrence that host and file name combination does not yield a unique result, the error 'TraceFileNotUnique' will be returned.

func (*HanaUtilClient) TruncateBackupCatalog

func (h *HanaUtilClient) TruncateBackupCatalog(days int, complete bool) (TruncateStats, error)

TruncateBackupCatalog removes entries from the HANA database backup catalog with the option of permanently destroying associated physical files. A large HANA backup catalog can cause performance issues and is recommended to be <50MiB

type LogSegmentsStats

type LogSegmentsStats struct {
	FreeSegments             uint64
	TotalFreeSegmentBytes    uint64
	NonFreeSegments          uint64
	TotalNonFreeSegmentBytes uint64
}

LogSegmentsStats provides information about how much space is used by freeable and non-freeable log segments in the log volume

type TraceFile

type TraceFile struct {
	Hostname      string
	FileName      string
	FileSizeBytes uint64
	LastModified  time.Time
}

TraceFile is a struct that contains information about a HANA trace file

type TruncateStats

type TruncateStats struct {
	FilesRemoved uint64
	BytesRemoved uint64
}

TruncateStats provided information regarding the number of files and the amount of data removed by truncating the backup catalog

Jump to

Keyboard shortcuts

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