Documentation
¶
Index ¶
- Constants
- func Abs(i geneos.Instance, file string) (result string)
- func BaseVersion(i geneos.Instance) (dir string)
- func BuildCmd(i geneos.Instance, noDecode bool, options ...StartOptions) (cmd *exec.Cmd, err error)
- func ByPort(h *geneos.Host, port uint16) (i geneos.Instance, err error)
- func CheckPaths(i geneos.Instance, paths []string) (missing []string)
- func Clean(i geneos.Instance, full bool) (err error)
- func CompareVersion(i geneos.Instance, version string) int
- func ComponentFilename(i geneos.Instance, extensions ...string) string
- func ComponentFilepath(i geneos.Instance, extensions ...string) string
- func ConfigFileType() (conftype string)
- func ConfigFileTypes() []string
- func Copy(ct *geneos.Component, source, destination string, options ...CopyOptions) (err error)
- func CreateAESKeyFile(i geneos.Instance) (err error)
- func DeleteSettingFromMap(i geneos.Instance, from map[string]any, key string)
- func Disable(i geneos.Instance) (err error)
- func DisplayName(i geneos.Instance) string
- func Do(h *geneos.Host, ct *geneos.Component, names []string, ...) (rs responses.Responses)
- func DoInstances(instances []geneos.Instance, ...) (rs responses.Responses)
- func Enable(i geneos.Instance) (err error)
- func ExecuteTemplate(i geneos.Instance, outputPath string, name string, defaultTemplate []byte, ...) (err error)
- func FileOf(i geneos.Instance, name string) (filename string)
- func Get(ct *geneos.Component, name string) (instance geneos.Instance, err error)
- func GetAllPorts(h *geneos.Host) (ports map[uint16]bool)
- func GetLivePID(i geneos.Instance) (pid int, err error)
- func GetPID(i geneos.Instance) (pid int, err error)
- func GetPIDInfo(i geneos.Instance) (pid int, uid, gid int, mtime time.Time, err error)
- func GetWithHost(h *geneos.Host, ct *geneos.Component, name string) (instance geneos.Instance, err error)
- func Home(i geneos.Instance) (home string)
- func IDString(i geneos.Instance) string
- func ImportFiles(s geneos.Instance, files ...string) (err error)
- func InstanceNames(h *geneos.Host, ct *geneos.Component) (names []string)
- func Instances(h *geneos.Host, ct *geneos.Component, options ...InstanceOptions) (instances []geneos.Instance)
- func IsA(i geneos.Instance, names ...string) bool
- func IsAutoStart(i geneos.Instance) bool
- func IsDisabled(i geneos.Instance) bool
- func IsProtected(i geneos.Instance) bool
- func IsRunning(i geneos.Instance) bool
- func ListeningPorts(i geneos.Instance) (ports []int)
- func ListeningPortsStrings(i geneos.Instance) (ports []string)
- func LiveVersion(i geneos.Instance, pid int) (base string, version string, actual string, err error)
- func LogFilePath(i geneos.Instance) (logfile string)
- func Match(h *geneos.Host, ct *geneos.Component, keepHosts bool, mustMatch bool, ...) (names []string, err error)
- func Migrate(i geneos.Instance) (resp *responses.Response)
- func NewCertificate(i geneos.Instance, options ...certs.TemplateOption) (resp *responses.Response)
- func NextFreePort(h *geneos.Host, ct *geneos.Component) uint16
- func ParseName(name string, defaultHost ...*geneos.Host) (host *geneos.Host, ct *geneos.Component, instance string)
- func PathTo(i geneos.Instance, name string) string
- func PathsTo(i geneos.Instance, names ...string) (filenames []string)
- func ProcessStatus(i geneos.Instance, pstats any) (err error)
- func Read(i geneos.Instance) (err error)
- func ReadAESKeyFile(i geneos.Instance, setting ...string) (keyfile config.KeyFile, kv *config.KeyValues, crc uint32, err error)
- func ReadCertificates(i geneos.Instance, ext ...string) (certChain []*x509.Certificate, err error)
- func ReadCertificatesWithKey(i geneos.Instance, ext ...string) (certChain []*x509.Certificate, key *memguard.Enclave, err error)
- func ReadKVConfig(r host.Host, p string) (kvs map[string]string, err error)
- func ReadLeafCertificate(i geneos.Instance, ext ...string) (cert *x509.Certificate, err error)
- func ReadPrivateKey(i geneos.Instance, ext ...string) (key *memguard.Enclave, err error)
- func ReadRCConfig(r host.Host, cf *config.Config, p string, prefix string, ...) (err error)
- func RefactorConfig(h *geneos.Host, ct *geneos.Component, cf *config.Config, ...) (err error)
- func RemovePaths(i geneos.Instance, list ...string) (err error)
- func ReservedName(name string) (ok bool)
- func RollAESKeyFile(i geneos.Instance, nkv *config.KeyValues, backup string) (keyfile config.KeyFile, crc uint32, err error)
- func RollFiles(i geneos.Instance, newSuffix, oldSuffix string, params ...string) (err error)
- func SecureArgs(i geneos.Instance) (args []string, env []string, fileChecks []string, err error)
- func SetDefaults(i geneos.Instance, name string) (err error)
- func SetInstanceValues(i geneos.Instance, set SetConfigValues, k config.KeyFile) (err error)
- func Shared(i geneos.Instance, subs ...any) string
- func ShortName(i geneos.Instance) string
- func Signal(i geneos.Instance, signal syscall.Signal) (err error)
- func Start(i geneos.Instance, opts ...any) (err error)
- func Stop(i geneos.Instance, force, kill bool) (err error)
- func UnsetInstanceValues(i geneos.Instance, unset UnsetConfigValues) (changed bool)
- func ValidName(name string) bool
- func Version(i geneos.Instance) (base string, version string, err error)
- func Write(i geneos.Instance) (err error)
- func WriteAESKeyFile(i geneos.Instance, kv *config.KeyValues) (keyfile config.KeyFile, crc uint32, err error)
- func WriteCertificateAndKey(i geneos.Instance, key *memguard.Enclave, certChain ...*x509.Certificate) (err error)
- func WriteKVConfig(r host.Host, p string, kvs map[string]string) (err error)
- type ConfigOption
- type CopyOptions
- type Filename
- type Gateways
- type Includes
- type Instance
- type InstanceOptions
- type NameValues
- type ProcessFDs
- type ProcessStats
- type SecureValue
- type SecureValues
- type SetConfigValues
- type SocketConnection
- type StartOptions
- type Types
- type UnsetConfigValues
- type UnsetValues
- type UnsetVars
- type VarValue
- type Vars
Constants ¶
const ( TCP_ESTABLISHED TCP_SYN_SENT TCP_SYN_RECV TCP_FIN_WAIT1 TCP_FIN_WAIT2 TCP_TIME_WAIT TCP_CLOSE TCP_CLOSE_WAIT TCP_LAST_ACK TCP_LISTEN TCP_CLOSING TCP_NEW_SYN_RECV )
from linux net/tcp_states.h
const ( TLSBASE = "tls" CERTIFICATE = "certificate" PRIVATEKEY = "privatekey" TLSVERIFY = "verify" CABUNDLE = "ca-bundle" CERTCHAIN = "certchain" )
const AttributesOptionsText = "Attribute in the format NAME=VALUE\n(Repeat as required, san only)"
const EnvsOptionsText = "Environment variable for instance start-up\n(Repeat as required)"
const GatewaysOptionstext = "A gateway connection in the format HOSTNAME:PORT\n(Repeat as required, san and floating only)"
const HeadersOptionsText = "HTTP header in the format NAME=VALUE\n(Repeat as required)"
const IncludeValuesOptionsText = "An include file in the format `PRIORITY:[PATH|URL]`\n(Repeat as required, gateway only)"
IncludeValuesOptionsText is the default help text for command to use for options setting include files
const TypesOptionsText = "A type NAME\n(Repeat as required, san only)"
const VarsOptionsText = "A variable in the format [TYPE:]NAME=VALUE\n(Repeat as required, san only)"
Variables ¶
This section is empty.
Functions ¶
func Abs ¶
Abs returns an absolute path to file prepended with the instance working directory if file is not already an absolute path. If file is empty then an empty result is returned.
func BaseVersion ¶ added in v1.6.0
BaseVersion returns the absolute path of the base package directory for the instance i.
func BuildCmd ¶
BuildCmd gathers the path to the binary, arguments and any environment variables for an instance and returns an exec.Cmd, almost ready for execution. Callers will add more details such as working directories, user and group etc.
If noDecode is set then any secure environment variables are not decoded, so can be used for display to a user without revealing secrets.
Any extras arguments are appended without further checks
func ByPort ¶ added in v1.26.1
ByPort returns an instance on host h that is configured to use port. Returns an error if no instance is found or if the configuration cannot be loaded for any instance on the host. Will not check if the port is actually in use by any process.
func CheckPaths ¶ added in v1.14.2
CheckPaths checks paths for an existing file or directory, returning a list of missing paths. The check performed is a simple stat() for now.
func Clean ¶
Clean removes all the files and directories listed in the component type of the instance i for removal. First all entries in the CleanList are removed and then, if full is true, the instance is stopped and the entries in FullClean are removed. Any instances stopped are started up, but any that were already stopped will be left stopped.
func CompareVersion ¶ added in v1.4.1
CompareVersion returns -1, 0 or +1 if the version of the instance is less than, equal or greater than version respectively.
func ComponentFilename ¶
ComponentFilename returns the filename for the component used by the instance i with the extensions appended, joined with a ".". If no extensions are given then the current configuration file type is used, e.g. "json" or "yaml".
func ComponentFilepath ¶
ComponentFilepath returns an absolute path to a file named for the component type of the instance with any extensions joined using ".", e.g. is c is a netprobe instance then
path := instance.ComponentFilepath(c, "xml", "orig")
will return /path/to/netprobe/netprobe.xml.orig
If no extensions are passed then the default us to add an extension of the instance.ConfigType, which defaults to "json", e.g. using the same instance as above:
path := instance.ComponentPath(c)
will return /path/to/netprobe/netprobe.json
func ConfigFileType ¶ added in v1.4.1
func ConfigFileType() (conftype string)
ConfigFileType returns the configuration file extension, defaulting to "json" if not set.
func ConfigFileTypes ¶ added in v1.4.1
func ConfigFileTypes() []string
ConfigFileTypes contains a list of supported configuration file extensions
func Copy ¶ added in v1.7.0
func Copy(ct *geneos.Component, source, destination string, options ...CopyOptions) (err error)
Copy copies the instance named source to destination for component type ct. If the move argument is true then the source is deleted after the copy.
Both source and destination can include host labels as well as being only host labels to indicate all instances of type ct on that host. If source is in the form `@host` then destination must also be a host - and different - or the function returns an error, but is it valid to have a specific source and a destination of only `@host` and then the name of the instance is used, as with file system operations on files and directories normally.
If ct is nil that all component types are considered
func CreateAESKeyFile ¶ added in v1.13.0
CreateAESKeyFile creates a new key file, for secure passwords as per https://docs.itrsgroup.com/docs/geneos/current/Gateway_Reference_Guide/gateway_secure_passwords.htm
func DeleteSettingFromMap ¶ added in v1.4.1
DeleteSettingFromMap removes key from the map from and if it is registered as an alias it also removes the key that alias refers to.
func Disable ¶ added in v1.5.0
Disable the instance i. Does not try to stop a running instance and returns an error if it is running.
func DisplayName ¶
DisplayName returns the type, name and non-local host as a string suitable for display.
func Do ¶ added in v1.8.0
func Do(h *geneos.Host, ct *geneos.Component, names []string, f func(geneos.Instance, ...any) *responses.Response, values ...any) (rs responses.Responses)
Do calls function f for each matching instance and gathers the return values into responses for handling by the caller. The functions are executed in goroutines and must be concurrency safe.
The values are passed to each function called and must not be changes by the called function. The called function should validate and cast values for use.
Do calls Instances() to resolve the names given to a list of matching instances on host h (which can be geneos.ALL to look on all hosts) and for type ct, which can be nil to look across all component types.
func DoInstances ¶ added in v1.26.1
func DoInstances(instances []geneos.Instance, f func(geneos.Instance, ...any) *responses.Response, values ...any) (rs responses.Responses)
DoInstances is a variant of Do that takes a slice of instances instead of looking them up by host, type and name. This is for use by functions that have already looked up instances and want to call a function on them concurrently.
func ExecuteTemplate ¶ added in v1.7.0
func ExecuteTemplate(i geneos.Instance, outputPath string, name string, defaultTemplate []byte, perms os.FileMode) (err error)
ExecuteTemplate loads the template name from the component `templates` directory on the host for the instance i, parses it and executes it, writing the results to outputPath with the given permissions. If a template file is not found on the host, the defaultTemplate is used instead.
The output file is first written to a temporary file with a ".new" suffix, which is then renamed to the final outputPath with the permissions perms.
If an error occurs, any temporary file is removed and the error returned. The existing outputPath file is not modified until the final rename step.
func FileOf ¶ added in v1.7.0
FileOf returns the basename of the file identified by the instance parameter name.
If the parameter is unset or empty then an empty path is returned.
func Get ¶
Get return instance `name` of component type ct, and loads the config. It is an error if the config cannot be loaded. The instance is loaded from the host given in the name after any '@' or, if none, localhost is used.
func GetAllPorts ¶ added in v1.9.0
GetAllPorts gets all used ports in config files on a specific remote and also all listening ports on the same host. Returns a map of port to bool "true" for each lookup.
func GetLivePID ¶ added in v1.14.2
GetLivePID returns the PID of the process running for the instance. It resets the process cache to ensure the check is live. If not found then an err of os.ErrProcessDone is returned.
The process is identified by checking the conventions used to start Geneos processes. If a component type defines it's own GetPID() custom check then that is used instead.
func GetPID ¶
GetPID returns the PID of the process running for the instance. If not found then an err of os.ErrProcessDone is returned.
The process is identified by checking the conventions used to start Geneos processes. If a component type defines it's own GetPID() custom check then that is used instead.
func GetPIDInfo ¶
GetPIDInfo returns the PID of the process for the instance i along with the owner uid and gid and the start time.
func GetWithHost ¶ added in v1.14.2
func GetWithHost(h *geneos.Host, ct *geneos.Component, name string) (instance geneos.Instance, err error)
GetWithHost return instance of component type ct from host h and loads the config. It is an error if the config cannot be loaded. If name has an embedded "@HOST" it must match h, else that is an error.
func Home ¶ added in v1.7.0
Home return the directory for the instance. It checks for the first existing directory from:
- The one configured for the instance factory and in the configuration parameter "home"
- In the default component instances directory (component.InstanceDir)
- If the instance's component type has a parent component then in the legacy instances directory
If no directory is found then a default built using PathTo() is returned
func IDString ¶ added in v1.14.2
IDString returns a string suitable as a unique rowname for Toolkit output and other places. For local instance it return `TYPE:NAME` and for remote instances it returns `TYPE:NAME@HOST`
func InstanceNames ¶ added in v1.14.2
InstanceNames returns a slice of all the base names for instance directories for a given component ct on host h. No checking is done to validate that the directory contains a valid instance. InstanceNames are qualified with the host name. Regular files are ignored.
To support the move to parent types we do a little more, looking for legacy locations in here
func Instances ¶ added in v1.14.2
func Instances(h *geneos.Host, ct *geneos.Component, options ...InstanceOptions) (instances []geneos.Instance)
Instances returns a slice of all instances on host h of component type ct, where both can be nil in which case all hosts or component types are used respectively. The options allow filtering based on names or parameter matches.
func IsA ¶ added in v1.5.0
IsA returns true if instance i has a type that is component of one of names.
func IsAutoStart ¶ added in v1.6.1
IsAutoStart returns true is the instance is set to autostart
func IsDisabled ¶
IsDisabled returns true if the instance i is disabled.
func IsProtected ¶
IsProtected returns true if instance i is marked protected
func ListeningPorts ¶ added in v1.6.3
ListeningPorts returns all TCP ports currently open for the process running as the instance. An empty slice is returned if the process cannot be found. The instance may be on a remote host.
func ListeningPortsStrings ¶ added in v1.7.0
ListeningPorts returns all TCP ports currently open for the process running as the instance. An empty slice is returned if the process cannot be found. The instance may be on a remote host.
func LiveVersion ¶ added in v1.7.0
func LiveVersion(i geneos.Instance, pid int) (base string, version string, actual string, err error)
LiveVersion returns the base package name, the underlying package version and the actual version in use for the instance i. If base is not a link, then base is also returned as the symlink. If there are more than 10 levels of symlink then return symlink set to "loop-detected" and err set to syscall.ELOOP to prevent infinite loops. If the instance is not running or the executable path cannot be determined then actual will be returned as "unknown".
func LogFilePath ¶ added in v1.7.0
LogFilePath returns the full path to the log file for the instance.
func Match ¶
func Match(h *geneos.Host, ct *geneos.Component, keepHosts bool, mustMatch bool, patterns ...string) (names []string, err error)
Match applies file glob patterns to all instance names (stripped of hostname) on the host h and of the component type ct and returns all matches. Valid patterns are the same as for path.Match.
The returned slice is sorted and duplicates are removed.
Patterns that resolve to empty (e.g. @hostname) are returned unchanged and unchecked against valid names.
Patterns that have no globbing special characters are returned as-is and the caller is expected to validate them.
func Migrate ¶
Migrate is a helper that checks if the configuration was loaded from a legacy .rc file and if it has it then saves the current configuration (it does not reload the .rc file) in a new format file and renames the .rc file to .rc.orig to allow Revert to work.
Also now check if instance directory path has changed. If so move it.
func NewCertificate ¶ added in v1.26.1
NewCertificate creates a new certificate for an instance.
this also creates a new private key
skip if certificate exists and is valid
func NextFreePort ¶ added in v1.14.2
NextFreePort returns the next available (unallocated and unused) TCP listening port for component ct on host h.
The range of ports available for a component is defined in the configuration for the user and for each component type. A port is available if it is neither allocated to any other instance on the same host (of any component type) and also is not in use by any other process which may not be a Geneos instance.
Each range is a comma separated list of single port number, e.g. "7036", a min-max inclusive range, e.g. "7036-8036" or a 'start-' open ended range, e.g. "7041-". Ranges can also be denoted by double-dot in addition to single dashes '-'.
some limits based on https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
not concurrency safe at this time
func ParseName ¶ added in v1.26.1
func ParseName(name string, defaultHost ...*geneos.Host) (host *geneos.Host, ct *geneos.Component, instance string)
ParseName returns the parts of an instance name in the format [TYPE:]NAME[@HOST]. ct defaults to nil and host to localhost unless an optional default host is passed as a var arg.
func PathTo ¶ added in v1.26.1
PathTo returns the full path to the file identified by the configuration parameter name. If the parameters value is already an absolute path then it is returned as-is, otherwise it is joined with the home directory of the instance and returned. The path is only useful on the host that instance i is on.
If the parameter is unset or empty then an empty path is returned.
func PathsTo ¶ added in v1.26.1
PathsTo returns the full paths to the files identified by names.
If the instance configuration is valid an empty slice is returned. If a parameter is unset or empty then an empty path is returned.
func ProcessStatus ¶ added in v1.14.2
ProcessStatus reads the instance process `stats` and `status` files in /proc and returns values that match the tags in the structure pstats. pstats must be a point to a struct and must be initialised before calling. Use the instance.ProcessStats struct as a useful default.
func Read ¶ added in v1.26.1
Read will load the instance config file if available, otherwise try to load the "legacy" .rc file. The instance struct must be initialised before the call.
The modtime of the underlying config file is recorded in ConfigLoaded and checked before re-loading
support cache?
error check core values - e.g. Name
func ReadAESKeyFile ¶ added in v1.13.0
func ReadAESKeyFile(i geneos.Instance, setting ...string) (keyfile config.KeyFile, kv *config.KeyValues, crc uint32, err error)
ReadAESKeyFile locates the path to the keyfile in the instance configuration, using the first setting if passed otherwise defaulting to `keyfile`. If found, return the key values in kv or an error,
func ReadCertificates ¶ added in v1.26.1
ReadCertificates reads the instance certificate and returns a slice of certificates.
For older Geneos versions that do not support full chains, this will check for an also load a chain file. The chain file path is taken from the `certchain` parameter if set and no optional extensions are added.
func ReadCertificatesWithKey ¶ added in v1.26.1
func ReadKVConfig ¶ added in v1.13.0
ReadKVConfig reads a file containing key=value lines, returning a map of key to value. We need this to preserve the case of keys, which viper forces to lowercase, when writing this file back out via WriteKVConfig().
func ReadLeafCertificate ¶ added in v1.26.1
ReadLeafCertificate reads the instance certificate and returns the leaf certificate.
func ReadPrivateKey ¶ added in v1.26.1
ReadPrivateKey reads the instance RSA private key
func ReadRCConfig ¶ added in v1.8.0
func ReadRCConfig(r host.Host, cf *config.Config, p string, prefix string, aliases map[string]string) (err error)
ReadRCConfig reads an old-style, legacy Geneos "ctl" layout configuration file and sets values in cf corresponding to updated equivalents.
All empty lines and those beginning with "#" comments are ignored.
The rest of the lines are treated as `name=value` pairs and are processed as follows:
- If `name` is either `binsuffix` (case-insensitive) or `prefix`+`name` then it saved as a config item. This is looked up in the `aliases` map and if there is a match then this new name is used.
- All other `name=value` entries are saved as environment variables in the configuration for the instance under the `Env` key.
func RefactorConfig ¶ added in v1.26.1
func RefactorConfig(h *geneos.Host, ct *geneos.Component, cf *config.Config, options ...ConfigOption) (err error)
RefactorConfig updates the instance config cf for the new instance name and directory, based on the old home value in the config file and the new home value based on the destination instance directory.
Unless the option config.KeepPort() is passed, ports are updated to avoid clashes with existing instances on the destination host. Paths are updated based on the old home value in the config file and the new home value based on the destination instance directory. Ports are updated to avoid clashes with existing instances on the destination host. Legacy parameters are removed.
Any `user` setting is removed from the config, as this is no longer supported.
All paths with a instance directory prefix are updated to use `${config:home}` instead.
`libpaths` is updated to replace any paths with the old install prefix to use `${config:install}` instead, and any paths with the old version suffix to use `${config:version}` instead.
func RemovePaths ¶
RemovePaths removes all files and directories in paths, each file or directory is separated by ListSeperator
func ReservedName ¶
ReservedName returns true if name is a reserved word. Reserved names are checked against all the values registered by components at start-up.
func RollAESKeyFile ¶ added in v1.13.0
func RollAESKeyFile(i geneos.Instance, nkv *config.KeyValues, backup string) (keyfile config.KeyFile, crc uint32, err error)
RollAESKeyFile moves any existing instance key file to a "previous" filename unless it is in a shared keyfiles directory, in which case it sets `prevkeyfile` to this path and saves the new key file values nkv to the instance directory.
Otherwise, the current keyfile is renamed to a file where the backup string is appended to the base name before the extension and the key file values nkv are written to a new file and the instance settings updated.
func RollFiles ¶ added in v1.26.1
RollFiles atomically rolls files indicated by params with the given suffixes for the instance. The newSuffix files are moved to the active files, and existing active files are backed up with the oldSuffix. If an error occurs, any files that were successfully rolled are unrolled back to their original state.
Each file is rolled individually and atomically using a lock directory to prevent concurrent modifications. If any file fails to roll, the function attempts to unroll (revert) all previously rolled files in this operation by calling itself with swapped suffixes and the list of completed files. A lock directory is created for each file, but not for the whole operation.
func SecureArgs ¶ added in v1.26.1
SecureArgs returns command line arguments, environment variables, and any files that need to be checked for secure connections based on the TLS configuration of the instance.
If the instance has not been migrated to the new TLS parameters then it calls SetSecureArgs() instead, but with the addition of file checks for any args that are not prefixed with a dash (`-`).
func SetDefaults ¶
SetDefaults is a common function called by component factory functions to iterate over the component specific instance struct and set the defaults as defined in the 'defaults' struct tags.
func SetInstanceValues ¶ added in v1.7.0
SetInstanceValues applies the settings in values to instance i by iterating through the fields and calling the appropriate helper function. SecureEnvs overwrite any set by Envs earlier.
func Shared ¶ added in v1.7.0
Shared returns the full path to a directory or file in the instances component type shared directory joined to any parts subs - the last element can be a filename. If the instance is not loaded then "." is returned for the current directory.
func ShortName ¶ added in v1.14.2
ShortName returns the instance name with the "@HOST" suffix as a string
func UnsetInstanceValues ¶ added in v1.7.0
func UnsetInstanceValues(i geneos.Instance, unset UnsetConfigValues) (changed bool)
XXX abstract this for a general case
func Version ¶
Version returns the base package name, the underlying package version and the actual version in use for the instance i. If base is not a link, then base is also returned as the symlink. If there are more than 10 levels of symlink then return symlink set to "loop-detected" and err set to syscall.ELOOP to prevent infinite loops. If the instance is not running or the executable path cannot be determined then actual will be returned as "unknown".
func Write ¶ added in v1.26.1
Write writes the instance configuration to the standard file for that instance. All legacy parameter (aliases) are removed from the set of values saved. Any empty configuration values are removed from the saved configuration.
func WriteAESKeyFile ¶ added in v1.13.0
func WriteAESKeyFile(i geneos.Instance, kv *config.KeyValues) (keyfile config.KeyFile, crc uint32, err error)
WriteAESKeyFile writes key values to a an instance key file, for secure passwords as per:
https://docs.itrsgroup.com/docs/geneos/current/Gateway_Reference_Guide/gateway_secure_passwords.htm
If the instance config is updated then it is also saved.
func WriteCertificateAndKey ¶ added in v1.26.1
func WriteCertificateAndKey(i geneos.Instance, key *memguard.Enclave, certChain ...*x509.Certificate) (err error)
WriteCertificateAndKey writes the certificates and, if given, the private key to the instance i using standard file names and updates the instance configuration. It will set the instance `tls::certificate` and, when given a key, the `tls::privatekey` parameters and clear any values in the old style `certificate` and `privatekey` parameters. It does not write the instance configuration, expecting the caller to do so after any other updates.
Types ¶
type ConfigOption ¶ added in v1.26.1
type ConfigOption func(*configOptions)
func KeepPort ¶ added in v1.26.1
func KeepPort() ConfigOption
KeepPort controls whether to keep the same port number in the new config or to update it to avoid clashes with existing instances on the destination host. By default ports are updated to avoid clashes. This option is used when copying an instance within the same host, where there will be no clashes, and we want to keep the same port numbers.
func NewDir ¶ added in v1.26.1
func NewDir(dir string) ConfigOption
NewDir returns a ConfigOption that sets the new instance directory in the config options, which is used by RefactorConfig to set the new home in the config file. If not set, RefactorConfig will use the default directory for the instance type on the destination host. This option is used when copying an instance within the same host, where we want to keep the same directory and just update the name, and therefore the default would not be correct. It can also be used to specify a custom directory for the new instance.
func NewName ¶ added in v1.26.1
func NewName(name string) ConfigOption
NewName returns a ConfigOption that sets the new instance name in the config options, which is used by RefactorConfig to set the new name in the config file. If not set, RefactorConfig will not update the name of the instance.
type CopyOptions ¶ added in v1.11.0
type CopyOptions func(*copyOptions)
func Move ¶ added in v1.11.0
func Move() CopyOptions
Move tells Copy to remove the source instance(s) after the copy.
func Params ¶ added in v1.11.0
func Params(p ...string) CopyOptions
Params add key=value parameters to the copied/moved destination, overriding the values of the source. Currently only supports plain paramaters, not structured ones like environments.
type Includes ¶ added in v1.7.0
Includes is a map of include file priority to path include file - priority:url|path
type Instance ¶
type Instance struct {
geneos.Instance `json:"-"`
Conf *config.Config `json:"-"`
InstanceHost *geneos.Host `json:"-"`
Component *geneos.Component `json:"-"`
ConfigLoaded time.Time `json:"-"`
}
The Instance type is the common data shared by all instances
type InstanceOptions ¶ added in v1.14.2
type InstanceOptions func(*instanceOptions)
func FilterNames ¶ added in v1.14.2
func FilterNames(names ...string) InstanceOptions
func FilterParameters ¶ added in v1.14.2
func FilterParameters(parameters ...string) InstanceOptions
type NameValues ¶ added in v1.8.0
type NameValues []string
attribute - name=value
func (*NameValues) Set ¶ added in v1.8.0
func (i *NameValues) Set(value string) error
func (*NameValues) String ¶ added in v1.8.0
func (i *NameValues) String() string
func (*NameValues) Type ¶ added in v1.8.0
func (i *NameValues) Type() string
type ProcessFDs ¶ added in v1.14.2
type ProcessFDs struct {
PID int
FD int
Path string
Lstat fs.FileInfo
Stat fs.FileInfo
Conn *SocketConnection
}
func Files ¶
func Files(i geneos.Instance) (files []ProcessFDs)
Files returns a map of file descriptor to file details for all files for the instance. An empty map is returned if the process cannot be found.
type ProcessStats ¶ added in v1.14.2
type ProcessStats struct {
Pid int64 `stat:"0"`
Utime time.Duration `stat:"13"`
Stime time.Duration `stat:"14"`
CUtime time.Duration `stat:"15"`
CStime time.Duration `stat:"16"`
State string `status:"State"`
Threads int64 `status:"Threads"`
VmRSS int64 `status:"VmRSS"`
VmHWM int64 `status:"VmHWM"`
RssAnon int64 `status:"RssAnon"`
RssFile int64 `status:"RssFile"`
RssShmem int64 `status:"RssShmem"`
OpenFiles int64
OpenSockets int64
}
ProcessStats is an example of a structure to pass to instance.ProcessStatus, using a field number for `stat` and a line prefix for `status` tags. OpenFiles and OpenSockets are counts of their respective names.
type SecureValue ¶ added in v1.7.0
type SecureValues ¶ added in v1.7.0
type SecureValues []*SecureValue
func (*SecureValues) Set ¶ added in v1.7.0
func (p *SecureValues) Set(v string) error
Set a SecureValue. If there is a "=VALUE" part then this is saved in Secret, otherwise only the NAME is set. This allows later processing to either encode the Secret into Ciphertext or to prompt the user for a secret
func (*SecureValues) String ¶ added in v1.7.0
func (p *SecureValues) String() string
func (*SecureValues) Type ¶ added in v1.7.0
func (p *SecureValues) Type() string
type SetConfigValues ¶ added in v1.7.0
type SetConfigValues struct {
// Includes are include files for Gateway templates, keyed by priority
Includes Includes
// Gateways are gateway connections for SAN templates
Gateways Gateways
// Attributes are name=value pairs for attributes for Gateway templates
Attributes NameValues
// Environment variables for all instances as name=value pairs
Envs NameValues
// Headers are name=value pairs for passing to URL requests from
// various commands
Headers NameValues
// Variables for SAN templates, keyed by variable name
Variables Vars
// Types for SAN templates
Types Types
// Params are key=value pairs set directly in the configuration after checking
Params []string
// SecureParams parameters name[=value] where value will be prompted
// for if not supplied and are encoded with a keyfile
SecureParams SecureValues
// SecureEnvs are environment variables in the form name[=value]
// where value will be prompted for if not supplied and are encoded
// with a keyfile
SecureEnvs SecureValues
}
SetConfigValues defined the set of non-simple configuration options that can be accepted by various commands
type SocketConnection ¶ added in v1.14.2
type SocketConnection struct {
Protocol string
LocalAddr net.IP
LocalPort uint16
RemoteAddr net.IP
RemotePort uint16
TxQueue int64
RxQueue int64
Status string
}
func SocketToConn ¶ added in v1.14.2
func SocketToConn(h *geneos.Host, socket string) (sc *SocketConnection, err error)
SocketToConn takes the name of a socket from destination of a `/proc/.../fd` link and locates the corresponding connection in one of `/proc/net/tcp[6]` or `/proc/net/ucp[6]`. socket should be of the form `socket:[17126174]`
type StartOptions ¶ added in v1.8.0
type StartOptions func(*startOptions)
func SkipFileCheck ¶ added in v1.14.2
func SkipFileCheck() StartOptions
func StartingEnvs ¶ added in v1.8.0
func StartingEnvs(envs NameValues) StartOptions
StartingEnvs takes a NameValues list of extra environment variables to append to the standard list for the instance.
func StartingExtras ¶ added in v1.8.0
func StartingExtras(extras string) StartOptions
StartingExtras sets extra command line parameters by splitting extras on spaces. Quotes, escaping and other shell-like separators are ignored.
type UnsetConfigValues ¶ added in v1.5.0
type UnsetConfigValues struct {
Attributes UnsetValues
Envs UnsetValues
Gateways UnsetValues
Includes UnsetValues
Keys UnsetValues
Types UnsetValues
Variables UnsetVars
}
type UnsetValues ¶ added in v1.5.0
type UnsetValues []string
unset Var flags take just the key, either a name or a priority for include files
func (*UnsetValues) Set ¶ added in v1.7.0
func (i *UnsetValues) Set(value string) error
func (*UnsetValues) String ¶ added in v1.7.0
func (i *UnsetValues) String() string
func (*UnsetValues) Type ¶ added in v1.7.0
func (i *UnsetValues) Type() string