%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/modules/win_status.pyc

�
���^c@@s0dZddlmZmZmZddlZddlZddlZddlZej	e
�ZddlZ
ddlZ
ddlZ
ddlZ
ddlmZddlmZddlmZddlmamaddlZy=e
jjj�rddl Z ddl!Z
e"Z#ne$Z#Wne%k
r9e$Z#nXe$Z&e
jjj�rgddl'Z'e"Z&niZ(dZ)d	ej*fd
��YZ+d�Z,idd
6Z-d�Z.d�Z/d�Z0d�Z1d�Z2e$dd�Z4e$d�Z5e$d�Z6e$d�Z7d�Z8d�Z9d�Z:de"d�Z;dS(u�
Module for returning various status data about a minion.
These data can be useful for compiling into stats later,
or for problem solving if your minion is having problems.

.. versionadded:: 0.12.0

:depends:  - wmi
i(tabsolute_importtunicode_literalstprint_functionN(thost_to_ips(tnamespaced_function(tsix(tping_masterttime_ustatustSYSTEM_PERFORMANCE_INFORMATIONcOB@s�eZdejfdejfdejfdejfdejfdejfdejfdejfdejfd	ejfd
ejfdejfdejfd
ejfdejfdejfdejfdejfdejfdejfdejfdejfdejfdejfdejfdejfdejfdejfdejfdejfdejfdejfd ejfd!ejfd"ejfd#ejfd$ejfd%ejfd&ejfd'ejfd(ejfd)ejfd*ejfd+ejfd,ejfd-ejfd.ejfd/ejfd0ejfd1ejfd2ejfd3ejfd4ejfd5ejfd6ejfd7ejfd8ejfd9ejfd:ejfd;ejfd<ejfd=ejfd>ejfd?ejfd@ejfdAejfdBejfdCejfdDejfdEejfdFejfdGejfdHejfdIejfdJejfdKejfdLejfdMejfgNZRS(NuIdleProcessTimeuIoReadTransferCountuIoWriteTransferCountuIoOtherTransferCountuIoReadOperationCountuIoWriteOperationCountuIoOtherOperationCountuAvailablePagesuCommittedPagesuCommitLimituPeakCommitmentuPageFaultCountuCopyOnWriteCountuTransitionCountuCacheTransitionCountuDemandZeroCountu
PageReadCountuPageReadIoCountuCacheReadCountuCacheIoCountuDirtyPagesWriteCountuDirtyWriteIoCountuMappedPagesWriteCountuMappedWriteIoCountuPagedPoolPagesuNonPagedPoolPagesuPagedPoolAllocsuPagedPoolFreesuNonPagedPoolAllocsuNonPagedPoolFreesuFreeSystemPtesuResidentSystemCodePageuTotalSystemDriverPagesuTotalSystemCodePagesuNonPagedPoolLookasideHitsuPagedPoolLookasideHitsuAvailablePagedPoolPagesuResidentSystemCachePageuResidentPagedPoolPageuResidentSystemDriverPageuCcFastReadNoWaituCcFastReadWaituCcFastReadResourceMissuCcFastReadNotPossibleuCcFastMdlReadNoWaituCcFastMdlReadWaituCcFastMdlReadResourceMissuCcFastMdlReadNotPossibleuCcMapDataNoWaitu
CcMapDataWaituCcMapDataNoWaitMissuCcMapDataWaitMissuCcPinMappedDataCountuCcPinReadNoWaitu
CcPinReadWaituCcPinReadNoWaitMissuCcPinReadWaitMissuCcCopyReadNoWaituCcCopyReadWaituCcCopyReadNoWaitMissuCcCopyReadWaitMissuCcMdlReadNoWaitu
CcMdlReadWaituCcMdlReadNoWaitMissuCcMdlReadWaitMissuCcReadAheadIosuCcLazyWriteIosuCcLazyWritePagesu
CcDataFlushesuCcDataPagesuContextSwitchesuFirstLevelTbFillsuSecondLevelTbFillsuSystemCallsuCcTotalDirtyPagesuCcDirtyPagesThresholduResidentAvailablePagesuSharedCommittedPages(t__name__t
__module__tctypestc_int64tc_ulongtc_ulonglongt
c_longlongt_fields_(((s;/usr/lib/python2.7/site-packages/salt/modules/win_status.pyR:s�cC@sdtjjj�stdfSts,tdfSts<tdfSttt	��att
t	��a
tS(u;
    Only works on Windows systems with WMI and WinAPI
    uwin_status.py: Requires Windowsu&win_status.py: Requires WMI and WinAPIuwin_status.py: Requires psutil(tsalttutilstplatformt
is_windowstFalsetHAS_WMIt
HAS_PSUTILt_namespaced_functionRtglobalsRt__virtualname__(((s;/usr/lib/python2.7/site-packages/salt/modules/win_status.pyt__virtual__�s


utimeutime_cC@s�tj�\}}}}}i|d6|d6|d6|d6|d6}tj�\}}}}	iigd6|d6d6}
igd6|d6}itj�d	6|d
6|d6|
d6ttj��d
6|d6|	d6S(u�
    Return information about the CPU.

    Returns
        dict: A dictionary containing information about the CPU stats

    CLI Example:

    .. code-block:: bash

        salt * status.cpustats
    uuserusystemuidleuirqudpcuirqsutotalusoftirqsubtimeucpuuctxtuintru	processesusoftirqusyscalls(tpsutilt	cpu_timest	cpu_statst	boot_timetlentpids(tusertsystemtidlet	interrupttdpctcputctx_switchest
interruptstsoft_interruptst	sys_callstintrtsoft_irq((s;/usr/lib/python2.7/site-packages/salt/modules/win_status.pytcpustats�s$




cC@s�tj�\}}}}}tj�\}}}}}	}	d�}
i|
|�d6|
|�d6|
|�d6|
|�d6|
|�d6|
|�d6|
|�d6S(	u�
    Return information about physical and virtual memory on the system

    Returns:
        dict: A dictionary of information about memory on the system

    CLI Example:

    .. code-block:: bash

        salt * status.meminfo
    cS@s�d}i}x0t|�D]"\}}d	|d	d
>||<qWxJt|�D]<}|||krLt|�||}i|d6|d6SqLWid
d6|d6S(NuKuMuGuTuPuEuZuYii
uunituvalueuB(uKuMuGuTuPuEuZuY(t	enumeratetreversedtfloat(tmemorytsymbolstprefixtitstvalue((s;/usr/lib/python2.7/site-packages/salt/modules/win_status.pytget_unit_value�s

uVmallocTotaluVmallocUseduVmallocFreeuVmallocAvailu	SwapTotaluSwapUseduSwapFree(Rtvirtual_memorytswap_memory(tvm_totaltvm_availablet
vm_percenttvm_usedtvm_freet	swp_totaltswp_usedtswp_freetswp_percentt_R8((s;/usr/lib/python2.7/site-packages/salt/modules/win_status.pytmeminfo�s	





cC@s�t�}tj�}tjjjdtj|�tj|�tj|��i}x6|jD]+}|j	it
||d�|d6�q\W|S(u�
    Return information about the virtual memory on the machine

    Returns:
        dict: A dictionary of virtual memory stats

    CLI Example:

    .. code-block:: bash

        salt * status.vmstats
    ii(RRR
twindlltntdlltNtQuerySystemInformationtbyreftsizeofRtupdatetgetattr(tspitretlentrettfield((s;/usr/lib/python2.7/site-packages/salt/modules/win_status.pytvmstats�s	+)cC@sCdddddddddd d!d"d#g
}tjjjd|�S($u�
    Returns counter information related to the load of the machine

    Returns:
        dict: A dictionary of counters

    CLI Example:

    .. code-block:: bash

        salt * status.loadavg
    uMemoryuAvailable Bytesu	Pages/secuPaging Fileu*u% Usageu	Processoru% Processor TimeuDPCs Queued/secu% Privileged Timeu% User Timeu
% DPC Timeu% Interrupt TimeuServeruWork Item ShortagesuServer Work QueuesuQueue LengthuSystemuProcessor Queue LengthuContext Switches/sectcounter_listN(uMemoryNuAvailable Bytes(uMemoryNu	Pages/sec(uPaging Fileu*u% Usage(u	Processoru*u% Processor Time(u	Processoru*uDPCs Queued/sec(u	Processoru*u% Privileged Time(u	Processoru*u% User Time(u	Processoru*u
% DPC Time(u	Processoru*u% Interrupt Time(uServerNuWork Item Shortages(uServer Work Queuesu*uQueue Length(uSystemNuProcessor Queue Length(uSystemNuContext Switches/sec(tNoneRRtwin_pdhtget_counters(RR((s;/usr/lib/python2.7/site-packages/salt/modules/win_status.pytloadavgs	cC@s
tj�S(u�
    .. versionadded:: 2015.8.0

    Return the processor load as a percentage

    CLI Example:

    .. code-block:: bash

       salt '*' status.cpuload
    (Rtcpu_percent(((s;/usr/lib/python2.7/site-packages/salt/modules/win_status.pytcpuload3scC@s�|sd}ntj|�}|j}|j}|j}|j}|rot|�}t|�}t|�}ni|d6|d6|d6|d6S(u�
    .. versionadded:: 2015.8.0

    Return the disk usage for this minion

    human_readable : False
        If ``True``, usage will be in KB/MB/GB etc.

    CLI Example:

    .. code-block:: bash

        salt '*' status.diskusage path=c:/salt
    uc:/utotaluusedufreeupercent(Rt
disk_usagettotaltusedtfreetpercentt
_byte_calc(thuman_readabletpatht
disk_statst	total_valtused_valtfree_valR]((s;/usr/lib/python2.7/site-packages/salt/modules/win_status.pyt	diskusageBs					
cC@sotjjj��tj�}|j�}WdQX|rAt|�Si}x!|D]}t|�||j	<qNW|S(u
    Return the process data

    count : False
        If ``True``, this function will simply return the number of processes.

        .. versionadded:: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt '*' status.procs
        salt '*' status.procs count
    N(
RRtwinapitComtwmitWMIt
win32_processR t_get_process_infot	ProcessId(tcounttwmi_objt	processestprocess_infotproc((s;/usr/lib/python2.7/site-packages/salt/modules/win_status.pytprocsfs

cC@sBtj�}|j��|j�j}WdQX|r>t|�S|S(u,
    .. versionadded:: 2015.8.0

    Returns the amount of memory that salt is using

    human_readable : False
        return the value in a nicely formatted number

    CLI Example:

    .. code-block:: bash

        salt '*' status.saltmem
        salt '*' status.saltmem human_readable=True
    N(RtProcesstoneshottmemory_infotrssR^(R_tptmem((s;/usr/lib/python2.7/site-packages/salt/modules/win_status.pytsaltmem�s

cC@sHtjjtj��}tjj�|}|r>tj|�S|j�S(u�
    .. versionadded:: 2015.8.0

    Return the system uptime for the machine

    Args:

        human_readable (bool):
            Return uptime in human readable format if ``True``, otherwise
            return seconds. Default is ``False``

            .. note::
                Human readable format is ``days, hours:min:sec``. Days will only
                be displayed if more than 0

    Returns:
        str:
            The uptime in seconds or human readable format depending on the
            value of ``human_readable``

    CLI Example:

    .. code-block:: bash

        salt '*' status.uptime
        salt '*' status.uptime human_readable=True
    (tdatetimet
fromtimestampRRtnowRt	text_typet
total_seconds(R_tstartup_timetuptime((s;/usr/lib/python2.7/site-packages/salt/modules/win_status.pyR��scC@sXtjjj|jpd�}tjjj|j�}td|d|t|��}|S(u%
    Return  process information
    utcmdtname(RRtstringutilst
to_unicodetCommandLinetNametdictt_get_process_owner(RqR�R�tinfo((s;/usr/lib/python2.7/site-packages/salt/modules/win_status.pyRk�scC@si}d	\}}}yK|j�\}}}tjjj|�|d<tjjj|�|d<Wntk
ru}nX|r�t||f�r�tjjj|�|d<tjjj|�|d<nH|jd
kr�|dkr�d|d<d|d<nt	j
d|j|�|S(Nuuseruuser_domainiiiuSYSTEMuNT AUTHORITYu3Error getting owner of process; PID='%s'; Error: %s(NNN(ii(RStGetOwnerRRR�R�t	ExceptiontallRltlogtwarning(tprocesstownertdomaint
error_codeR"texc((s;/usr/lib/python2.7/site-packages/salt/modules/win_status.pyR��s"

	
cC@s�|dkr"tj|�d}n�|dkrHtj|d�d}nc|dkrntj|d�d}n=|dkr�tj|d�d}ntj|d�d	}|S(
NiuBi�uKBi@uMBIuGBuTB(RR}(tvalttstr((s;/usr/lib/python2.7/site-packages/salt/modules/win_status.pyR^�sc	C@s%d�}d}d}|r*t|�}n|s4dStdd�dkrcttdd��}nt}||�}x$|D]}||kr|t}Pq|q|W||k	r!tjjj	ddt
d	t�}|r�|ji|d
6tjj
dd��q!|ji|d
6tjj
dd
��n|S(uW
    .. versionadded:: 2015.5.0

    Fire an event if the minion gets disconnected from its master. This
    function is meant to be run via a scheduled job from the minion. If
    master_ip is an FQDN/Hostname, is must be resolvable to a valid IPv4
    address.

    CLI Example:

    .. code-block:: bash

        salt '*' status.master
    cS@s�t�}ytjddddg�}Wn$tjk
rNtjd��nXtjjj	|�j
d�}xm|D]e}d|kr�qtn|j
�}|djd	d
�\}}t|�|kr�qtn|j
|�qtW|S(u�
        Windows specific helper function.
        Returns set of ipv4 host addresses of remote established connections
        on local or remote tcp port.

        Parses output of shell 'netstat' to get connections

        PS C:> netstat -n -p TCP

        Active Connections

          Proto  Local Address          Foreign Address        State
          TCP    10.1.1.26:3389         10.1.1.1:4505          ESTABLISHED
          TCP    10.1.1.26:56862        10.1.1.10:49155        TIME_WAIT
          TCP    10.1.1.26:56868        169.254.169.254:80     CLOSE_WAIT
          TCP    127.0.0.1:49197        127.0.0.1:49198        ESTABLISHED
          TCP    127.0.0.1:49198        127.0.0.1:49197        ESTABLISHED
        unetstatu-nu-puTCPuFailed netstatu
uESTABLISHEDiu:i(tsett
subprocesstcheck_outputtCalledProcessErrorR�terrorRRR�R�tsplittrsplittinttadd(tporttremotestdatatlinestlinetchunkstremote_hosttremote_port((s;/usr/lib/python2.7/site-packages/salt/modules/win_status.pyt_win_remotes_on
s 	

i�Nu
config.getupublish_portuuminiontoptstlistenumasterttypeu	connectedudisconnected(RSt_host_to_ipst__salt__R�RtTrueRRteventt	get_eventt__opts__t
fire_eventtminiontmaster_event(	tmastert	connectedR�R�t
master_ipstmaster_connection_statust
connected_ipst	master_ipR�((s;/usr/lib/python2.7/site-packages/salt/modules/win_status.pyR��s*	&
!))(<t__doc__t
__future__RRRRRztloggingR�t	getLoggerR	R�tsalt.utils.eventRtsalt.utils.platformtsalt.utils.stringutilstsalt.utils.win_pdhtsalt.utils.networkRR�tsalt.utils.functoolsRRtsalt.extRtsalt.modules.statusRRtcopyRRRRhtsalt.utils.winapiR�RRtImportErrorRRR�Rt	StructureRRt__func_alias__R.RERQRVRXRSReRrRyR�RkR�R^R�(((s;/usr/lib/python2.7/site-packages/salt/modules/win_status.pyt<module>
s\	


	S	
	&	(		 	$ %			

Zerion Mini Shell 1.0