HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/beacons/__pycache__/memusage.cpython-310.pyc
o

�N�g��@sndZddlZddlZddlZzddlZdZWney!dZYnwe�e	�Z
dZdd�Zdd	�Z
d
d�ZdS)zV
Beacon to monitor memory usage.

.. versionadded:: 2016.3.0

:depends: python-psutil
�NTF�memusagecCs&tdurd}t�dt|�d|fStS)NFzpsutil library is missing.zUnable to load %s beacon: %s)�
HAS_PSUTIL�log�error�__virtualname__)�err_msg�r�I/opt/saltstack/salt/lib/python3.10/site-packages/salt/beacons/memusage.py�__virtual__s
r
cCs,t|t�sdStjj�|�}d|vrdSdS)z+
    Validate the beacon configuration
    )Fz1Configuration for memusage beacon must be a list.�percent)Fz3Configuration for memusage beacon requires percent.)TzValid beacon configuration)�
isinstance�list�salt�utils�beacons�list_to_dict)�configrrr	�validate#s
rcCsjg}tjj�|�}t��}|j}|d}t|t�r$d|vr$t	�
dd|�}t|�}||kr3|�d|i�|S)z�
    Monitor the memory usage of the minion

    Specify thresholds for percent used and only emit a beacon
    if it is exceeded.

    .. code-block:: yaml

        beacons:
          memusage:
            - percent: 63%
    r�%�r)
rrrr�psutilZvirtual_memoryrr�str�re�sub�float�append)r�retZ_current_usageZ
current_usageZ
monitor_usagerrr	�beacon2s
r)�__doc__�loggingrZsalt.utils.beaconsrrr�ImportError�	getLogger�__name__rrr
rrrrrr	�<module>s�