Custom Datasources Catalog

insights.specs.datasources

Custom datasources provide functionality beyond simple_file and simple_command type datasources. If the custom datasource is short and concise it may be added to this module. Other datasources should be added as a separate module. Normally custom datasources are necessary for core-collection. In order for a custom datasource to execute, all of its dependencies must be explicitly loaded by the client. The client uses the YAML template insights.collect.default_manifest and each parser/combiner/component required by a custom datasource must be included in the YAML template to ensure it is loaded.

insights.specs.datasources.DEFAULT_SHELL_TIMEOUT = 10

Default timeout in seconds for ctx.shell_out() commands, must be provided as an arg

Type

int

insights.specs.datasources.get_running_commands(ps, ctx, commands)[source]

Search for a list of commands in Ps combiner output and returns the full path to the command

Parameters
  • ps -- Ps combiner object

  • ctx -- Context of the current collection

  • commands (list) -- List of commands to search for in ps output

Returns

List of the full command paths of the all command.

Return type

list

Raises

TypeError -- Raised when commands args is not a list

insights.specs.datasources.candlepin_broker

Custom datasources for candlepin broker.xml

class insights.specs.datasources.candlepin_broker.LocalSpecs[source]

Bases: insights.specs.Specs

Local specs used only by candlepin_broker datasources

candlepin_broker_input = <insights.core.spec_factory.simple_file object>

Returns the contents of the file /etc/candlepin/broker.xml

context_handlers = {}
registry = {}
insights.specs.datasources.candlepin_broker.candlepin_broker(broker)

This datasource provides the candlepn broker configuration information collected from /etc/candlepin/broker.xml.

Typical content of /etc/candlepin/broker.xml file is:

<configuration xmlns="urn:activemq"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
    <core xmlns="urn:activemq:core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="urn:activemq:core ">
        <acceptors>
            <acceptor name="in-vm">vm://0</acceptor>
            <acceptor name="stomp">tcp://localhost:61613?protocols=STOMP;useEpoll=false;sslEnabled=true;trustStorePath=/etc/candlepin/certs/truststore;trustStorePassword=CDX9i3K5uPPBzcNtzz5tcycVf5PuXA5w;keyStorePath=/etc/candlepin/certs/keystore;keyStorePassword=4iBpTS45VZjFmVdNzRhRKNXtxbsH5Dij;needClientAuth=true</acceptor>
        </acceptors>
        <security-enabled>true</security-enabled>
    </core>
</configuration>

Note

This datasource may be executed using the following command:

insights cat --no-header candlepin_broker

Returns

XML string after removeing sensitive information.

Return type

str

Raises

SkipComponent -- When the path does not exist or any exception occurs.

insights.specs.datasources.cloud_init

Custom datasources for cloud initialization information

class insights.specs.datasources.cloud_init.LocalSpecs[source]

Bases: insights.specs.Specs

Local specs used only by cloud_init datasources

cloud_cfg_input = <insights.core.spec_factory.simple_file object>

Returns the contents of the file /etc/cloud/cloud.cfg

context_handlers = {}
registry = {}
insights.specs.datasources.cloud_init.cloud_cfg(broker)

This datasource provides the network configuration information collected from /etc/cloud/cloud.cfg.

Typical content of /etc/cloud/cloud.cfg file is:

#cloud-config
users:
  - name: demo
    ssh-authorized-keys:
      - key_one
      - key_two
    passwd: $6$j212wezy$7H/1LT4f9/N3wpgNunhsIqtMj62OKiS3nyNwuizouQc3u7MbYCarYeAHWYPYb2FT.lbioDm2RrkJPb9BZMN1O/

network:
    version: 1
    config:
    - type: physical
        name: eth0
        subnets:
          - type: dhcp
          - type: dhcp6

system_info:
    default_user:
    name: user2
    plain_text_passwd: 'someP@assword'
    home: /home/user2

debug:
    output: /var/log/cloud-init-debug.log
    verbose: true

Note

This datasource may be executed using the following command:

insights cat --no-header cloud_cfg

Sample data returned includes only the network portion of the input file in JSON format:

{
    "version": 1,
    "config": [
        {
            "type": "physical",
            "name": "eth0",
            "subnets": [
                {"type": "dhcp"},
                {"type": "dhcp6"}
            ]
        }
    ]
}
Returns

JSON string when the network parameter includes content, else None is returned.

Return type

str

Raises

SkipComponent -- When the path does not exist or any exception occurs.

insights.specs.datasources.ethernet

Custom datasource for gathering a list of the ethernet interface names.

class insights.specs.datasources.ethernet.LocalSpecs[source]

Bases: insights.specs.Specs

Local specs used only by ethernet_interfaces datasource.

context_handlers = {}
registry = {}
insights.specs.datasources.ethernet.interfaces(broker)[source]

This datasource provides a list of the ethernet interfaces available.

Typical content of the spec is:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000\    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000\    link/ether 52:54:00:13:14:b5 brd ff:ff:ff:ff:ff:ff
3: enp8s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000\    link/ether 52:54:00:e5:11:d4 brd ff:ff:ff:ff:ff:ff
4: enp1s0.2@enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000\    link/ether 52:54:00:13:14:b5 brd ff:ff:ff:ff:ff:ff
5: ib0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 4092 qdisc mq state DOWN group default qlen 256\    link/infiniband 00:01:02:03:fd:90:0:00:00:00:00:00:ef:0d:8b:02:01:d9:82:fd

Note

This datasource may be executed using the following command:

insights cat --no-header ethernet_interfaces

Sample data returned:

['enp1s0', 'enp8s0', 'enp1s0.2']
Returns

List of the ethernet interfaces available.

Return type

list

Raises

SkipComponent -- When there is not any content.

insights.specs.datasources.ipcs

Custom datasources to get the semid of all the inter-processes.

insights.specs.datasources.ipcs.semid(broker)[source]

This datasource provides a list of the semid of all the inter-processes.

Note

This datasource may be executed using the following command:

insights cat --no-header ipcs_s_i

Sample output:

[
    '65570', '98353', '98354'
]
Returns

A list of the semid of all the inter-processes.

Return type

list

insights.specs.datasources.package_provides

Custom datasource for package_provides

insights.specs.datasources.package_provides.cmd_and_pkg(broker)

Collect a list of running commands and the associated RPM package providing those commands. The commands are based on filters so rules must add the desired commands as filters to enable collection. If a command is not provided by an RPM then it will not be included in the output.

In order for the full command line to be present in the Ps combiner a filter must be added to the spec ps_auxww. A filter must also be added to package_provides_command so this datasource will look for the command in Ps.

Parameters

broker -- the broker object for the current session

Returns

Returns the collected information as a file with 1 line per command

Return type

DatasourceProvider

Raises

SkipComponent -- Raised if no data is collected

insights.specs.datasources.package_provides.get_package(ctx, file_path)[source]

Get the RPM package that owns the specified filename with path

Parameters
  • ctx -- The current execution context

  • file_path (str) -- The full path and filename for RPM query

Returns

The name of the RPM package that provides the file or None if file is not associated with an RPM.

Return type

str

insights.specs.datasources.ps

Custom datasources for ps information

class insights.specs.datasources.ps.LocalSpecs[source]

Bases: insights.specs.Specs

Local specs used only by ps datasources

context_handlers = {}
ps_eo_args = <insights.core.spec_factory.simple_command object>

Returns ps output including pid and full args

registry = {}
insights.specs.datasources.ps.ps_eo_cmd(broker)

Custom datasource to collect the full paths to all running commands on the system provided by the ps -eo pid,args command. After collecting the data, all of the args are trimmed to leave only the command including full path.

Sample output from the ps -eo pid, args command:

PID COMMAND
  1 /usr/lib/systemd/systemd --switched-root --system --deserialize 31
  2 [kthreadd]
  3 [rcu_gp]
  4 [rcu_par_gp]
  6 [kworker/0:0H-events_highpri]
  9 [mm_percpu_wq]
 10 [rcu_tasks_kthre]
 11 /usr/bin/python3 /home/user1/python_app.py
 12 [kworker/u16:0-kcryptd/253:0]

This datasource trims off the args to minimize possible PII and sensitive information. After trimming the data looks like this:

PID COMMAND
  1 /usr/lib/systemd/systemd
  2 [kthreadd]
  3 [rcu_gp]
  4 [rcu_par_gp]
  6 [kworker/0:0H-events_highpri]
  9 [mm_percpu_wq]
 10 [rcu_tasks_kthre]
 11 /usr/bin/python3
 12 [kworker/u16:0-kcryptd/253:0]
Returns

Returns a multiline string in the same format as ps output

Return type

str

Raises

SkipComponent -- Raised if no data is available

insights.specs.datasources.sap

Custom datasources for SAP related specs

class insights.specs.datasources.sap.LocalSpecs[source]

Bases: insights.specs.Specs

Local specs used only by sap datasources

context_handlers = {}
registry = {}
sap_hana_instance()[source]

list: List of the SAP HANA Instances.

sap_instance()[source]

list: List of all SAP Instances.

insights.specs.datasources.sap.ld_library_path_of_user(broker)

list: The list of “Username LD_LIBRARY_PATH”, e.g.:

[
  'sr1adm /usr/sap/RH1/SYS/exe/run:/usr/lib/',
  'sr2adm /usr/sap/RH2/SYS/exe/run',
]

Note

Currently, only Sap users are supported.

insights.specs.datasources.sap.sap_hana_sid(broker)[source]

list: List of the SID of SAP HANA Instances.

insights.specs.datasources.sap.sap_hana_sid_SID_nr(broker)[source]

list: List of tuples (sid, SID, Nr) of SAP HANA Instances.

insights.specs.datasources.sap.sap_sid(broker)[source]

list: List of the SID of all the SAP Instances.

insights.specs.datasources.satellite_missed_queues

class insights.specs.datasources.satellite_missed_queues.LocalSpecs[source]

Bases: insights.specs.Specs

Local specs used only by get_satellite_missed_pulp_agent_queues datasources

content_host_uuids = <insights.core.spec_factory.simple_command object>
context_handlers = {}
qpid_queues = <insights.core.spec_factory.simple_command object>
registry = {}
insights.specs.datasources.satellite_missed_queues.satellite_missed_pulp_agent_queues(broker)

This datasource provides the missed pulp agent queues information on satellite server.

Note

This datasource may be executed using the following command:

insights cat --no-header satellite_missed_pulp_agent_queues

Sample output:

pulp.agent.09008eec-aba6-4174-aa9f-e930004ce5c9:2018-01-16 00:06:13
pulp.agent.fac7ebbc-ee4f-44b4-9fe0-3f4e42c7f024:2018-01-16 00:06:16
0
Returns

All the missed pulp agent queues and the boolean mark if the data is

truncated in the last line. If the value of last line is 0, it means all the missed queues are returned. If the value of the last line is 1, it means there are a lot of missed queues, to avoid render error, only the first 10 missed queues are returned.

Return type

str

Raises

SkipComponent -- When the error doen’t happen or the missed queues have been recreated.