bgq dZddlmZddlmZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlmZddl mZddl mZddl mZ dd l mZn #e$rdZYnwxYw dd l mZn #e$rdZYnwxYwe jd krddlZndZe jdd kZeejd ZeZgdZejdkZejdkZ e j!"dZ#e j!"dZ$e$Z%e j!"dZ&e j!"dZ'e j!"dZ(e&pe'pe(Z)e j!"dZ*e j!"dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2dZ3d Z4d!Z5d"Z6d#Z7d$Z8d%Z9d&Z:d'Z;d(Zd+Z?d,Z@d-ZAd.ZBd/ZCd0ZDd1ZEed2ZFd3ZGdZHn5Gd4d5ejIZJeKLeJjMed6ZNd7ZOn5Gd8d9ejIZPeKLePjMe jQZResd:ZSn" e jTZSn#eU$r erd;nd:ZSYnwxYwedgd?ZWed@gdAZXedBgdCZYedDgdEZZedFgdGZ[edHgdIZ\edJgdKZ]edLgdMZ^edNgdOZ_edPgdQZ`edRgdSZaedTgdUZbedVdWdXgZcedYgdZZded[d\d]gZeed^gd_Zfed`gdaZgedbgdaZhedcgddZiededfdggZjedhdidjgZkedkgdlZledmdndogZmeeegeegfeegegfegegfeegegfegegfeegeegfegeegfegeegfdpZne enLegegfegegfdqeenLdregeegfiGdsdteoZpGdudvepZqGdwdxeqZrGdydzepZsGd{d|epZter-euevewr evd}Zxn eyevd}Zxexd~ndZzddZ{dZ|dZ}dZ~dZe|dZdZdZdZddZdZGddZdZeZeje_eje_dZdZdZeefdZefdZddZdZerdZndZe|e jfdZddZdde jfdZdZdS)z9Common objects shared by __init__.py and _ps*.py modules.)division)print_functionN) namedtuple)AF_INET) SOCK_DGRAM) SOCK_STREAM)AF_INET6)AF_UNIX)r PSUTIL_DEBUG)RFREEBSDBSDLINUXNETBSDOPENBSDMACOSOSXPOSIXSUNOSWINDOWS CONN_CLOSECONN_CLOSE_WAIT CONN_CLOSINGCONN_ESTABLISHEDCONN_FIN_WAIT1CONN_FIN_WAIT2 CONN_LAST_ACK CONN_LISTEN CONN_NONE CONN_SYN_RECV CONN_SYN_SENTCONN_TIME_WAITNIC_DUPLEX_FULLNIC_DUPLEX_HALFNIC_DUPLEX_UNKNOWN STATUS_DEADSTATUS_DISK_SLEEP STATUS_IDLE STATUS_LOCKEDSTATUS_RUNNINGSTATUS_SLEEPINGSTATUS_STOPPEDSTATUS_SUSPENDEDSTATUS_TRACING_STOPSTATUS_WAITINGSTATUS_WAKE_KILL STATUS_WAKING STATUS_ZOMBIE STATUS_PARKEDENCODING ENCODING_ERRSr pconn pcputimespctxswpgidspiopionice popenfilepthreadpuidssconn scpustatssdiskio sdiskpart sdiskusagesnetiosnicaddr snicstatssswapsuser conn_tmapdeprecated_method isfile_strictmemoizeparse_environ_blockpath_exists_strict usage_percent supports_ipv6sockfam_to_enumsocktype_to_enum wrap_numbers open_text open_binarycatbcat bytes2humanconn_to_ntupledebughiliteterm_supports_colors print_colorposixntlinuxdarwin)freebsd midnightbsdopenbsdnetbsd)sunossolarisaixrunningsleepingz disk-sleepstoppedz tracing-stopzombiedeadz wake-killwakingidlelockedwaiting suspendedparked ESTABLISHEDSYN_SENTSYN_RECV FIN_WAIT1 FIN_WAIT2 TIME_WAITCLOSE CLOSE_WAITLAST_ACKLISTENCLOSINGNONEceZdZdZdZdZdS) NicDuplexrrrN)__name__ __module__ __qualname__r$r%r&E/opt/cloudlinux/venv/lib64/python3.11/site-packages/psutil/_common.pyrrs rrceZdZdZdZdS) BatteryTimerrN)rrrPOWER_TIME_UNKNOWNPOWER_TIME_UNLIMITEDrrrrrs!rrreplacesurrogateescaperH)totalusedfreepercentsinsoutrD)rrrrrB) read_count write_count read_bytes write_bytes read_time write_timerC)device mountpointfstypeoptsmaxfilemaxpathrE) bytes_sent bytes_recv packets_sent packets_recverrinerroutdropindropoutrI)nameterminalhoststartedpidr@)fdfamilytypeladdrraddrstatusrrF)raddressnetmask broadcastptprG)isupduplexspeedmtuflagsrA) ctx_switches interruptssoft_interruptssyscallsscpufreq)currentminmaxshwtemp)labelrhighcriticalsbattery)rsecsleft power_pluggedsfanrrr8)usersystem children_userchildren_systemr=pathrr>)id user_time system_timer?)real effectivesavedr:r;)rrrrr<ioclassvaluer9 voluntary involuntaryr7)rrrrrraddripport)alltcptcp4udpudp4inetinet4inet6)tcp6udp6unixc(eZdZdZdZdZdZdZdS)ErrorzQBase exception class. All other psutil exceptions inherit from this one. psutilctj}|D],}t||d}|r|||<|dkr |dkr|||<-|S)Nrr) collections OrderedDictgetattr)selfattrsinforrs r _infodictzError._infodictsc&(( # #DD$--E #"T 5A::"T  rc|d}|r5ddd|Dz}nd}ddt|dd|fDS) N)rppidrz(%s), c"g|] \}}|d| S=r.0kvs r z!Error.__str__..+s';;;daAAAqq!;;;r cg|]}||Srr)rxs rrz!Error.__str__...sMMMq1MMMMrmsg)rjoinitemsrrrdetailss r__str__z Error.__str__&s~~566  tyy;;djjll;;; = ==GGGxxMMWT5"%=%=w$GMMMNNNrc|d}dd|D}d|jjd|dS)N)rrrsecondsrrc"g|] \}}|d| Srrrs rrz"Error.__repr__..3s'GGG$!Q11-GGGrzpsutil.())rr r  __class__rr s r__repr__zError.__repr__0sX~~GHH))GG$**,,GGGHH"&."9"9"9777CCrN)rrr__doc__rr rrrrrrsZJOOODDDDDrrceZdZdZdZddZdS) NoSuchProcesszXException raised when a process with a certain PID doesn't or no longer exists. rNcht|||_||_|pd|_dS)Nzprocess no longer existsr__init__rrrrrrrs rrzNoSuchProcess.__init__=s3 t 44rNNrrrrrrrrrr7s9J555555rrceZdZdZdZddZdS) ZombieProcessa1Exception raised when querying a zombie process. This is raised on macOS, BSD and Solaris only, and not always: depending on the query the OS may be able to succeed anyway. On Linux all zombie processes are querable (hence this is never raised). Windows doesn't have zombie processes. rNc`t||||||_|pd|_dS)Nz"PID still exists but it's a zombie)rrrr)rrrrrs rrzZombieProcess.__init__Ms4tS$444 >>rNNNrrrrrrDs9 J??????rrceZdZdZdZddZdS) AccessDeniedz@Exception raised when permission to perform an action is denied.rNcht|||_||_|pd|_dS)Nrrrs rrzAccessDenied.__init__Ws1 t 9"rr!rrrrr#r#Ss3JJJrr#ceZdZdZdZddZdS)TimeoutExpiredzWRaised on Process.wait(timeout) if timeout expires and process is still alive. rNcxt|||_||_||_d|z|_dS)Nztimeout after %s seconds)rrrrrr)rrrrs rrzTimeoutExpired.__init__ds9 t  -7rrrrrrr&r&^s9J888888rr&execzvdef raise_from(value, from_value): try: raise value from from_value finally: value = None c|Nr)r from_values r raise_fromr,s rcx t||z dz}|t||}|S#t$rYdSwxYw)z5Calculate percentage usage of 'used' against 'total'.dNg)floatroundZeroDivisionError)rrround_rets rrPrPs\T{{U"c)  V$$C sss + 99cftjfd}fd}i||_|S)aA simple memoize decorator for functions supporting (hashable) positional arguments. It also provides a cache_clear() function for clearing the cache: >>> @memoize ... def foo() ... return 1 ... >>> foo() 1 >>> foo.cache_clear() >>> It supports: - functions - classes (acts as a @singleton) - staticmethods - classmethods It does NOT support: - methods c|tt|f} |S#t$r6 |i|x}|<n"#t$r}t |dd}~wwxYw|cYSwxYwr*) frozensetsortedr KeyError Exceptionr,)argskwargskeyr3errcachefuns rwrapperzmemoize..wrappersYvfllnn55667 :     ,#&3#7#7#77eCjj , , , d+++ ,JJJ  s3; A; AA; A3A..A33A;:A;c0dS)z Clear cache.N)clear)r>sr cache_clearzmemoize..cache_clears r) functoolswrapsrC)r?r@rCr>s` @rrMrMsf._S       E%G Nrcntjfd}d}d}||_||_|S)aA memoize decorator which is disabled by default. It can be activated and deactivated on request. For efficiency reasons it can be used only against class methods accepting no arguments. >>> class Foo: ... @memoize ... def foo() ... print(1) ... >>> f = Foo() >>> # deactivated (default) >>> foo() 1 >>> foo() 1 >>> >>> # activated >>> foo.cache_activate(self) >>> foo() 1 >>> foo() >>> foo() >>> cN |j}n#t$r1 |cYS#t$r}t|dd}~wwxYwt$rN |}n"#t$r}t|dd}~wwxYw ||j<n#t$rYnwxYwYnwxYw|Sr*)_cacheAttributeErrorr9r,r8)rr3r=r?s rr@z'memoize_when_activated..wrappers  +c"CC , , , ,s4yy    , , , d+++ ,    ,c$ii , , , d+++ , #& C  !      sv  B" )B" AAA B" A! B"! B+A;;BB" BB" BB"BB"!B"ci|_dS)zjActivate cache. Expects a Process instance. Cache will be stored as a "_cache" instance attribute.N)rHprocs rcache_activatez.memoize_when_activated..cache_activates rc. |`dS#t$rYdSwxYw)zDeactivate and clear cache.N)rHrIrKs rcache_deactivatez0memoize_when_activated..cache_deactivates2      DD s  )rDrErMrO)r?r@rMrOs` rmemoize_when_activatedrPsh4_S2 ,G/G Nrc tj|}tj|jS#t$r+}|jt jt jfvrYd}~dSd}~wwxYw)zSame as os.path.isfile() but does not swallow EACCES / EPERM exceptions, see: http://mail.python.org/pipermail/python-dev/2012-June/120787.html NF)osstatS_ISREGst_modeOSErrorerrnoEPERMEACCES)rstr=s rrLrLso ( WT]] |BJ'''  9el3 3 3 uuuuus/ A$ AA$c tj|dS#t$r+}|jtjtjfvrYd}~dSd}~wwxYw)zSame as os.path.exists() but does not swallow EACCES / EPERM exceptions, see: http://mail.python.org/pipermail/python-dev/2012-June/120787.html TNF)rRrSrVrWrXrY)rr=s rrOrOsb   t  9el3 3 3 uuuuus A  AA c(tjrtdS tjttj}t j|5|ddddn #1swxYwYdS#tj$rYdSwxYw)z2Return True if IPv6 is supported on this platform.NF)z::1rT)sockethas_ipv6r r contextlibclosingbinderror)socks rrQrQs ?h.u}Xv'9::   % % " " IIj ! ! ! " " " " " " " " " " " " " " "t <uus58A>A1% A>1A55A>8A59A>>BBci}d}t} |d|}||krnU|d||}||kr2|||}||dz|}|r|}|||<|dz}r|S)zCParse a C environ block of environment variables into a dictionary.rTrr)rfindupper)datar3posWINDOWS_next_pos equal_posr<rs rrNrN-s C CH99T3'' s?? IIc311 s??s9}%CQx/0E "iikkCHl Jrcbt|S tj|S#t$r|cYSwxYw)zConvert a numeric socket family value to an IntEnum member. If it's not a known member, return the numeric value itself. )enumr] AddressFamily ValueErrornums rrRrRIsH |  ',, ,   JJJ   ..cbt|S tj|S#t$r|cYSwxYw)zConvert a numeric socket type value to an IntEnum member. If it's not a known member, return the numeric value itself. )rnr] SocketKindrprqs rrSrSVsH |  $S)) )   JJJ rsc p|tjtfvr|r t|}|r t|}|tjkr,|ttfvr||t }nt }t|}t|}|t||||||St|||||||S)z2Convert a raw connection tuple to a proper ntuple.) r]rr rrgetr rRrSr7r@)rfamtype_rrr status_maprs rrZrZcs v~x(((  !%LE  !%LE """sw.A'A'A 22 #  C U # #E {ReUE6:::ReUE63???rcfd}|S)zA decorator which can be used to mark a method as deprecated 'replcement' is the method name which will be called instead. c|jdd|j|_tj|fd}|S)Nz*() is deprecated and will be removed; use z () insteadchtjtdt||i|S)Nr)category stacklevel)warningswarnDeprecationWarningr)rr:r;r replacements rinnerz/deprecated_method..outer..inners: M#(:q I I I I-74--t>v>> >r)rrrDrE)r?rrrs @routerz deprecated_method..outerzsc LLL+++' ; CK    ? ? ? ? ?   ? rr)rrs` rrKrKvs#      Lrc8eZdZdZdZdZdZdZd dZdZ dS) _WrapNumberszNWatches numbers so that they don't overflow and wrap (reset to zero). c`tj|_i|_i|_i|_dSr*) threadingLocklockr> reminders reminder_keysrs rrz_WrapNumbers.__init__s-N$$  rc||jvsJ||jvsJ||jvsJ||j|<tjt |j|<tjt |j|<dSr*)r>rrr defaultdictintset)r input_dictrs r _add_dictz_WrapNumbers._add_dicts}4:%%%%4>))))4-----% 4*6s;;t#.#:3#?#?4   rc|j|}t|t|z }|D]4}|j||D]}|j||=|j||=5dS)zIn case the number of keys changed between calls (e.g. a disk disappears) this removes the entry from self.reminders. N)r>rkeysrr)rrrold_dict gone_keysgone_keyremkeys r_remove_dead_remindersz#_WrapNumbers._remove_dead_reminderss:d# ((3z/@/@+A+AA ! 3 3H,T28< 1 1N4(00"4(22 3 3rc||jvr||||S||||j|}i}|D]}||} ||}n#t$r|||<Y%wxYwg}t t |D]} || } || } || f} | | krA|j|| xx| z cc<|j|| | | | |j|| zt|||<||j|<|S)zkCache dict and sum numbers which overflow and wrap. Return an updated copy of `input_dict` ) r>rrrr8rangelenrraddappendtuple) rrrrnew_dictr< input_tuple old_tuplebitsi input_value old_valuers rrunz_WrapNumbers.runs tz ! ! NN:t , , ,  ##J555:d#??$$ ( (C$S/K $SM    !,    D3{++,, H H)!n %aL q**N4(000I=000&t,S155f=== K$.*>v*FFGGGG!$KKHSMM% 4s&A//BBNc|j5|L|j|j|jnQ|j|d|j|d|j|dddddS#1swxYwYdS)z>Clear the internal cache, optionally only for function 'name'.N)rr>rBrrpop)rrs rrCz_WrapNumbers.cache_clears Y 3 3|   """$$&&&"((**** tT***""4..."&&tT222 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3sB B55B9<B9cl|j5|j|j|jfcdddS#1swxYwYdS)z5Return internal cache dicts as a tuple of 3 elements.N)rr>rrrs r cache_infoz_WrapNumbers.cache_infos Y D DJ0BC D D D D D D D D D D D D D D D D D Ds )--r*) rrrrrrrrrCrrrrrrs   @@@ 3 3 3%%%N 3 3 3 3DDDDDrrctj5t||cdddS#1swxYwYdS)zGiven an `input_dict` and a function `name`, adjust the numbers which "wrap" (restart from zero) across different calls by adding "old value" to "new value" and return an updated dict. N)_wnrr)rrs rrTrTs ))wwz4(())))))))))))))))))s 599ic0t|dtS)Nrb buffering)openFILE_READ_BUFFER_SIZE)fnames rrVrVs t'< = = ==rctst|dtSt|dttt} t|_n.#t $rYn"t$r|wxYw|S)zOn Python 3 opens a file in text mode by using fs encoding and a proper en/decoding errors handler. On Python 2 this is just an alias for open(name, 'rt'). rtr)rencodingerrors) PY3rrr5r6 _CHUNK_SIZErIr9close)rfobjs rrUrUs BE4+@AAAA t'<!- 9 9 9D1         Ks A A;A;c,|tur9||5}|cdddS#1swxYwYdS ||5}|cdddS#1swxYwYdS#ttf$r|cYSwxYw)zRead entire file content and return it as a string. File is opened in text mode. If specified, `fallback` is the value returned in case of error, either if the file does not exist or it can't be read(). N)_DEFAULTreadIOErrorrV)rfallback_openfs rrWrWs1 8 U5\\ Q6688                   u vvxx                  !   OOO sB6:: A=A0# A=0A44A=7A48A==BBc0t||tS)z,Same as above but opens file in binary mode.)rr)rWrV)rrs rrXrX+s ux{ ; ; ;;r%(value).1f%(symbol)sc6d}i}t|ddD]\}}d|dzdzz||<t|ddD]9}|||kr+t|||z }|tzcS:|t |d|zS)zUsed by various scripts. See: http://goo.gl/zeJZl >>> bytes2human(10000) '9.8K' >>> bytes2human(100001221) '95.4M' ) BKMGTPEZYrN r)symbolr) enumeratereversedr/localsdict)nformatsymbolsprefixrsrrs rrYrY0s   !"" "" KK  C"%((4....!!! 44s : r ) r inspect getframeinfo currentframef_back isinstancer9rVrEnvironmentErrorr rr)rrrlineno_linesindexs rr[r[s )0)=)=  " " )*+*+&vq% c9 % % *#2BCDD *#c)#c) EEE66633?:        rr*)r)NF)r __future__rrrr_rWrDrRr]rSrrrrrrrr ImportErrorr version_infornrboolgetenvr objectr__all__rrrplatform startswithrrrrrrrrAIXr+r,r(r-r/r3r'r1r2r)r*r0r.r4rr"r!rrr#rrrrrr r$r%r&IntEnumrglobalsupdate __members__rrrgetfilesystemencodingr5r6getfilesystemencodeerrorsrIrHrDrBrCrErIr@rFrGrArrrrr8r=r>r?r:r;r<r9r7rrJr9rrrr#r&r __builtins__rexec_rr,rPrMrPrLrOrQrNrRrSrZrKrrTrrCrrrVrUrWrXrYrrstdoutr]r\r^r[rrrr8s  @?  %%%%%%  """"""HHHGGGvKKKK D qQtIBIn--.. 688   J 7 'T/ (( ))  , ! !"< = = , ! !) , ,   * * ""F  455 le$$ $      !        <OODL  GIIY*+++<"""""dl""" GII[,--- %3 $ & & BMMB5577 BBB-2A)) B  7%%% & &Z &J&J&J K K *Y!<!<!< = = J{%;%;%; < <  H444 5 5  7JJJKK 7... / / :jJJJ L L J{BBB D D  JNNN P P  :j";";"; < < * 777 9 9 :j"J"J"J K Kz&7I.// J{MMM O O  J{VTN 3 3 *Y B B B C C 7:::;; 7:::;;j66677 *YG 4 5 5 H{M: ; ; 7''' ( (z&4.))h (; *C D h + /Y & h * .Y %x ; "; <i+z2 3j; 3 4     k]+j\*   '[*56DDDDDIDDDB 5 5 5 5 5E 5 5 5 ? ? ? ? ?M ? ? ?5 8 8 8 8 8U 8 8 8*z,%%.V$ f-- E         )))XBBBJ ( ( (        8      @@@@&$TDTDTDTDTDTDTDTDn)))lnn? . ">>>4! ""<<<< 5555(--- AAAA !j     5555(E  ; ; ; ;F     s6AA! A!%A,,A65A6I** I87I8