§ ½@¾jFã óð—ddlZddlmZmZmZmZmZGd„de¦«Zdedeeeeeffd„Z de de fd „Z deeeeeee e fffd „Zdeee ffd „ZdS) éN)ÚOptionalÚDictÚAnyStrÚUnionÚListcó—eZdZdZdS)Ú NotSupportedz5 Custom error to handle compatibility issues N)Ú__name__Ú __module__Ú __qualname__Ú__doc__©óú#py/clsummary/hardware_statistics.pyr r s€€€€€ððð €Drr Ú file_contentÚreturncóX—g}| d¦«D]‘}i}|sŒ| d¦«D]_}| d¦«}t|¦«dkr5|d ¦«||d ¦«<Œ`| |¦«Œ’|S)a� Parses the response of /proc files Since this file has a possibility to include multiple objects info, we need to parse all of them in the separate dicts :file_content: /proc file content. Example: processor : 0 vendor_id : AuthenticAMD processor : 1 vendor_id : AuthenticAMD_1 return: list of dicts with each node z ú ú:éér)ÚsplitÚlenÚstripÚappend)rÚresultÚ info_objectÚ temp_dictÚ info_attrÚvaluess rÚget_proc_info_as_list_of_dictsr!s¸€ð$€FØ#×)Ò)¨&Ñ1Ô1ð!ð!ˆ ؈ Øð Ø Ø$×*Ò*¨4Ñ0Ô0ð Að AˆIØ—_’_ SÑ)Ô)ˆFÝ�6‰{Œ{˜aÒÐØ/5°a¬y¯ªÑ/@Ô/@� ˜& œ)Ÿ/š/Ñ+Ô+Ñ,øØ� Š �iÑ Ô Ð Ð Ø €MrÚvaluecóV—t| ¦«d¦«dz S)z² Helper to get numeric value of string record and convert it to mb :value: metric value from /proc file. Example: '512 KB' return: converted value. Example: 0.5 ri)Úfloatr)r"s rÚconvert_string_kb_to_mb_valuer%2s$€õ �—’‘”˜qÔ!Ñ "Ô " TÑ )Ð)rc óŽ—g}tj¦«j}tjdtj¦«st d¦«‚|dvrt d|›d�¦«‚tddd¬¦«5}| ¦«}d d d ¦«n #1swxYwYt|¦«}|D]•}t|  d d ¦«¦«|  d |¦«t|  d d¦«¦«t|  dd ¦«¦«dœ}| |¦«Œ–|S)a_ Prepare list of dicts with required cpu metrics The base of this method was taken from rhn_client_tools (src/up2date_client/hardware.py) Each CPU will be represented with a dict { "model": "foo", "cache_mb": 100, "frequency_mhz": 100, "id": 0 } return: list of dicts with cpu metrics z /proc/cpuinfozFile for cpuinfo is restricted!)Úx86_64Úi386z Machine arch z isn't compatible!Úrúutf-8©ÚencodingNÚ processorÚ0z model namez cache sizeú0 KBzcpu MHz)ÚidÚmodelÚcache_mbÚ frequency_mhz)ÚosÚunameÚmachineÚaccessÚR_OKÚOSErrorr ÚopenÚreadr!ÚintÚgetr%r$r)Ú result_listr5ÚfÚ proc_cpuinfoÚcpu_listÚcpuÚcpu_dicts rÚget_cpu_metricsrD<s{€ð"€KÝ ŒH‰JŒJÔ €Eå Œ9�_¥b¤gÑ .Ô .ð9ÝÐ7Ñ8Ô8Ð8Ø Ð&Ð&Ð&ÝÐD¨5ÐDÐDÐDÑEÔEÐEå ˆo˜s¨WÐ 5Ñ 5Ô 5ð ¸Ø—v’v‘x”xˆ ð ð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð å-¨lÑ;Ô;€HØð %ð %ˆå�c—g’g˜k¨3Ñ/Ô/Ñ0Ô0ð—W’W˜\¨5Ñ1Ô1Ý5°c·g²g¸lÈFÑ6SÔ6SÑTÔTÝ" 3§7¢7¨9°cÑ#:Ô#:Ñ;Ô;ð  ð ˆð ×Ò˜8Ñ$Ô$Ð$Ð$Ø ÐsÁ2BÂBÂBcó–—tjdtj¦«std¦«‚t ddd¬¦«5}| ¦«}ddd¦«n #1swxYwYt |¦«d}t| dd ¦«¦«t| d d ¦«¦«d œ}|S) z„ Prepare dict of memory metrics Dict will be represented as: { "ram_mb": 8.5 "swap_mb": 2.04 } z /proc/meminfozFile for meminfo is restricted!r)r*r+NrÚMemTotalr/Ú SwapTotal)Úram_mbÚswap_mb) r4r7r8r9r:r;r!r%r=)r?Ú proc_meminfoÚmem_dictrs rÚget_memory_metricsrLesø€õ Œ9�_¥b¤gÑ .Ô .ð9ÝÐ7Ñ8Ô8Ð8Ý ˆo˜s¨WÐ 5Ñ 5Ô 5ð ¸Ø—v’v‘x”xˆ ð ð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð õ.¨lÑ;Ô;¸AÔ>€Hõ 0°· ² ¸ZÈÑ0PÔ0PÑQÔQÝ0°·²¸kÈ6Ñ1RÔ1RÑSÔSðð€Fð €MsÁA"Á"A&Á)A&)r4ÚtypingrrrrrÚ Exceptionr r!Ústrr$r%r<rDrLrrrúrPs4ðð € € € Ø6Ð6Ð6Ð6Ð6Ð6Ð6Ð6Ð6Ð6Ð6Ð6Ð6Ð6ð ð ð ð ð �9ñ ô ð ðØðà ˆ(�4˜ ˜Ô'Ô (Ô)ððððð>*¨ð*°ð*ð*ð*ð*ð&˜˜h t¨FØ,1°&¸%ÀÐ2DÔ,Eð-Fô(GôHôIð&ð&ð&ð&ðR˜D ¨ Ô/ððððððr