Documentation ¶
Index ¶
- Variables
- func CheckGateways(cf *config.Config) (liveGateways []string)
- func Execute()
- func LoadHosts(cf *config.Config) (hosts map[string]HostMappings, err error)
- func OrderGateways(netprobe string, gateways []string) (selection []string)
- func ReadGateways(source string) (gateways []map[string]string)
- func ReadHostsYAML(cf *config.Config) (hosts map[string]HostMappings, err error)
- type ConfigServer
- func (cs *ConfigServer) Gateways(hostname string) (NPgateways []netprobe.Gateway)
- func (cs *ConfigServer) NetprobeConfig(hostname string, componentOverride string) (np *netprobe.Netprobe, finalComponentType string)
- func (cs *ConfigServer) ServeConfig(c echo.Context) (err error)
- func (cs *ConfigServer) ServeConnection(c echo.Context) (err error)
- type FetchOptions
- func AddHeader(name string, values []string) FetchOptions
- func BasicAuth(username string, password *config.Plaintext) FetchOptions
- func Client(client *http.Client) FetchOptions
- func IfModified(inv *Inventory) FetchOptions
- func InventoryType(t string) FetchOptions
- func Method(method string) FetchOptions
- type GatewaySet
- type HostMappings
- type Inventory
- func FetchInventory(cf *config.Config, source string, cacheFile string, options ...FetchOptions) (inv *Inventory, err error)
- func ParseInventoryYAML(cf *config.Config, cacheFile string, in io.Reader) (inv *Inventory, contents []byte, err error)
- func ReadInventory(cf *config.Config, file string, options ...FetchOptions) (inv *Inventory, err error)
Constants ¶
This section is empty.
Variables ¶
var Inventories sync.Map
Inventories is a map of source to inventory, for "if modified" checks
Functions ¶
func CheckGateways ¶
CheckGateways uses a liveness endpoint to see if gateway is reachable. primary and standby gateways should normally respond the same, and as long as one of each pair is "up" we respond OK for the set.
all gateways are checked in their own go routines
func Execute ¶
func Execute()
Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.
func LoadHosts ¶
func LoadHosts(cf *config.Config) (hosts map[string]HostMappings, err error)
LoadHosts reads the inventories and extracts the hosts and their types, returning them as a map of HostMappings
func OrderGateways ¶ added in v1.17.1
OrderGateways creates an ordered list of the hash of probe and gateway names. The hash is created through UUIDs based on the configuration namespace uuid.
func ReadGateways ¶ added in v1.17.1
ReadGateways reads an local file for gateway details. Paths can use the "~/" prefix for the user's home directory.
CSV, JSON and YAML are supported. The file type is wholly determined by the source file extension, which defaults to YAML if not given, so ".yml" will work too.
CSV files must have a first line with column names, and the column "name" is required while "primary", "standby" and "secure" are optional. The format of each field is as for the main configuration file.
JSON files must be an array of objects, where each object has a required "name" field and optional fields as for CSV.
YAML files must have a top-level "gateways" parameter and an array of object as per the main configuration file.
func ReadHostsYAML ¶ added in v1.17.1
func ReadHostsYAML(cf *config.Config) (hosts map[string]HostMappings, err error)
ReadHostsYAML read all the inventories referenced in the YAML configuration and returns a consolidated map of hostname to mappings. If the slice "loop" exists it runs for each value, setting the mapping "index" to the loop value.
Types ¶
type ConfigServer ¶
ConfigServer encapsulates the data required to server config (and connection) requests
func (*ConfigServer) Gateways ¶ added in v1.17.1
func (cs *ConfigServer) Gateways(hostname string) (NPgateways []netprobe.Gateway)
Gateways returns a slice of all the gateways that this SAN should try to connect to.
When a named gateway is configured with both a primary and standby host then this counts as one gateway but results in two slice elements. The number of named gateways is limited by the `geneos.sans.gateways` value which defaults to 1.
func (*ConfigServer) NetprobeConfig ¶
func (cs *ConfigServer) NetprobeConfig(hostname string, componentOverride string) (np *netprobe.Netprobe, finalComponentType string)
NetprobeConfig returns a netprobe.Netprobe struct for output via XML marshalling. The returned `finalComponentType` is for logging in the caller for those cases where the type changes from the requested one..
If hostname is not found in hosts then return the unknown component settings and the fallback gateway(s)
If no gateways are available then do the same as above for hardware probes - not sure about apps at this stage
func (*ConfigServer) ServeConfig ¶
func (cs *ConfigServer) ServeConfig(c echo.Context) (err error)
ServeConfig is the main handler to return a SAN XML config
func (*ConfigServer) ServeConnection ¶
func (cs *ConfigServer) ServeConnection(c echo.Context) (err error)
ServeConnection supplies a connection file with all live gateways
The output format is (from docs):
<hostname>~<port>~<description>~<Secondary Host>~<Secondary Port>~<Logon Method>~<Connection Security> thinkpad ~7038 ~test1 ~ubuntu ~7038 ~* ~SECURE ...
The description, Secondary Host and port and logon methods can be replaced with '*' for undefined
type FetchOptions ¶
type FetchOptions func(*fetchOptions)
FetchOptions for FetchInventory options
func AddHeader ¶
func AddHeader(name string, values []string) FetchOptions
AddHeader adds a header to the FetchInventory call. Any existing header with the name name is overwritten
func BasicAuth ¶
func BasicAuth(username string, password *config.Plaintext) FetchOptions
BasicAuth sets up the request to use Basic Authentication
func Client ¶
func Client(client *http.Client) FetchOptions
Client sets the http Client for FetchInventory
func IfModified ¶
func IfModified(inv *Inventory) FetchOptions
IfModified checks if the inventory inv has changed since the last request, using the If-Modified-Since header
func InventoryType ¶
func InventoryType(t string) FetchOptions
InventoryType sets the inventory format. The default is YAML.
type GatewaySet ¶
type GatewaySet struct { Name string Primary string PrimaryPort int Standby string StandbyPort int Secure bool }
GatewaySet is a Gateway instance with standby details if required
func GatewayDetails ¶
func GatewayDetails(name string, gateways []map[string]string) (gateway GatewaySet)
GatewayDetails searches for and returns the details for Gateway name
type HostMappings ¶
HostMappings is a lookup table for substitution and other features.
type Inventory ¶
type Inventory struct {
// contains filtered or unexported fields
}
Inventory type stores the results of loading an Inventory, including a host to node_type mapping
func FetchInventory ¶
func FetchInventory(cf *config.Config, source string, cacheFile string, options ...FetchOptions) (inv *Inventory, err error)
FetchInventory fetches an inventory file in JSON format from the source URL with optional method (default GET), client and requests.
func ParseInventoryYAML ¶
func ParseInventoryYAML(cf *config.Config, cacheFile string, in io.Reader) (inv *Inventory, contents []byte, err error)
ParseInventoryYAML loads a simple, flat yaml style file of:
name: type name: type
func ReadInventory ¶
func ReadInventory(cf *config.Config, file string, options ...FetchOptions) (inv *Inventory, err error)
ReadInventory reads the inventory from a file source