sos.collector.clusters — Cluster Profiles

class sos.collector.clusters.Cluster(commons)[source]

Bases: object

This is the class that cluster profiles should subclass in order to add support for different clustering technologies and environments to sos-collector.

A profile should at minimum define a package that indicates the node is configured for the type of cluster the profile is intended to serve and then additionally be able to return a list of enumerated nodes via the get_nodes() method

Parameters:

commons (dict) – The commons dict containing system information. The same as what is handed to Plugin()

Variables:
  • option_list (list of tuples) – Options supported by the profile, and set by the –cluster-option cmdline arg
  • packages (tuple) – What package(s) should this profile enable on
  • sos_plugins (list) – Which plugins to forcibly enable for node reports
  • sos_plugin_options (dict) – Plugin options to forcibly set for nodes
  • sos_preset (str) – A SoSReport preset to forcibly enable on nodes
  • cluster_name (str) – The name of the cluster type
add_default_ssh_key(key)[source]

Some clusters generate and/or deploy well-known and consistent SSH keys across environments. If this is the case, the cluster profile may call this command so that subsequent node connections will use that key rather than prompting the user for one or a password.

Note this will only function if collector is being run locally on the master node.

check_enabled()[source]

This may be overridden by clusters

This is called by sos collect on each cluster type that exists, and is meant to return True when the cluster type matches a criteria that indicates that is the cluster type is in use.

Only the first cluster type to determine a match is run

Returns:True if the cluster profile should be used, or False
Return type:bool
exec_master_cmd(cmd, need_root=False)[source]

Used to retrieve command output from a (master) node in a cluster

Parameters:
  • cmd (str) – The command to run
  • need_root (bool) – Does the command require root privileges
Returns:

The output and status of cmd

Return type:

dict

format_node_list()[source]

Format the returned list of nodes from a cluster into a known format. This being a list that contains no duplicates

Returns:A list of nodes, without extraneous entries from cmd output
Return type:list
get_node_label(node)[source]

Used by SosNode() to retrieve the appropriate label from the cluster as set by set_node_label() in the cluster profile.

Parameters:node (str) – The name of the node to get a label for
Returns:The label to use for the node’s report
Return type:str
get_nodes()[source]

This MUST be overridden by a cluster profile subclassing this class

A cluster should use this method to return a list or string that contains all the nodes that a report should be collected from

Returns:A list of node FQDNs or IP addresses
Return type:list or None
get_option(option)[source]

This is used to by clusters to check if a cluster option was supplied to sos collect

Parameters:option (str) – The name of the option to fetch
Returns:The value of the requested option if it exists, or False
log_debug(msg)[source]

Used to print debug messages

log_error(msg)[source]

Used to print error messages

log_info(msg)[source]

Used to print info messages

log_warn(msg)[source]

Used to print warning messages

classmethod name()[source]

Returns the cluster’s name as a string.

set_node_label(node)[source]

This may be overridden by clusters profiles subclassing this class

If there is a distinction between masters and nodes, or types of nodes, then this can be used to label the sosreport archive differently.

setup()[source]

This MAY be used by a cluster to do prep work in case there are extra commands to be run even if a node list is given by the user, and thus get_nodes() would not be called