system

package
v0.0.0-...-920a0ca Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Cloud Service Provider short and long names
	// microsoft-azure
	CSPAzure     = "azure"
	CSPAzureLong = "Microsoft Azure"
	// amazon-web-services
	CSPAWS     = "aws"
	CSPAWSLong = "Amazon Web Services"
	// GoogleCloud
	CSPGoogle     = "google"
	CSPGoogleLong = "Google Cloud Platform"
	// OracleCloud
	CSPOVM     = "ovm"
	CSPOVMLong = "Oracle Cloud"
	// Alibaba Cloud
	CSPAlibaba     = "alibaba"
	CSPAlibabaLong = "Alibaba Cloud"
)

constant definitions

View Source
const (
	MemMainTotalKey = "MemTotal"
	MemSwapTotalKey = "SwapTotal"
)

string definitions for parsing /proc/meminfo output

View Source
const (
	SysctlPagecacheLimitMB          = "vm.pagecache_limit_mb"
	SysctlPagecacheLimitIgnoreDirty = "vm.pagecache_limit_ignore_dirty"
	SysctlDirtyRatio                = "vm.dirty_ratio"
	SysctlDirtyBackgroundRatio      = "vm.dirty_background_ratio"
	SysKernelTHPEnabled             = "kernel.mm.transparent_hugepage.enabled"
	SysKSMRun                       = "kernel.mm.ksm.run"
)

mapping of system parameter names to configuration names

View Source
const SaptuneSectionDir = "/run/saptune/sections"

SaptuneSectionDir defines saptunes saved state directory

View Source
const SecurityLimitUnlimitedValue = SecurityLimitInt(-1)

SecurityLimitUnlimitedValue is the constant integer value that represents unrestricted limit.

Variables

View Source
var DmiID = "/sys/class/dmi/id"

DmiID is the path to the dmidecode representation in the /sys filesystem

View Source
var ErrExitOut = errExitOut

ErrExitOut defines the output function, which should be used in case of colored output

View Source
var ErrorExitOut = ErrorLog

ErrorExitOut defines, which exit output function should be used

View Source
var InfoOut = InfoLog

InfoOut defines, which log output function should be used

View Source
var IsMsect = regexp.MustCompile(`^MAX_SECTORS_KB_\w+\-?\d*$`)

IsMsect matches block device max_sectors_kb tag

View Source
var IsNrreq = regexp.MustCompile(`^NRREQ_\w+\-?\d*$`)

IsNrreq matches block device nrreq tag

View Source
var IsRahead = regexp.MustCompile(`^READ_AHEAD_KB_\w+\-?\d*$`)

IsRahead matches block device read_ahead_kb tag

View Source
var IsSched = regexp.MustCompile(`^IO_SCHEDULER_\w+\-?\d*$`)

IsSched matches block device scheduler tag

View Source
var IsXFSOption = regexp.MustCompile(`^xfsopt_\w+$`)

IsXFSOption matches xfs options

View Source
var OSExit = os.Exit

OSExit defines, which exit function should be used

View Source
var SecurityLimitUnlimitedString = []string{"unlimited", "infinity"}

SecurityLimitUnlimitedString are the string constants that represent unrestricted limit.

Functions

func AddGap

func AddGap(writer io.Writer)

AddGap adds an empty line to improve readability of the screen output

func BlockDeviceIsDisk

func BlockDeviceIsDisk(dev string) bool

BlockDeviceIsDisk checks, if a block device is a disk /sys/block/*/device/type (TYPE_DISK / 0x00) does not work for virtio and nvme block devices, needs workaround

func CalledFrom

func CalledFrom() string

CalledFrom returns the name and the line number of the calling source file

func CheckForPattern

func CheckForPattern(file, pattern string) bool

CheckForPattern returns true, if the file is available and contains the expected string

func CheckRpmVers

func CheckRpmVers(vers1, vers2 string) int

CheckRpmVers compare versions of 2 RPMs (installed version, expected version) Return 0 (Equal), 1 (GreaterThan) or -1 (LessThan)

func ChkCliSyntax

func ChkCliSyntax() bool

ChkCliSyntax checks, if command line parameter are in the right order only checking the right position of the 'options' aka 'flags' saptune globOpt realm realmOpt cmd cmdOpt param

func ChkForSysctlDoubles

func ChkForSysctlDoubles(param string) string

ChkForSysctlDoubles checks if the given sysctl parameter is additional set in a sysctl system configuration file

func ChkMD5Pair

func ChkMD5Pair(srcFile, destFile string) bool

ChkMD5Pair checks, if the md5sum of 2 files are equal

func CleanUpRun

func CleanUpRun()

CleanUpRun cleans up runtime files

func CliArg

func CliArg(i int) string

CliArg returns the i-th command line parameter, or empty string if it is not specified.

func CliArgs

func CliArgs(i int) []string

CliArgs returns all remaining command line parameters starting with i, or empty string if it is not specified.

func CmdIsAvailable

func CmdIsAvailable(cmdName string) bool

CmdIsAvailable returns true, if the cmd is available.

func CmpRpmVers

func CmpRpmVers(vers1, vers2 string) bool

CmpRpmVers compare versions of 2 RPMs (installed version, expected version) Return true, if installed package version is equal or higher than expected Return false, if installed package version is less than expected

func CmpServiceStates

func CmpServiceStates(actStates, expStates string) bool

CmpServiceStates compares the expected service states with the current active service states

func CollectBlockDeviceInfo

func CollectBlockDeviceInfo() []string

CollectBlockDeviceInfo collects all needed information about block devices from /sys/block write info to /var/lib/saptune/sections/block.run

func CollectGlobalSysctls

func CollectGlobalSysctls(excludeDirs []string)

CollectGlobalSysctls collects all sysctl parameters defined in all of the sysctl.conf related files

func CopyFile

func CopyFile(srcFile, destFile string) error

CopyFile from source to destination

func DebugLog

func DebugLog(txt string, stuff ...interface{})

DebugLog sents text to the debugLogger and stderr

func EditAndCheckFile

func EditAndCheckFile(srcFileName, destFileName, defName, defType string) (bool, error)

EditAndCheckFile creates or modify note or solution definition files using an editor

func EditFile

func EditFile(srcFile, destFile string) error

EditFile copies a source file to another name and opens this copy in an editor defined by environment variable "EDITOR" or in 'vim'

func ErrLog

func ErrLog(txt string, stuff ...interface{})

ErrLog sents text only to the errorLogger

func ErrorExit

func ErrorExit(template string, stuff ...interface{})

ErrorExit prints the message to stderr and exit 1.

func ErrorLog

func ErrorLog(txt string, stuff ...interface{}) error

ErrorLog sents text to the errorLogger and stderr

func FileIsEmpty

func FileIsEmpty(fileName string) bool

FileIsEmpty returns true, if the given file is empty or does not exist or false, if exist, but not empty

func GetAvailBlockInfo

func GetAvailBlockInfo(info, tag string) []string

GetAvailBlockInfo returns a list of all block devices matching a special tag regarding block device info like VENDOR or MODEL

func GetAvailServices

func GetAvailServices() map[string]string

GetAvailServices returns a map of the available services of the system

func GetBackupValue

func GetBackupValue(fileName string) string

GetBackupValue reads the value from the backup file currently used for the former start TasksMax value

func GetCSP

func GetCSP() string

GetCSP returns the identifier of the cloud service provider of the current running system or an empty string, if the system does not belong to a CSP use files in /sys/class/dmi/id/ instead of dmidecode command

func GetCurrentLogins

func GetCurrentLogins() []string

GetCurrentLogins returns the user ids of the currently logged in users

func GetDmiID

func GetDmiID(file string) (string, error)

GetDmiID return the content of /sys/devices/virtual/dmi/id/<file> or an empty string

func GetFLInfo

func GetFLInfo() (string, string, bool)

GetFLInfo retrieve CPU latency configuration from the system and returns the current latency, the latency states of all CPUs to save latency states for 'revert', if cpu states differ return lat, savedStates, cpuStateDiffer

func GetFiles

func GetFiles(dir string) map[string]string

GetFiles returns the files from a directory as map skip directories

func GetFlagVal

func GetFlagVal(flag string) string

GetFlagVal returns the value of a saptune commandline flag

func GetGovernor

func GetGovernor() map[string]string

GetGovernor retrieve performance configuration regarding to cpu frequency from the system

func GetHWIdentity

func GetHWIdentity(info string) (string, error)

GetHWIdentity returns the hardwar vendor or model of the system needs adaption, if the files to identify the hardware will change or if we need to look at different files for different vendors but the 'open' API GetDmiID exists for workarounds at customer side

func GetMD5Hash

func GetMD5Hash(file string) (string, error)

GetMD5Hash generate the md5sum of a file

func GetMainMemSizeMB

func GetMainMemSizeMB() uint64

GetMainMemSizeMB return size of system main memory, excluding swap. Panic on error.

func GetMountOpts

func GetMountOpts(mustExist bool, fstype, fsopt string) ([]string, []string)

GetMountOpts checks if mount points with the given type exists and contain the needed/not needed option. Returns a list of mount point containing the option and a list of mount point NOT containing the option

func GetNrTags

func GetNrTags(key string) (int, string, string)

GetNrTags returns the value from /sys/block/<bdev>/mq/0/nr_tags and the related scheduler

func GetOsName

func GetOsName() string

GetOsName returns the OS name

func GetOsVers

func GetOsVers() string

GetOsVers returns the OS version

func GetPerfBias

func GetPerfBias() string

GetPerfBias retrieve CPU performance configuration from the system

func GetRpmVers

func GetRpmVers(rpm string) string

GetRpmVers return the version of an installed RPM

func GetSemaphoreLimits

func GetSemaphoreLimits() (msl, mns, opm, mni uint64)

GetSemaphoreLimits return kernel semaphore limits. Panic on error.

func GetServiceName

func GetServiceName(service string) string

GetServiceName returns the systemd service name for supported services

func GetSolutionSelector

func GetSolutionSelector() string

GetSolutionSelector returns the architecture string needed to select the supported set os solutions

func GetSysChoice

func GetSysChoice(parameter string) (string, error)

GetSysChoice read a /sys/ key that comes with current value and alternative choices, return the current choice or empty string.

func GetSysInt

func GetSysInt(parameter string) (int, error)

GetSysInt read an integer /sys/ key.

func GetSysSearchParam

func GetSysSearchParam(syskey string) (string, string)

GetSysSearchParam returns the search pattern for a given sys key and the conterpart section

func GetSysString

func GetSysString(parameter string) (string, error)

GetSysString read a /sys/ key and return the string value.

func GetSysctlInt

func GetSysctlInt(parameter string) (int, error)

GetSysctlInt read an integer sysctl key.

func GetSysctlString

func GetSysctlString(parameter string) (string, error)

GetSysctlString read a sysctl key and return the string value.

func GetSysctlUint64

func GetSysctlUint64(parameter string) (uint64, error)

GetSysctlUint64 read an uint64 sysctl key.

func GetSysctlUint64Field

func GetSysctlUint64Field(param string, field int) (uint64, error)

GetSysctlUint64Field extracts an uint64 value from a sysctl key of many fields.

func GetSystemState

func GetSystemState() (string, error)

GetSystemState returns the output of 'systemctl is-system-running'

func GetTasksMax

func GetTasksMax(userID string) string

GetTasksMax returns the current limit of TasksMax for a given user id which is the value for UserTasksMax

func GetTotalMemSizeMB

func GetTotalMemSizeMB() uint64

GetTotalMemSizeMB return size of system main memory plus swap. Panic on error.

func GetTotalMemSizePages

func GetTotalMemSizePages() uint64

GetTotalMemSizePages return size of system main memory plus swap, in pages. Panic on error.

func GetTunedAdmProfile

func GetTunedAdmProfile() string

GetTunedAdmProfile return the currently active tuned profile. Return empty string if it cannot be determined.

func GetTunedProfile

func GetTunedProfile() string

GetTunedProfile returns the currently active tuned profile by reading the file /etc/tuned/active_profile may be unreliable in newer tuned versions, so better use 'tuned-adm active' Return empty string if it cannot be determined.

func GetVirtStatus

func GetVirtStatus() string

GetVirtStatus gets the status of virtualization environment

func GetdmaLatency

func GetdmaLatency() string

GetdmaLatency retrieve DMA latency configuration from the system

func InfoLog

func InfoLog(txt string, stuff ...interface{})

InfoLog sents text only to the infoLogger

func InitOut

func InitOut(logSwitch map[string]string)

InitOut initializes the various output methodes currently only json and screen are supported

func IsFlagSet

func IsFlagSet(flag string) bool

IsFlagSet returns true, if the flag is available on the command line or false, if not

func IsPagecacheAvailable

func IsPagecacheAvailable() bool

IsPagecacheAvailable check, if system supports pagecache limit

func IsSLE12

func IsSLE12() bool

IsSLE12 returns true, if System is running a SLE12 release

func IsSLE15

func IsSLE15() bool

IsSLE15 returns true, if System is running a SLE15 release

func IsSapconfActive

func IsSapconfActive(sapconf string) bool

IsSapconfActive checks, if sapconf is active

func IsServiceAvailable

func IsServiceAvailable(service string) bool

IsServiceAvailable checks, if a systemd service is available on the system

func IsSystemRunning

func IsSystemRunning() (bool, error)

IsSystemRunning returns true, if 'is-system-running' reports 'running' 'degraded' or 'starting'. In all other cases it returns false, which means: do not call 'start' or 'restart' to prevent 'Transaction is destructive' messages

func IsUserRoot

func IsUserRoot() bool

IsUserRoot return true only if the current user is root.

func JInvalid

func JInvalid(exitStatus int)

JInvalid is the answer of an invalid saptune call used in function action/PrintHelpAndExit

func Jcollect

func Jcollect(data interface{})

Jcollect collects the result data

func JnotSupportedYet

func JnotSupportedYet()

JnotSupportedYet is the answer of a command without json support yet used in function action/SelectAction

func ListDir

func ListDir(dirPath, logMsg string) (dirNames, fileNames []string)

ListDir list directory content and returns a slice for the directory names and a slice for the file names.

func LogInit

func LogInit(logFile string, logSwitch map[string]string)

LogInit initialise the different log writer saptune will use

func MaxI

func MaxI(values ...int) int

MaxI returns the maximum among the input values. If there isn't any input value, return 0.

func MaxI64

func MaxI64(values ...int64) int64

MaxI64 returns the maximum among the input values. If there isn't any input value, return 0.

func MaxU64

func MaxU64(values ...uint64) uint64

MaxU64 returns the maximum among the input values. If there isn't any input value, return 0.

func MinU64

func MinU64(values ...uint64) uint64

MinU64 returns the minimum among the input values. If there isn't any input value, return 0.

func NoticeLog

func NoticeLog(txt string, stuff ...interface{})

NoticeLog sents text to the noticeLogger and stdout

func OutIsTerm

func OutIsTerm(writer *os.File) bool

OutIsTerm returns true, if Stdout is a terminal

func ParseCliArgs

func ParseCliArgs() ([]string, map[string]string)

ParseCliArgs parses the command line to identify special flags and the 'normal' arguments returns a map of Flags (set/not set or value) and a slice containing the remaining arguments possible Flags - force, dryrun, help, version, show-non-compliant, format, colorscheme, non-compliance-check on command line - --force, --dry-run or --dryrun, --help, --version, --color-scheme, --format Some Flags (like 'format') can have a value (--format json or --format csv)

func ParseCmdline

func ParseCmdline(fileName, option string) string

ParseCmdline parse /proc/cmdline into key(string) - value(string) pairs. return value for given boot option or 'NA', if not available

func ParseMeminfo

func ParseMeminfo() (infoMap map[string]uint64)

ParseMeminfo parse /proc/meminfo into key(string) - value(int) pairs. Panic on error.

func ReadConfigFile

func ReadConfigFile(fileName string, autoCreate bool) ([]byte, error)

ReadConfigFile read content of config file

func ReleaseSaptuneLock

func ReleaseSaptuneLock()

ReleaseSaptuneLock removes the saptune lock file

func RemountSHM

func RemountSHM(newSizeMB uint64) error

RemountSHM invoke mount command to resize /dev/shm to the specified value.

func RereadArgs

func RereadArgs()

RereadArgs parses the cli parameter again

func SaptuneLock

func SaptuneLock()

SaptuneLock creates the saptune lock file

func SecureBootEnabled

func SecureBootEnabled() bool

SecureBootEnabled checks, if the system is in lock-down mode

func SetForceLatency

func SetForceLatency(value, savedStates, info string, revert bool) error

SetForceLatency set CPU latency configuration to the system

func SetGovernor

func SetGovernor(value, info string) error

SetGovernor set performance configuration regarding to cpu frequency to the system using 'cpupower' command

func SetPerfBias

func SetPerfBias(value string) error

SetPerfBias set CPU performance configuration to the system using 'cpupower' command

func SetSysInt

func SetSysInt(parameter string, value int) error

SetSysInt write an integer /sys/ value.

func SetSysString

func SetSysString(parameter, value string) error

SetSysString write a string /sys/ value.

func SetSysctlInt

func SetSysctlInt(parameter string, value int) error

SetSysctlInt write an integer sysctl value.

func SetSysctlString

func SetSysctlString(parameter, value string) error

SetSysctlString write a string sysctl value.

func SetSysctlUint64

func SetSysctlUint64(parameter string, value uint64) error

SetSysctlUint64 write an integer sysctl value.

func SetSysctlUint64Field

func SetSysctlUint64Field(param string, field int, value uint64) error

SetSysctlUint64Field write an integer sysctl value into the specified field pf the key.

func SetTasksMax

func SetTasksMax(userID, limit string) error

SetTasksMax sets the limit of TasksMax for a given user id to 'limit'

func StripComment

func StripComment(str, commentChars string) string

StripComment will strip everything right from the given comment character (including the comment character) and returns the resulting string comment characters can be '#' or ';' or something else or a regex like `\s#[^#]|"\s#[^#]`

func SwitchOffLogging

func SwitchOffLogging()

SwitchOffLogging disables logging

func SwitchOffOut

func SwitchOffOut() (*os.File, *os.File)

SwitchOffOut disables stdout and stderr

func SwitchOnOut

func SwitchOnOut(stdout *os.File, stderr *os.File)

SwitchOnOut restores stdout and stderr to the settings before SwitchOffOut was called

func SystemctlDisable

func SystemctlDisable(thing string) error

SystemctlDisable call systemctl disable on thing.

func SystemctlDisableStop

func SystemctlDisableStop(thing string) error

SystemctlDisableStop call systemctl disable and then systemctl stop on thing. Panic on error.

func SystemctlEnable

func SystemctlEnable(thing string) error

SystemctlEnable call systemctl enable on thing.

func SystemctlEnableStart

func SystemctlEnableStart(thing string) error

SystemctlEnableStart call systemctl enable and then systemctl start on thing.

func SystemctlIsActive

func SystemctlIsActive(thing string) (string, error)

SystemctlIsActive returns the output of 'systemctl is-active'

func SystemctlIsEnabled

func SystemctlIsEnabled(thing string) (bool, error)

SystemctlIsEnabled return true only if systemctl suggests that the thing is enabled.

func SystemctlIsRunning

func SystemctlIsRunning(thing string) (bool, error)

SystemctlIsRunning return true only if systemctl suggests that the thing is running.

func SystemctlIsStarting

func SystemctlIsStarting() bool

SystemctlIsStarting return true only if systemctl suggests that the system is starting.

func SystemctlReloadTryRestart

func SystemctlReloadTryRestart(thing string) error

SystemctlReloadTryRestart call systemctl reload on thing.

func SystemctlResetFailed

func SystemctlResetFailed() error

SystemctlResetFailed calls systemctl reset-failed.

func SystemctlRestart

func SystemctlRestart(thing string) error

SystemctlRestart call systemctl restart on thing.

func SystemctlStart

func SystemctlStart(thing string) error

SystemctlStart call systemctl start on thing.

func SystemctlStatus

func SystemctlStatus(thing string) error

SystemctlStatus call systemctl status on thing.

func SystemctlStop

func SystemctlStop(thing string) error

SystemctlStop call systemctl stop on thing.

func SystemdDetectVirt

func SystemdDetectVirt(opt string) (bool, string, error)

SystemdDetectVirt calls systemd-detect-virt. option can be '-r' (chroot), -c (container), -v (vm) '-r' only returns 0 or 1 without any output

func TestSysString

func TestSysString(parameter, value string) error

TestSysString Test writing a string /sys/ value.

func TunedAdmOff

func TunedAdmOff() error

TunedAdmOff calls tuned-adm to switch off the active profile.

func TunedAdmProfile

func TunedAdmProfile(profileName string) error

TunedAdmProfile calls tuned-adm to switch to the specified profile. newer versions of tuned seems to be reliable with this command and they changed the behaviour/handling of the file /etc/tuned/active_profile

func WarningLog

func WarningLog(txt string, stuff ...interface{})

WarningLog sents text to the warningLogger and stderr

func Watch

func Watch() string

Watch prints the current time

func WrapTxt

func WrapTxt(text string, width int) (folded []string)

WrapTxt implements something like 'fold' command A given text string will be wrapped at word borders into lines of a given width

func WriteBackupValue

func WriteBackupValue(value, fileName string)

WriteBackupValue writes a value into the backup file currently used for the former start TasksMax value

func WriteTunedAdmProfile

func WriteTunedAdmProfile(profileName string) error

WriteTunedAdmProfile write new profile to tuned, used instead of sometimes unreliable 'tuned-adm' command

Types

type BlockDev

type BlockDev struct {
	AllBlockDevs    []string
	BlockAttributes map[string]map[string]string
}

BlockDev contains all key-value pairs of current available block devices in /sys/block

func GetBlockDeviceInfo

func GetBlockDeviceInfo() (*BlockDev, error)

GetBlockDeviceInfo reads content of stored block device information. content stored in SaptuneSectionDir (/run/saptune/sections) as blockdev.run Return the content as BlockDev

type JAppliedSol

type JAppliedSol struct {
	SolName string `json:"Solution ID,omitempty"`
	Partial *bool  `json:"applied partially,omitempty"`
}

JAppliedSol is for 'Solution applied' in 'saptune status' and 'saptune solution applied'

type JEntry

type JEntry struct {
	// URI to the schema definition
	Schema string `json:"$schema"`
	// saptune timestamp of the time this JSON object was created
	Created string `json:"publish time"`
	// The entire saptune command as it was called
	CmdLine string `json:"argv"`
	// PID of the saptune process creating this object
	Pid int `json:"pid"`
	// The saptune command (classifier), which was execute
	// realm + command, no options, no parameter
	Cmd string `json:"command"`
	// The return code the saptune command terminated with
	CmdRet int `json:"exit code"`
	// The result (output) of the command.
	CmdResult JResult `json:"result"`
	//Contains all log messages normally printed on the screen in the
	// order they were created
	CmdMsg JMessages `json:"messages"`
}

JEntry defines the global structure of our json object

type JFootNotes

type JFootNotes struct {
	FNoteNumber int    `json:"index,omitempty"`
	FNoteTxt    string `json:"amendment,omitempty"`
}

JFootNotes collects the footnotes per parameter

type JMessages

type JMessages []JMsg

JMessages contains all log messages normally printed on the screen in the order they were created

type JMsg

type JMsg struct {
	// Priority of the log messages as defined AT
	// https://confluence.suse.com/display/SAP/Logging+Guide"
	// "CRITICAL", "ERROR" ,"WARNING" ,"NOTICE" ,"INFO", "DEBUG"
	Prio string `json:"priority"`
	// The log message itself
	Txt string `json:"message"`
}

JMsg is a single log message and it's severity/priority

type JNoteList

type JNoteList struct {
	NotesList  []JNoteListEntry `json:"Notes available"`
	NotesOrder []string         `json:"Notes enabled"`
	Msg        string           `json:"remember message"`
}

JNoteList is the whole 'saptune note list'

type JNoteListEntry

type JNoteListEntry struct {
	NoteID       string `json:"Note ID"`
	NoteDesc     string `json:"Note description"`
	NoteRef      JObj   `json:"Note reference"`
	NoteVers     string `json:"Note version"`
	NoteRdate    string `json:"Note release date"`
	ManEnabled   bool   `json:"Note enabled manually"`
	SolEnabled   bool   `json:"Note enabled by Solution"`
	ManReverted  bool   `json:"Note reverted manually"`
	NoteOverride bool   `json:"Note override exists"`
	CustomNote   bool   `json:"custom Note"`
}

JNoteListEntry is one line of 'saptune note list'

func JNoteListEntryInit

func JNoteListEntryInit() JNoteListEntry

JNoteListEntryInit initialises a JNoteListEntry variable used in NoteActionList

type JObj

type JObj interface{}

JObj is a string, a string pointer or a bool for some parts in the result of the command.

type JPNotes

type JPNotes struct {
	Verifications []JPNotesLine   `json:"verifications"`
	Simulations   []JPNotesLine   `json:"simulations,omitempty"`
	Attentions    []JPNotesRemind `json:"attentions"`
	NotesOrder    []string        `json:"Notes enabled"`
	SysCompliance *bool           `json:"system compliance"`
}

JPNotes is the whole 'PrintNoteFields' function if we need to differ between 'verify' and 'simulate' this can be done in PrintNoteFields' or in jcollect.

type JPNotesLine

type JPNotesLine struct {
	NoteID    string       `json:"Note ID,omitempty"`
	NoteVers  string       `json:"Note version,omitempty"`
	Parameter string       `json:"parameter"`
	Compliant *bool        `json:"compliant,omitempty"`
	ExpValue  string       `json:"expected value,omitempty"`
	OverValue string       `json:"override value,omitempty"`
	ActValue  *string      `json:"actual value,omitempty"`
	Comment   string       `json:"comment,omitempty"`
	Footnotes []JFootNotes `json:"amendments,omitempty"`
}

JPNotesLine one row of 'saptune note verify|simulate' from PrintNoteFields

type JPNotesRemind

type JPNotesRemind struct {
	NoteID       string `json:"Note ID,omitempty"`
	NoteReminder string `json:"attention,omitempty"`
}

JPNotesRemind is the reminder section

type JResult

type JResult interface{}

JResult is the result (output) of the command.

type JSol

type JSol struct {
	SolName   string   `json:"Solution ID"`
	NotesList []string `json:"Note list"`
}

JSol - Solution name and related Note list

type JSolList

type JSolList struct {
	SolsList []JSolListEntry `json:"Solutions available"`
	Msg      string          `json:"remember message"`
}

JSolList is the whole 'saptune solution list'

type JSolListEntry

type JSolListEntry struct {
	SolName     string   `json:"Solution ID"`
	NotesList   []string `json:"Note list"`
	SolEnabled  bool     `json:"Solution enabled"`
	SolOverride bool     `json:"Solution override exists"`
	CustomSol   bool     `json:"custom Solution"`
	DepSol      bool     `json:"Solution deprecated"`
}

JSolListEntry is one line of 'saptune solution list'

type JStatus

type JStatus struct {
	Services        JStatusServs   `json:"services"`
	SystemdSysState string         `json:"systemd system state"`
	TuningState     string         `json:"tuning state"`
	VirtEnv         string         `json:"virtualization"`
	SaptuneVersion  string         `json:"configured version"`
	RPMVersion      string         `json:"package version"`
	ConfiguredSol   []string       `json:"Solution enabled"`
	ConfSolNotes    []JSol         `json:"Notes enabled by Solution"`
	AppliedSol      []JAppliedSol  `json:"Solution applied"`
	AppliedSolNotes []JSol         `json:"Notes applied by Solution"`
	ConfiguredNotes []string       `json:"Notes enabled additionally"`
	EnabledNotes    []string       `json:"Notes enabled"`
	AppliedNotes    []string       `json:"Notes applied"`
	Staging         JStatusStaging `json:"staging"`
	Msg             string         `json:"remember message"`
}

JStatus is the whole 'saptune status'

type JStatusServs

type JStatusServs struct {
	SaptuneService JObj    `json:"saptune"`
	SapconfService JObj    `json:"sapconf"`
	TunedService   JObj    `json:"tuned"`
	TunedProfile   *string `json:"tuned profile,omitempty"`
}

JStatusServs are the mentioned systemd services in 'saptune status'

type JStatusStaging

type JStatusStaging struct {
	StagingEnabled bool     `json:"staging enabled"`
	StagedNotes    []string `json:"Notes staged"`
	StagedSols     []string `json:"Solutions staged"`
}

JStatusStaging contains the staging infos for 'saptune status'

type MountPoint

type MountPoint struct {
	Device     string
	MountPoint string
	Type       string
	Options    []string
	Dump       int
	Fsck       int
}

MountPoint Represent a mount point entry in /proc/mounts or /etc/fstab

func (MountPoint) Equals

func (mount1 MountPoint) Equals(mount2 MountPoint) bool

Equals return true only if two mount points are identical in all attributes.

func (MountPoint) GetFileSystemSizeMB

func (mount MountPoint) GetFileSystemSizeMB() uint64

GetFileSystemSizeMB return the total size of the file system in MegaBytes. Panic on error.

type MountPoints

type MountPoints []MountPoint

MountPoints contains a list of mount points.

func ParseFstab

func ParseFstab() MountPoints

ParseFstab return all mount points defined in /etc/fstab. Returns empty list of mount points

func ParseMounts

func ParseMounts(txt string) (mounts MountPoints)

ParseMounts return all mount points defined in the input text. Skipping malformed entry.

func ParseMtab

func ParseMtab(file string) MountPoints

ParseMtab return all mount points defined in a given file. Returns empty list of mount points on error

func ParseMtabMounts

func ParseMtabMounts() MountPoints

ParseMtabMounts return all mount points appearing in /etc/mtab. Returns empty list of mount points

func ParseProcMounts

func ParseProcMounts() MountPoints

ParseProcMounts return all mount points appearing in /proc/mounts. Returns empty list of mount points

func (MountPoints) GetByMountOption

func (mounts MountPoints) GetByMountOption(fstype, mountOption, chkDflt string) ([]string, []string)

GetByMountOption find a mount point with special mount option. returns a list of mount points containing the option and a second list with mount points missing the option.

func (MountPoints) GetByMountPoint

func (mounts MountPoints) GetByMountPoint(mountPoint string) (MountPoint, bool)

GetByMountPoint find a mount point by its path.

type SecLimits

type SecLimits struct {
	Entries []*SecLimitsEntry
}

SecLimits Entries of security/limits.conf file. It is able to convert back to original text in the original entry order.

func ParseSecLimits

func ParseSecLimits(input string) *SecLimits

ParseSecLimits read limits.conf text and parse the text into memory structures.

func ParseSecLimitsFile

func ParseSecLimitsFile(fileName string) (*SecLimits, error)

ParseSecLimitsFile read limits.conf and parse the file content into memory structures.

func (*SecLimits) Apply

func (limits *SecLimits) Apply() error

Apply overwrite /etc/security/limits.conf with the content of this structure.

func (*SecLimits) ApplyDropIn

func (limits *SecLimits) ApplyDropIn(lim []string, noteID string) error

ApplyDropIn overwrite file 'dropInFile' with the content of this structure.

func (*SecLimits) Get

func (limits *SecLimits) Get(domain, typeName, item string) (string, bool)

Get return string value that belongs to the entry.

func (*SecLimits) GetOr0

func (limits *SecLimits) GetOr0(domain, typeName, item string) SecurityLimitInt

GetOr0 retrieves an integer limit value and return. If the value is not specified or cannot be parsed correctly, 0 will be returned.

func (*SecLimits) Set

func (limits *SecLimits) Set(domain, typeName, item, value string)

Set value for an entry. If the entry does not yet exist, it is created.

func (*SecLimits) ToDropIn

func (limits *SecLimits) ToDropIn(lim []string, noteID, fileName string) string

ToDropIn convert the entries back into text.

func (*SecLimits) ToText

func (limits *SecLimits) ToText() string

ToText convert the entries back into text.

type SecLimitsEntry

type SecLimitsEntry struct {
	LeadingComments    []string // The comment lines leading to the key-value pair, including prefix '#', excluding end-of-line.
	Domain, Type, Item string
	Value              string
}

SecLimitsEntry is a single entry in security/limits.conf file.

type SecurityLimitInt

type SecurityLimitInt int

SecurityLimitInt is an integer number where -1 represents unlimited value.

func ToSecurityLimitInt

func ToSecurityLimitInt(in string) SecurityLimitInt

ToSecurityLimitInt interprets integer limit number from input string. If the input cannot be parsed successfully, it will return a default 0 value.

func (SecurityLimitInt) String

func (limit SecurityLimitInt) String() string

Jump to

Keyboard shortcuts

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