HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/sysbench.cpython-310.pyc
o

�N�gJ�@sXdZddlZddlZdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)z�
The 'sysbench' module is used to analyze the
performance of the minions, right from the master!
It measures various system parameters such as
CPU, Memory, File I/O, Threads and Mutex.
�NcCstjj�d�r	dSdS)z9
    loads the module, if only sysbench is installed
    Zsysbench)FzUThe sysbench execution module failed to load: the sysbench binary is not in the path.)�salt�utils�path�which�rr�I/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/sysbench.py�__virtual__
src
Cs�t�d�}t�d�}t�d�}t�d�}t�d�}t�d�}t�||��d�}t�||��d�}t�||��d�}	t�||��d�}
t�||��d�}t�||�}|durZ|�d�}|||	|
||d	�S)
z-
    parses the output into a dictionary
    ztotal time:\s*(\d*.\d*s)zevent execution:\s*(\d*.\d*s?)zmin:\s*(\d*.\d*ms)zmax:\s*(\d*.\d*ms)zavg:\s*(\d*.\d*ms)z95 percentile:\s*(\d*.\d*ms)�N)z
total timeztotal execution timezminimum response timezmaximum response timezaverage response timez
95 percentile)�re�compile�search�group)
�resultZ_total_timeZ_total_executionZ_min_response_timeZ_max_response_timeZ_avg_response_timeZ_per_response_timeZ
total_timeZtotal_executionZmin_response_timeZmax_response_timeZavg_response_timeZper_response_timerrr�_parsers*






�rcCsNgd�}d}d}i}|D]}d|��}|�|�}td|�}t|�||<q|S)z
    Tests for the CPU performance of minions.

    CLI Examples:

    .. code-block:: bash

        salt '*' sysbench.cpu
    )������	�z+sysbench --test=cpu --cpu-max-prime={0} runNzPrime numbers limit: �cmd.run��format�__salt__r)Z
max_primes�test_commandr�ret_valZprimes�key�run_commandrrr�cpu=s

rc	Cspgd�}gd�}d}|d7}d}i}t||�D]\}}d|�d|��}|�||�}td|�}t|�||<q|S)	z�
    This tests the performance of the processor's scheduler

    CLI Example:

    .. code-block:: bash

        salt '*' sysbench.threads
    )�d��rr)����z)sysbench --num-threads=64 --test=threads z+--thread-yields={0} --thread-locks={1} run NzYields: � Locks: r)�ziprrr)	Z
thread_yieldsZthread_locksrrrZyields�locksrrrrr�threadsZsr&cCs�gd�}gd�}g}|�|�gd�}d}|d7}d}i}t|||�D]#\}}}d|�d|�d	|��}	|�|||�}
td
|
�}t|�||	<q#|S)zy
    Tests the implementation of mutex

    CLI Examples:

    .. code-block:: bash

        salt '*' sysbench.mutex
    )	�2r'r'rrrrrr)	�'�a�P�r(r)r*r(r)r*)	rrr(r(rrrr(rz(sysbench --num-threads=250 --test=mutex z8--mutex-num={0} --mutex-locks={1} --mutex-loops={2} run NzMutex: r#z Loops: r)�extendr$rrr)Z	mutex_numr%Zmutex_locksZmutex_loopsrrr�numZloopsrrrrr�mutexys
r-c	Csxddg}ddg}d}|d7}|d7}d}i}|D]!}|D]}d	|�d
|��}|�||�}td|�}t|�||<qq|S)z�
    This tests the memory for read and write operations.

    CLI Examples:

    .. code-block:: bash

        salt '*' sysbench.memory
    �read�write�local�globalz(sysbench --num-threads=64 --test=memory z%--memory-oper={0} --memory-scope={1} z3--memory-block-size=1K --memory-total-size=32G run NzOperation: z Scope: rr)	Zmemory_operZmemory_scoperrrZoperZscoperrrrr�memory�s�r2cCs�gd�}d}|d7}d}i}|D]4}d|��}|d�|�}td|�|d�|�}td|�}t|�||<|d	�|�}td|�q|S)
a�
    This tests for the file read and write operations
    Various modes of operations are

    * sequential write
    * sequential rewrite
    * sequential read
    * random read
    * random write
    * random read and write

    The test works with 32 files with each file being 1Gb in size
    The test consumes a lot of time. Be patient!

    CLI Examples:

    .. code-block:: bash

        salt '*' sysbench.fileio
    )ZseqwrZseqrewrZseqrdZrndrdZrndwrZrndrwz(sysbench --num-threads=16 --test=fileio z8--file-num=32 --file-total-size=1G --file-test-mode={0} NzMode: Zpreparer�runZcleanupr)Z
test_modesrrr�moderrrrr�fileio�s
r5cCsdS)NTrrrrr�ping�sr6)�__doc__r
Zsalt.utils.pathrrrrr&r-r2r5r6rrrr�<module>s"'&3