File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/engines/__pycache__/logentries.cpython-310.pyc
Back
o ;jd � @ s d Z ddlZddlZddlZddlZddlZddlZddlZzddl Z dZ W n ey1 dZ Y nw zddlZdZ W n eyE dZ Y nw e�e�Zdd� ZG dd� d�ZzddlZdZ W n eyk eZdZ Y nw G d d � d e�ZeZdd� Z ddd�ZdS )av An engine that sends events to the Logentries logging service. :maintainer: Jimmy Tang (jimmy_tang@rapid7.com) :maturity: New :depends: ssl, certifi :platform: all .. versionadded:: 2016.3.0 To enable this engine the master and/or minion will need the following python libraries ssl certifi If you are running a new enough version of python then the ssl library will be present already. You will also need the following values configured in the minion or master config. :configuration: Example configuration .. code-block:: yaml engines: - logentries: endpoint: data.logentries.com port: 10000 token: 057af3e2-1c05-47c5-882a-5cd644655dbf The 'token' can be obtained from the Logentries service. To test this engine .. code-block:: bash salt '*' test.ping cmd.run uptime � NTFc C s t rtrdS dS )NTF)�HAS_CERTIFI�HAS_SSL� r r �K/opt/saltstack/salt/lib/python3.10/site-packages/salt/engines/logentries.py�__virtual__I s r c @ s8 e Zd Z ddd�Zdd� Zd d � Zdd� Zd d� ZdS )�PlainTextSocketAppenderT�data.logentries.com�P � c C sD || _ || _|| _d| _d| _d| _tjj� d�| _ || _d | _d S )Ng�������?� zG It appears the LOGENTRIES_TOKEN parameter you entered is incorrect! u ) �LE_API�LE_PORT�LE_TLS_PORT� MIN_DELAY� MAX_DELAYZ INVALID_TOKEN�salt�utils�stringutils�to_str�LINE_SEP�verbose�_conn)�selfr r r r r r r �__init__N s � z PlainTextSocketAppender.__init__c C s* t � t jt j�| _| j�| j| jf� d S �N)�socket�AF_INET�SOCK_STREAMr �connectr r �r r r r �open_connectionb s z'PlainTextSocketAppender.open_connectionc C s� | � � | j} z| �� W d S ty | jrt�d� Y nw |d9 }|| jkr-| j}|t� d|� }zt �|� W n tyD � w q)NTzUnable to connect to Logentries� r ) �close_connectionr r � Exceptionr �log�warningr �random�uniform�time�sleep�KeyboardInterrupt)r Z root_delay�wait_forr r r �reopen_connectionf s* �� ��z)PlainTextSocketAppender.reopen_connectionc C s | j d ur| j �� d S d S r )r �closer r r r r"