sos.collector.clusters — Cluster Interface

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


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

  • 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

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 primary node.


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

In the event there are multiple primaries, or if the collect command is being run from a system that is technically capable of enumerating nodes but the cluster profiles needs to specify primary-specific options for other nodes, override this method in the cluster profile

Parameters:node (SoSNode) – The node for the cluster to check
exec_primary_cmd(cmd, need_root=False)[source]

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

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

The output and status of cmd

Return type:



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

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

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

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

Used to print debug messages


Used to print error messages


Used to print info messages


Used to print warning messages

classmethod name()[source]

Returns the cluster’s name as a string.


This may be overridden by clusters profiles subclassing this class

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


If there is a need to set specific options on ONLY the non-primary nodes in a collection, override this method in the cluster profile and do that here.

Parameters:node (SoSNode) – The non-primary node

If there is a need to set specific options in the sos command being run on the cluster’s primary nodes, override this method in the cluster profile and do that here.

Parameters:node (SoSNode) – The primary node

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