gfVDtdZddlZddlZddlZddlZddlmZddlmZddlm Z ddlm Z ddlm Z dd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZgZe jZe jZe jeje j ej!e j"ej#e j$ej%e j&ej'e j(ej)e j*ej+e j,ej-e j.ej/e j0ej1e j2ej3e j4ej5i Z6e j7ej8e j9ej:e j;ej<e j=ej>e j?ej@iZAeBddddddddddd ZCeBddddddddZDedgd ZEed!gd"ZFed#gd$ZGed%eGjHd&zZId'ZJd(ZKd)ZLd*ZMd+ZNd,ZOd-ZPd.ZQe jRZRe jSZSd=d0ZTd1ZUe jVZVe jWZWd>d3ZXd4ZYd5ZZd6Z[d7Z\e j]Z]d8Z^d9Z_ej`d:ZaGd;dr; speculativeavailr:r9s o/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/psutil/_psosx.pyvirtual_memoryrJpsx8<8H8J8J5E68UD+ tOE E>D KDUU]U1===G wd5 * **ctj\}}}}}t||d}tj||||||S)z=Swap system memory as a (total, used, free, sin, sout) tuple.rrC)rEswap_memrrsswap)r7r:r;sinsoutr9s rI swap_memoryrQsF#'=?? E4sDD%222G =dGS$ ? ??rKcVtj\}}}}t||||S)z(Return system CPU times as a namedtuple.)rE cpu_timesr0r1s rIrSrSs,#~//D$ T4 . ..rKcg}tjD]0}|\}}}}t||||}||1|S)z(Return system CPU times as a named tuple)rE per_cpu_timesr0append)retcpu_tr2r3r4r5items rIrUrUsZ C#%%#( dFDtVT22 4 JrKc(tjS)z0Return the number of logical CPUs in the system.)rEcpu_count_logicalrKrIr[r[s  ! # ##rKc(tjS)z1Return the number of physical CPUs in the system.)rEcpu_count_physr\rKrIcpu_count_physicalr_s    rKcbtj\}}}}}tj||||SN)rE cpu_statsr scpustats) ctx_switches interruptssoft_interruptssyscallstrapss rIrbrbs: ?L*ox  j/8 = ==rKc^tj\}}}tj|||gS)zReturn CPU frequency. On macOS per-cpu frequency is not supported. Also, the returned frequency never changes, see: https://arstechnica.com/civis/viewtopic.php?f=19&t=465002 )rEcpu_freqrscpufreq)currmin_max_s rIrjrjs. }D$  T4 . . //rKFc >g}tj}|D]}|\}}}}|dkrd}|s?tj|rtj|sRdx}} t j|||||| } || |S)z8Return mounted disk partitions as a list of namedtuples.noneN) rEdisk_partitionsospathisabsexistsr sdiskpartrV) allretlist partitions partitiondevice mountpointfstypeoptsmaxfilemaxpathntuples rIrrrrsG%''J   +4( FD V  F 7==(( v0F0F   '"6:vt#*G55v NrKc tj\}}}n#t$rYdSwxYw|dk}|r tj}n|dkr tj}n|dz}tj|||S)zReturn battery information.Nr<)rEsensors_batteryNotImplementedErrorrPOWER_TIME_UNLIMITEDPOWER_TIME_UNKNOWNsbattery)r9minsleft power_pluggedsecslefts rIrrs+/+?+A+A(== tt"Q&M!/ R-b=  GX} = ==s  ((inetcg}tD]p} t||}|r9|D]6}t||gz}|t j|7a#t$rYmwxYw|S)z System-wide network connections.)pidsProcess connectionslistrVrsconnr)kindrWpidconscs rInet_connectionsrs Cvv 2 2 23<<++D11D 222AQ3%AJJw}a01111     H  Js"A22 A?>A?ct}i}|D]} tj|}tj|}tj|\}}t tdrtj|}tj ||||||<#t$r }|j tj krYd}~d}~wwxYw|S)z)Get NIC stats (isup, duplex, speed, mtu). NicDuplexN) net_io_counterskeys cext_posix net_if_mtunet_if_is_runningnet_if_duplex_speedhasattrrr snicstatsOSErrorerrnoENODEV)namesrWr'mtuisupduplexspeederrs rI net_if_statsrs    " " $ $E C D D D'--C/55D&:4@@MFE w ,, 3 *622)$sCCCII   yEL(()((((  Js?B++ C5CCc(tjS)z:The system boot time expressed in seconds since the epoch.)rE boot_timer\rKrIrrs >  rKcg}tj}|D]E}|\}}}}}|dkr|stj||pd|pd||}||F|S)z:Return currently connected users as a list of namedtuples.~N)rEusersrsuserrV) ryrawlistrYr2ttyhostnametstamprnts rIrr"sGjllG+/(c8VS #::    ]4h.>$ L Lr NrKctj}d|vrj td|ddn1#t $rYn%t $r|ddYnwxYw|SNr)rErr create_timeinsertrr )lss rIrr6s B{{  AJJ " " $ $ $ IIaOOOO    D    IIaOOOOO  Is7A A?A?>A?c tj|td}|tjkS#t$rYdSwxYw)Nr&F)rEproc_kinfo_oneshotkinfo_proc_mapSZOMB Exception)rsts rI is_zombierIsP  $S ) ).*B CTZ uus47 AAcFtjfd}|S)z`Decorator which translates bare OSError exceptions into NoSuchProcess and AccessDenied. cx |g|Ri|S#t$rOt|jr t|j|j|jt |j|jt$rt|j|jtj $r!t|j|j|jwxYwra) rrrr_name_ppidrrr rEZombieProcessError)selfargskwargsfuns rIwrapperz wrap_exceptions..wrapperUs B3t-d---f-- -! : : :"" :#DHdj$*EEE#DHdj999 5 5 5tx44 4& B B B$*djAA A Bs B*B9) functoolswraps)rrs` rIwrap_exceptionsrQs?_S B B B B B NrKc#zK dVdS#ttf$r}t|ts|jtjkro |}|t jkr t|j |j |j t|j |j #t$r|wxYwd}~wwxYw)zThere are some poor C APIs which incorrectly raise ESRCH when the process is still alive or it's a zombie, or even RuntimeError (those who don't set errno). This is here in order to solve: https://github.com/giampaolo/psutil/issues/1044 N)r RuntimeError isinstancerESRCHr&r STATUS_ZOMBIErrrrr r)procrr&s rI catch_zombieres  \ " c< ( ( CI,D,D =W222'$*djIII&tx<<< !      s- B:*B5B$A B5$ B11B55B:cveZdZdZgdZdZeedZeedZ dZ dZ edZ ed Z ed Zed Zed Zed ZedZedZedZedZedZedZedZedZedZedZed!dZedZed"dZedZedZ edZ!ed Z"dS)#rz1Wrapper class around underlying C implementation.)rrr_cachec0||_d|_d|_dSra)rrr)rrs rI__init__zProcess.__init__s  rKctj|j}t|ttksJ|Sra)rErrlenrrrWs rI_get_kinfo_proczProcess._get_kinfo_procs:%dh//3xx3~...... rKct|5tj|j}dddn #1swxYwYt |t t ksJ|Sra)rrEproc_pidtaskinfo_oneshotrrpidtaskinfo_maprs rI_get_pidtaskinfozProcess._get_pidtaskinfos$   : :/99C : : : : : : : : : : : : : : :3xx3////// s 6::cn|j||j|dSra)rcache_activaterrs rI oneshot_enterzProcess.oneshot_enters6 ++D111 ,,T22222rKcn|j||j|dSra)rcache_deactivaterrs rI oneshot_exitzProcess.oneshot_exits6 --d333 ..t44444rKc|td}||ntj|jS)Nr')rrrE proc_namer)rr's rIr'z Process.names8##%%nV&<='ttT^DH-E-EErKct|5tj|jcdddS#1swxYwYdSra)rrEproc_exerrs rIexez Process.exe $   + +=** + + + + + + + + + + + + + + + + + + 6::ct|5tj|jcdddS#1swxYwYdSra)rrE proc_cmdlinerrs rIcmdlinezProcess.cmdlines $   / /$TX.. / / / / / / / / / / / / / / / / / /rct|5ttj|jcdddS#1swxYwYdSra)rrrE proc_environrrs rIenvironzProcess.environs $   D D&t'8'B'BCC D D D D D D D D D D D D D D D D D Ds&AA Acd|td|_|jS)Nr)rrrrs rIrz Process.ppids'))++N6,BC zrKct|5tj|jcdddS#1swxYwYdSra)rrEproc_cwdrrs rIcwdz Process.cwdrrc|}tj|td|td|tdS)Nrrr rrpuidsrrrawtuples rIuidsz Process.uidsN''))} ^F+ , ^F+ , ^F+ ,.. .rKc|}tj|td|td|tdS)Nr!r"r#rrs rIgidsz Process.gidsrrKc|td}tj} ||S#t$rYdSwxYw)Nr$)rrrget_terminal_mapKeyError)rtty_nrtmaps rIterminalzProcess.terminals\%%''w(?@(** <    44 sA AAc|}t|td|td|td|tdS)Nr*r+r,r-)rr?rrs rI memory_infozProcess.memory_infosY((** _U+ , _U+ , _Y/ 0 _Y/ 0    rKcv|}tj|j}t ||fzSra)r rEproc_memory_ussrr@)r basic_memrAs rImemory_full_infozProcess.memory_full_infos7$$&& "48,,cW,--rKc|}tj|td|tdddS)Nr(r)g)rr pcputimesrrs rIrSzProcess.cpu_timessG((** _Z0 1 _Z0 1   rKcL|tdS)Nr%)rrrs rIrzProcess.create_times##%%nW&=>>rKcv|td}tj|dS)Nr/r)rrrpctxsw)rvols rInum_ctx_switcheszProcess.num_ctx_switchess1 ##%%oj&AB~c1%%%rKcL|tdS)Nr.)rrrs rI num_threadszProcess.num_threadss$$&&|'DEErKc&|jdkrgSg}t|5tj|j}dddn #1swxYwY|D]>\}}t |r*t j||}||?|Sr)rrrEproc_open_filesr r popenfilerV)rfilesrrtfdrs rI open_fileszProcess.open_filess 8q==I $   5 5*4844G 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 % %HD"T"" % *444 V$$$ sAA  A rc |tvr7td|dddtDt|\}}t|5t j|j||}dddn #1swxYwYg}|D]:}|\}}} } } } t||| | | | t} | | ;|S)Nzinvalid z kind argument; choose between z, c,g|]}t|Sr\)repr).0xs rI z'Process.connections..s0L0L0LQa0L0L0LrK) r ValueErrorjoinrrEproc_connectionsrr TCP_STATUSESrV)rrfamiliestypesrrWrYrfamtypeladdrraddrr&rs rIrzProcess.connectionssB y * $dii0L0L)0L0L0L&M&M&MOPP P#D/% $   G G+DHhFFG G G G G G G G G G G G G G G G  D26 /BT5%CueV ,..B JJrNNNN s BB B c|jdkrdSt|5tj|jcdddS#1swxYwYdSr)rrrE proc_num_fdsrs rInum_fdszProcess.num_fdss 8q==1 $   / /$TX.. / / / / / / / / / / / / / / / / / /sAA ANcBtj|j||jSra)rwait_pidrr)rtimeouts rIwaitz Process.wait&s 7DJ???rKct|5tj|jcdddS#1swxYwYdSra)rr getpriorityrrs rInice_getzProcess.nice_get*s $   4 4)$(33 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4rct|5tj|j|cdddS#1swxYwYdSra)rr setpriorityr)rvalues rInice_setzProcess.nice_set/s $   ; ;)$(E:: ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;s 7;;c|td}t|dS)Nr&?)rr PROC_STATUSESget)rcodes rIr&zProcess.status4s3##%%nX&>?  s+++rKctj|j}g}|D]1\}}}tj|||}||2|Sra)rE proc_threadsrrpthreadrV)rrry thread_idutimestimers rIthreadszProcess.threads:s\#DH--'. # # #Iue_Yu==F NN6 " " " "rKrra)#__name__ __module__ __qualname____doc__ __slots__rrr rrrrr'rrrrrrrr r rrSrrrr rr3r7r:r>r&rJr\rKrIrrs";;333I _ _333555FF_F++_+//_/DD_D_++_+.._..._._  _ .._. _??_?&&_&FF_F  _    _ //_/ @@@_@44_4;;_;,,_, _rKr)FrK)drO contextlibrrrs collectionsrrqrrrrErrr r r r r rrrr_compatrr__extra__all__ getpagesizePAGESIZEAF_LINKTCPS_ESTABLISHEDCONN_ESTABLISHED TCPS_SYN_SENT CONN_SYN_SENTTCPS_SYN_RECEIVED CONN_SYN_RECVTCPS_FIN_WAIT_1CONN_FIN_WAIT1TCPS_FIN_WAIT_2CONN_FIN_WAIT2TCPS_TIME_WAITCONN_TIME_WAIT TCPS_CLOSED CONN_CLOSETCPS_CLOSE_WAITCONN_CLOSE_WAIT TCPS_LAST_ACK CONN_LAST_ACK TCPS_LISTEN CONN_LISTEN TCPS_CLOSING CONN_CLOSINGPSUTIL_CONN_NONE CONN_NONEr*SIDL STATUS_IDLESRUNSTATUS_RUNNINGSSLEEPSTATUS_SLEEPINGSSTOPSTATUS_STOPPEDrrrAdictrrr0r6r?_fieldsr@rJrQrSrUr[r_rbrj disk_usagedisk_io_countersrrrr net_if_addrsrrrrr pid_existsrrcontextmanagerrobjectrr\rKrIrs %$  """"""!!!!!!))))))!!!!!!######""""""++++++""""""((((((""""""""""""$$$$$$'''''' ": ! # #   73-G1'0'0/g('1-g)w+7,   Iw"Iw%K(J&J%      $        $ J{$F$F$F G G   --- . .z&>>>?? :j$,": ; ;***"@@@/// $$$ !!! ===000 (.>>>,&& $2   (     ( 2BBBBBfBBBBBrK