mfjf : dZddlmZmZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZddl mZddlmZddlmZddlmZ dd lmZn #e$rdZYnwxYw dd lmZn #e$rdZYnwxYwe jd krddlZndZe jdd kZgd ZejdkZejdkZe jdZe jdZ e Z!e jdZ"e jdZ#e jdZ$e"pe#pe$Z%e jdZ&e jdZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0d Z1d!Z2d"Z3d#Z4d$Z5d%Z6d&Z7d'Z8d(Z9d)Z:d*Z;d+Zd.Z?d/Z@d0ZAed1ZBd2ZCdZDn5Gd3d4ejEZFeGHeFjIed5ZJd6ZKn5Gd7d8ejEZLeGHeLjIe jMZNesd9ZOn" e jPZOn#eQ$r erd:nd9ZOYnwxYwed;gd<ZRed=gd>ZSed?gd@ZTedAgdBZUedCgdDZVedEgdFZWedGgdHZXedIgdJZYedKgdLZZedMgdNZ[edOgdPZ\edQgdRZ]edSgdTZ^edUdVdWgZ_edXgdYZ`edZd[d\gZaed]gd^Zbed_gd`Zcedagd`ZdedbgdcZeedddedfgZfedgdhdigZgedjgdkZhedldmdngZieeegeegfeegegfegegfeegegfegegfeegeegfegeegfegeegfdoZje ejHegegfegegfdpeejHdqegeegfiGdrdsekZlGdtduelZmGdvdwemZnGdxdyelZoGdzd{elZpdd|Zqd}Zrd~ZsdZtdZuerdZvdZwdZxdZyddZzdZ{GddZ|dZ}e|Z~e~je}_e~je}_dZdZddZdZerdZndZere jfdZddZdde jfdZeejddr ddlZdZdSdZdS)z9Common objects shared by __init__.py and _ps*.py modules.)divisionprint_functionN) defaultdict) namedtuple)AF_INET) SOCK_DGRAM) SOCK_STREAM)AF_INET6)AF_UNIX)r )NFREEBSDBSDLINUXNETBSDOPENBSDMACOSOSXPOSIXSUNOSWINDOWS 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 bytes2humanconn_to_ntupledebughiliteterm_supports_colors print_colorposixntlinuxdarwinfreebsdopenbsdnetbsd)sunossolarisaixrunningsleepingz disk-sleepstoppedz tracing-stopzombiedeadz wake-killwakingidlelockedwaiting suspendedparked ESTABLISHEDSYN_SENTSYN_RECV FIN_WAIT1 FIN_WAIT2 TIME_WAITCLOSE CLOSE_WAITLAST_ACKLISTENCLOSINGNONEceZdZdZdZdZdS) NicDuplexr|r}rN)__name__ __module__ __qualname__r$r%r&E/opt/imunify360/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)isupduplexspeedmturA) 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(eZdZdZdZddZdZeZdS)ErrorzQBase exception class. All other psutil exceptions inherit from this one. psutilcJt||||_dSN) Exception__init__msg)selfrs rrzError.__init__s#4%%%rcXd|jjd|j}|S)Nzpsutil. ) __class__rrstrip)rrets r__repr__zError.__repr__s+ $ 7 7 7Byy{{rN)r)rrr__doc__rr__str__rrrrrsIJGGGrrceZdZdZdZddZdS) NoSuchProcesszXException raised when a process with a certain PID doesn't or no longer exists. rNct||||_||_||_|9|r!d|jdt |jd}n d|jz}d|z|_dSdS)N(pid=, name=)(pid=%s)zprocess no longer exists rrrrrrepr)rrrrdetailss rrzNoSuchProcess.__init__'s~ tS!!!  ; 0 0154 ????K$tx/2W>> @memoize ... def foo() ... return 1 ... >>> foo() 1 >>> foo.cache_clear() >>> c|tt|f} |S#t$r|i|x}|<|cYSwxYwr) frozensetsorteditemsKeyError)r kwargskeyrcachefuns rwrapperzmemoize..wrappersuYvfllnn55667 :    "sD3F33 3C%*JJJ s;AAc0dS)z Clear cache.N)clear)r#sr cache_clearzmemoize..cache_clears r) functoolswrapsr()r$r%r(r#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() >>> c |j}n;#t$r|cYSt$r|x}|j<YnwxYw|Sr)_cacheAttributeErrorr )rrr$s rr%z'memoize_when_activated..wrappers /+c"CC   3t99    / / /&)SYY .C$+c""" / s A A A ci|_dS)zjActivate cache. Expects a Process instance. Cache will be stored as a "_cache" instance attribute.N)r-procs rcache_activatez.memoize_when_activated..cache_activates rc. |`dS#t$rYdSwxYw)zDeactivate and clear cache.N)r-r.r0s rcache_deactivatez0memoize_when_activated..cache_deactivates2      DD s  )r)r*r2r4)r$r%r2r4s` rmemoize_when_activatedr5sh4_S      ,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)rsterrs 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)r7r8r;r<r=r>)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.rT=r})rfindupper)datarposWINDOWS_next_pos equal_posr"rs rrNrNs 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. )enumrC AddressFamily ValueErrornums rrRrR"sH |  ',, ,   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. )rUrC SocketKindrWrXs rrSrS/sH |  $S)) )   JJJ rZc p|tjtfvr|r t|}|r t|}|tjkr,|ttfvr||t }nt }t|}t|}|t||||||St|||||||S)z2Convert a raw connection tuple to a proper ntuple.) rCrr rr getr rRrSr7r@)rfamtype_rrr status_maprs rrVrV<s 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)warningswarnDeprecationWarninggetattr)rr r!r replacements rinnerz/deprecated_method..outer..innerYs: M#(:q I I I I-74--t>v>> >r)rrr)r*)r$rlrrks @routerz deprecated_method..outerSsc LLL+++' ; CK    ? ? ? ? ?   ? rr)rkrms` rrKrKOs#      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__fs-N$$  rc||jvsJ||jvsJ||jvsJ||j|<tt|j|<tt |j|<dSr)r#rtrurintset)r input_dictrs r _add_dictz_WrapNumbers._add_dictlsw4:%%%%4>))))4-----% 4*3//t#.s#3#34   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#rykeysrurt)rrzrold_dict gone_keysgone_keyremkeys r_remove_dead_remindersz#_WrapNumbers._remove_dead_remindersts: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#r{rr}r rangelenrtruaddr tuple) rrzrr~new_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)rsr#r'rtrupop)rrs rr(z_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)rsr#rtrurvs 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) rrrrrr{rrr(rrrrroroas   444 3 3 3%%%N 3 3 3 3DDDDDrroctj5t||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)_wnrsr)rzrs rrTrTs ))wwz4(())))))))))))))))))s 599c t|dfi|S)Nrb)openfnamer!s r open_binaryrs t & &v & &&rc tr6|dt|dtt |dfi|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'). encodingerrorsrt)PY3 setdefaultr5r6rrs r open_textrsR  3 *h///(M222 t & &v & &&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' ) BKMGTPEZYr}N r)symbolr) enumeratereversedrlocalsdict)nformatsymbolsprefixrsrrs rrUrUs   !"" "" KK  C"%((4....!!! 44s : rN)inspect getframeinfo currentframef_backrrr)rrlineno func_namelinesindexs rrWrWFsi181E  " " )2+2+.vy% EEE66633?:      rcdSrr)rs rrWrWMs rr)r)NF)r __future__rrrEr<r)r7rCr8rrqrg collectionsrrrrr r ImportErrorr version_inforUr__all__rrrplatform startswithrrrrrrrrAIXr+r,r(r-r/r3r'r1r2r)r*r0r.r4rr"r!rrr#rrrrrr r$r%r&IntEnumrglobalsupdate __members__rrrgetfilesystemencodingr5r6getfilesystemencodeerrorsr.rHrDrBrCrErIr@rFrGrArrrrr8r=r>r?r:r;r<r9r7rrJrrrrrrrPrMr5rLrOrQrNrRrSrVrKrorTrr(rrrrUrrstdoutrYrXrZboolgetenvrrWrrrrs  @? 0///////  ######""""""HHHGGGvKKKK D qQ   H 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{$F$F$F G G 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\*   '[*56I"=====E===&KKKKKMKKK25$/////U///,    @666r ( ( (        8      @@@@&$TDTDTDTDTDTDTDTDn)))lnn? . ''' ' ' '5555(--- AAAA !j     5555(E  ; ; ; ;F4  .!$$%%  NNN     s6AAA#A**A43A45I II