???????????????????????????? ??????????????/????????????????? ............/............... .........................../... ????????????????????????????? >>>>>>>>>>>>>/>>>>>>>>>>>>>>>>> ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>/>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ???????????????????????????? ??????????????/????????????????? ............/............... .........................../... ????????????????????????????? >>>>>>>>>>>>>/>>>>>>>>>>>>>>>>> ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>/>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> p8j _ndZddlZddlZddlZddlZddlZddlmZmZm Z m Z m Z m Z m Z mZmZddlmZddlmZmZmZ dZdZdZd Zd Z d Z!d Z"d Z#dZ$dZ%dZ&dZ'Gdde jPZ)Gdde*Z+dZ,dZ-dZ.dZ/Gdde*Z0dZ1dZ2ddZ3dZ4ejjd Z6d!Z7d"Z8d#Z9d$Z:d%Z;d&Zd)Z?d*Z@d+ZAd,ZBd-ZCd.ZDe0d/e4e0d0e3d1gd23e0d4e6e0d5e7e0d6e8e0d7e3d7ge0d8e9e0d9e1d:e0d;e1d<e0d=e1d>e0d?e1d@e0dAe1dBe0dCe1dDe0dEe1dFe0dGe1dHe0dIe1dJe0dKe2dLdMe0dNe:e0dOe2dPdQe0dRe;e0dSe<gZEge,dTdUje#e,dVdVe,dWdXje#e,dYdZe-d[d\e,d]d^e.d_d`e.dadbe.dcdde.dedfe.dgdhe.didje.dkdle.dmdne.dodpe-dqdre.dsdte-duee.dvdwe,dxdye,dzd{e,d|d|e,d}d}e/d~e=e,dde-dde/de?e,dde,dde/de@e-dde,dde/deAe,ddje#e-dee-dde/deBe/deCe,dde,dde,dde/deDe,dde,ddZGeje jdZJddZKy)aODoctor v2 vitals collector (KPT-5984). Python port of the kcdoctor.sh (1.0-8) vitals collection: gathers the same data set into a DataPackage-based archive processed by the patch server generic uploads pipeline. Scalar and short values are consolidated into a single ``doctor.json`` (the eportal doctor precedent), one field each, instead of a tiny archive entry per value; bulk data (logs, command dumps, package lists, sysfs tunables, crash artifacts) stays as separate archive entries. The 1:1 inventory of collected items lives in docs/features/KPT-5984-doctor-v2/parity-inventory.md. N) authconfig delivery_kit http_utilskcare log_utilsplatform_utilsserveridutils) run_command) HTTPErrorURLErrorhttplibz2.0-1z/boot/grub2/grub.cfgz/etc/kdump.confz/var/log/dpkg.logz/etc/apt/sources.list*z/etc/yum.repos.d/*z/var/log/libcare/*.logi'z/sys)zenable*znr_*zmax_*z*cnt*)z /sys/kernel/debug/tracing/eventsz/sys/kernel/tracing/eventsz /sys/devices)z [0-9]*.logzkmsg*logc$eZdZdZdZedZy)KcarectlDoctorPackagezkcarectl-doctorz/upload/kcarectl-doctor/c"tjSN)rDOCTOR_REPORT_MAX_SIZE_BYTES)selfs ,/usr/libexec/kcare/python/kcarectl/doctor.pymax_sizezKcarectlDoctorPackage.max_size;s222N)__name__ __module__ __qualname__ data_type upload_uripropertyrrrrr7s!I+J 33rrceZdZdZdZdZy)CollectionSpeczA single bulk vitals item ported from kcdoctor.sh. Collection failures are recorded in errors.log and never abort the report: an unhandled exception inside the package context manager would remove the whole archive. c ||_||_yr)arcname_collect)rr#collects r__init__zCollectionSpec.__init__Ls  rc |j||jy#t$r5}|jdj |j|Yd}~yd}~wwxYwNzfailed to collect {0}: {1})r$r# Exception log_errorformat)r data_packagees rapplyzCollectionSpec.applyQsP Y MM, 5 Y  " "#?#F#Ft||UV#W X X Ys A+AANrrr__doc__r&r.rrrr!r!Ds Yrr!c&fd}t||S)z4`run ""` kcdoctor.sh helper (no shell features)c*|j|yr) add_stdout)r,r#cmds rr%zrun_spec..collect]s-rr!)r#r4r%s ` rrun_specr6Ys. '7 ++rc&fd}t||S)z4`dump ""` kcdoctor.sh helper for regular filesc,|j|y)Nsrc_path)add_file)r,r#paths rr%zdump_spec..collecthsg5rr5r#r<r%s ` r dump_specr>ds6 '7 ++rc&fd}t||S)z`dump ""` for /proc and /sys files. tar reports them as 0-size so they are first read into memory (see the same approach in anomaly.prepare_kernel_anomaly_report). c tjjs!|jdj yt d5}|j ||jdddy#1swYyxYw)Nfile not found: {0}rb data_bytes)osr<existsr*r+openr;read)r,r#fr<s rr%zproc_dump_spec..collectwsnww~~d#  " "#8#?#?#E F  $  @  ! !'affh ! ? @ @ @s "A99Br5r=s ` rproc_dump_specrJos@ '7 ++rct||Srr5)r#fns r callable_specrMs '2 &&rceZdZdZdZdZy) FieldSpeczA single doctor.json field ported from kcdoctor.sh. Collection failures are recorded in errors.log and never abort the report; a collector returning None omits the field (e.g. a distro-specific source file absent on this system). c ||_||_yr)keyr$)rrQr%s rr&zFieldSpec.__init__s rc |j}||||j<yy#t$r5}|jdj|j|Yd}~yd}~wwxYwr()r$r)r*r+rQ)rr,reportvaluer-s rr.zFieldSpec.applysc MMOE  $F488      " "#?#F#FtxxQR#S T  s% A#+AA#Nr/rrrrOrOs %rrOcfd}|S)z`dump ""` as a doctor.json string field. Read in binary (non-utf8 safe) and decoded leniently; an absent distro-specific source file simply omits the field (None). ctjjsytd5}|j j ddj cdddS#1swYyxYwNrButf-8replace)rEr<rFrGrHdecodestrip)rIr<s rr%zread_field..collectsTww~~d# $  ?668??7I6<<> ? ? ?s .A&&A/r)r<r%s` r read_fieldr\s? Nrcftjtj|fd}|S)z`grep ` as a doctor.json list-of-lines field. Match on bytes (like collect_apt_sources) so a non-utf8 byte cannot lose a line; the matched lines are decoded leniently for the JSON. c0tjjsytd5}|j j }dddDcgc]&}j |s|jdd(c}S#1swY;xYwcc}wrW)rEr<rFrGrH splitlinessearchrZ)rIlinesliner<regexs rr%zgrep_field..collects{ww~~d# $  *FFH'')E *=BXDU\\RVEW GY/XX * *YsBB0BB)recompiler bstr)r<patternr%rcs` @r grep_fieldrhs) JJuzz'* +EY Nrcfd}|S)z@`run ""` captured as a doctor.json field instead of a file.cxtdd\}}}|xsdj}r|jS|S)NT catch_stdout catch_stderr)r r[r_)_stdouttextargvas_liness rr%zcmd_field..collects="4dN 61 "##%$,t 6$6rr)rrrsr%s`` r cmd_fieldrts7 NrctSr)DOCTOR_VERSIONrrrcollect_doctor_versionrws rc tjtjd}tj|j j S#t$rYywxYw)zthe public IP of the machine as seen by the patch server. Cached: the main_ip and server_id fields share one HTTP roundtrip per run. myipNA)rurlopenr get_patch_server_urlnstrrHr[r))responses r get_main_iprsR%%e&@&@&HIzz(--/*0022 sAA A'&A'ctj}|stjdd}t j |S)N.ro)r get_serveridrrYr r}) server_ids rcollect_server_idrs6%%'I M))#s3 ::i  rc*tjSr)rget_kernel_hashrrrcollect_kernel_idrs  ""rcti}dD]0}tdd|zgdd\}}}|xsdj||<2|S)N)armpouname-Trkrn)r r[)resultflagrorps r collect_unamersQ F)."GS4Z#8tZ^_ 61 "++-t . MrcNtjjtsyt td5}|j j dd}dddjDcgc]}d|vstjdd| c}S#1swYAxYwcc}w)z7`grep vmlinuz /boot/grub2/grub.cfg | sed 's/root=.*//'`NrBrXrYvmlinuzzroot=.*rn) rEr<rF GRUB2_CFGrGrHrZr_rdsub)rIrqrbs rcollect_grub2_entriesr s 77>>) $ i 3!vvxw 236:__5F \T)W[J[BFF:r4 ( \\33 ]s!B0 B":B"BcFttjtSr)sortedglobYUM_REPOS_GLOBrrrcollect_yum_reposrs $))N+ ,,rctjDcgc]\}}|s|}}}|tjdScc}}w)z8presence-only port of the kcdoctor.sh detect_cp() probes)cp softaculous)r CONTROL_PANEL_PROBEShas_softaculous)nameprobepanelss rcollect_control_panelrs?'5&I&I U{tUUWd UF U)G)G)I JJVs AAc tddgdd\}}}|j|tj|xsdj ddd  y ) z`ipcs -m | sed -e s/-/=/g`ipcsz-mTrkrnr=rXencodingrCN)r r;r rfrY)r,r#rorps r collect_ipcsr%sN~DtTLAvq'ejj&,B9O9OPSUX9Ydk.lmrctjjts%|j dj tyt td5}|jjDcgc] }d|vs| }}ddd|j|djdzycc}w#1swY4xYw)z$`grep ' install ' /var/log/dpkg.log`rANrBs install  rC) rEr<rFDPKG_LOGr*r+rGrHr_r;join)r,r#rIrbras rcollect_dpkg_install_logr,s 77>>( #4;;HEF h Q"#&&("5"5"7P$<4;OPPQ'ejj.?%.GHQQQs$!B=: B8B8B=8B==Ccxtjjdstjjdrd}n1tjjdrd} t|dnd}|j||y#t$r*}|j dj |Yd}~Ad}~wwxYw) Nz /usr/bin/rpmz/bin/rpmzFrpm -q -a --queryformat="%{N}|%{V}-%{R}|%{arch}|%{INSTALLTIME:date}\n"z /usr/bin/dpkgzJ/usr/bin/dpkg-query -W -f "${binary:Package}|${Version}|${Architecture}\n"zdpkg.logzfailed to collect dpkg.log: {0}zecho "unknown package manager")rEr<rFrr)r*r+r3)r,r# packages_cmdr-s rcollect_packagesr9s ww~~n% )C`  (d  P $\: >8 G\2  P  " "#D#K#KA#N O O Ps$ B B9 B44B9c tjd g}ttjtD]t}t j j|rBt j|D])\ }}|j fdt|D+d|j|v|s%|jdjtyg}|D]w} t|d5}|j}dddt!j"dj|d  |j fd j%Dy|j'|d j)|d z y#1swYxYw#t$r+} |jdj|| Yd} ~ d} ~ wwxYw) z/`grep -rE '^(deb|URIs)' /etc/apt/sources.list*`s ^(deb|URIs)c3^K|]$}tjj|&ywr)rEr<r).0rroots r z&collect_apt_sources..Us P$RWW\\$5Ps*-rANrBfailed to read {0}: {1}z{0}:rXrc3LK|]}j|s|zywr)r`)rrbprefixrcs rrz&collect_apt_sources..js!Ztu||TXGYVd]Zs$ $rrC)rdrerrAPT_SOURCES_GLOBrEr<isdirwalkextendappendr*r+rGrHr)r rfr_r;r) r,r#filesr<ronamesrarIcontentr-rrcrs @@@rcollect_apt_sourcesrLsz JJ 'E Etyy!123 77== "$''$- Qa P&-PP Q LL   4;; {0} <== rXrrrC)rrLIBCARE_LOGS_GLOBr*r+rGrHr_LOG_TAIL_LINESr)r rfrrr;) r,r#pathschunksr<rIrar-headers rcollect_libcare_logsros 499./ 0E 4;;? @ O22487K fuzz%001 2'ejj.@5.HI @ @   " "#<#C#CD!#L M  s0 D 'C>D >D D  D>!D99D>cJtjjtjsy|j |dj tjtjtjD]\}}}t|D]tfdtDstjj|}tjj|tj}|jdj ||y)z3crashreporter artifacts from /var/cache/kcare/dumpsN ls -lR {0}c3JK|]}tj|ywrfnmatchrrgrs rrz&collect_crash_dumps..Ug7??41U #zcrashreporter/{0}r9)rEr<rr KDUMPS_DIRr3r+rranyCRASH_DUMP_PATTERNSrrelpathr;)r,r#rrorr<rel_pathrs @rcollect_crash_dumpsrs 77==** +G\%8%89J9J%KL''&"3"34[a5M [DUATUUww||D$/77??41B1BC%%&9&@&@&JUY%Z [[rcrtjjtsyt j }tjj |sy|j|dj|ttjtjj|dD]}tjj |s#|jdjtjj|tjj|dy)Nr*zkdump/{0}/vmcore-dmesg.txtzvmcore-dmesg.txtr9)rEr<rF KDUMP_CONFrget_kdump_rootrr3r+rrrr;basename)r,r# kdump_rootevts r collect_kdumprs 77>>* %%%'J 77== $G\%8%8%DEdii Z =>?  ww}}S!  ( / /0@0@0E FWW\\#'9:   rc R g}tjtD]\}}}|jtrg|dd"t |D] t fdtDstjj| } t|d5}|j}ddd|jtjdj!|zdz|j#|dj|y#1swYixYw#t$rd}YywxYw)zGtunables gathered by the kcdoctor.sh get_sysfs_info() `find /sys` callsNc3JK|]}tj|ywrrrs rrz'collect_sysfs_config..rrrBrzcat {0} rrC)rEr SYSFS_ROOT startswithSYSFS_EXCLUDE_PREFIXESrrSYSFS_NAME_PATTERNSr<rrGrHr)rr rfr+r;) r,r#rrdirsrr<rIrrs @rcollect_sysfs_configrs FWWZ0VdE ??1 2DG 5M VDUATUUww||D$/"dD)+Q"#&&(+  ejj););D)ABWLuTU V V 'chhv.>?++ "!G"s* DD $D D D D&%D&doctor_version virt_whatz/usr/libexec/kcare/virt-whatT)rsmain_ipr kernel_iddaterredhat_releasez/etc/redhat-releasedebian_versionz/etc/debian_version os_releasez/etc/os-releaseissuez /etc/issuesysconfig_kernelz/etc/sysconfig/kernel proc_uptimez /proc/uptime proc_loadavgz /proc/loadavg proc_cmdlinez /proc/cmdline proc_versionz /proc/version default_grubz/etc/default/grubDEFAULT grub2_entries sshd_portz/etc/ssh/sshd_configPort yum_repos_d control_panelsyslogztail -n{0} /var/log/syslogdmesgmessagesztail -n{0} /var/log/messagesls_var_cache_kcarezls -lR /var/cache/kcare/z kcare.confz/etc/sysconfig/kcare/kcare.confcpuinfozcat /proc/cpuinfo proc_vmstatz /proc/vmstat proc_devicesz /proc/devicesproc_diskstatsz/proc/diskstats proc_mdstatz /proc/mdstat proc_meminfoz /proc/meminfo proc_swapsz /proc/swapsproc_filesystemsz/proc/filesystems proc_mountsz /proc/mountsproc_interruptsz/proc/interruptsz grub.confz/boot/grub/grub.conf proc_modulesz /proc/modulesz grub2.cfg proc_zoneinfoz/proc/zoneinfols_boot_configsz:ls /etc/grub.conf /boot/grub/grub.conf /boot/grub/menu.lstls_bootz ls -l /bootprintenv dmidecodersysctlz sysctl -az sysctl.confz/etc/sysctl.confz packages.listlspciz lspci -vvdpkg_lzdpkg -l apt_sourceszyum.confz /etc/yum.conf yum_repolistz yum repolist libcare_logsz kcarectl.logz tail -n{0} /var/log/kcarectl.logz kdump.confz kcare-cronz/etc/cron.d/kcare-cronzcrashreporter/lszkdump/ls aa_statusz aa-statussestatus kprobes_listz"cat /sys/kernel/debug/kprobes/list sysfs_configlsblkzlsblk -fdfzdf -h)loggerct}|5i}tD]}|j|||jd|tD]}|j| ddd|S#1swY|SxYw)Nz doctor.json)r FIELD_SPECSr.add_json FILE_SPECS)r,rSfieldspecs rprepare_doctor_reportr&s~ )*L %  .E KK f - . mV4 %D JJ| $ %% % s AA&&A0c|stjr4|rdnd}tjdj |d|yt j tjdd|yt}|tjd|y |j}tjd j |dtjd j ||j%y#tttjt j"f$r5}tjd j ||Yd}~nd}~wwxYw#|j%wxYw) aCollect and upload the doctor report via the generic uploads proxy. PUTs the archive to ``/upload/kcarectl-doctor/`` -- the same modern pipeline as ``kernel-anomaly`` -- which ePortal proxies transparently to the patch server, so no ePortal change is required. Any 2xx reply is success, including the ``REDUCED_REPORT`` ``204`` where the proxy intentionally drops the report (``send()`` returns without raising, so we do not fall back). Falls back to the legacy ``kcdoctor.sh`` flow (``fallback``) when: * ``force_fallback`` (the ``--doctor --fallback`` CLI flag) or ``config.FORCE_DOCTOR_FALLBACK`` is set -- the rollout kill-switch. ``--fallback`` is the one-off, per-invocation form; the config knob is settable per host in kcare.conf or pushed fleet-wide via the ``KC-Flag-Force-Doctor-Fallback`` feature flag. Either forces the legacy flow on every host, registered or not, before the new path is even considered; * the host is not registered, i.e. there is no auth string (OQ-4: the proxy upload requires auth, so the new path is not even attempted); * report collection failed (``prepare_doctor_report`` returned None); * the new route is unavailable on an older patch server / ePortal -- a 404 / 405 / 403, surfaced as ``HTTPError``, or a connection-level failure. ``send()`` drives ``http_utils.upload_file`` (raw ``httplib``, not ``urllib``), so transport failures surface as an ``OSError`` subclass -- ``socket.timeout``, ``ConnectionRefused``, ``socket.gaierror`` (DNS), ``ssl.SSLError`` -- or an ``httplib.HTTPException``, *not* ``URLError``; all of these mean the new path is unusable. ``upload_file`` raises only on status >= 400, so a redirect is not treated as a failure; the proxy and patch server never redirect uploads. :param fallback: legacy ``kcdoctor.sh`` runner, injected by the caller (KPT-6065) to keep this module free of an ``__init__`` import cycle. :param force_fallback: when True (``--doctor --fallback``), skip the v2 path and run ``fallback`` directly; the per-invocation form of ``config.FORCE_DOCTOR_FALLBACK``. z--fallback requestedzFORCE_DOCTOR_FALLBACK is setz.doctor: {0}; using the legacy kcdoctor.sh flowF) print_msgNzAdoctor: host is not registered; using the legacy kcdoctor.sh flowzCdoctor: report collection failed; using the legacy kcdoctor.sh flowzdoctor: report uploaded as {0}z,Please provide this filename to support: {0}zJdoctor: report upload unavailable ({0}); using the legacy kcdoctor.sh flow)rFORCE_DOCTOR_FALLBACKrloginfor+rget_http_auth_stringr&logwarnsendr print_wrapperr rr HTTPExceptionsocketerrorremove_archive)fallbackforce_fallbacksrcr, upload_nameerrs rsend_doctor_reportr8-sIR55(6$rJrMrOr\rhrtrwcachedrrrrrrrrrrrrrrrr!r+r# catch_errorsr,r&r8rrrrFs  nnn.66 "  +%,  ; 13L443YVY*,,,('%%2&,    !# ]- Kn I3& IFJ4[$ 2@8 67 k9&D%EPTUV i% k,- k,- fi)* g}%  +@ AB  +@ AB lJ'89: gz,/0  *-D"EF mZ78 nj9: nj9: nj9: nj)JK- Wg- Z7>>~NO- !#=> - l=> -  Y+, -=.1->?3-#%67-=.1->?3-</-%':;-=.1-$&89- k12!-">?3#-$k9%%-&?$45'-(  \])-* Y &+-, Z$--. [+&/-0&,'1-2 X{#3-4m/05-6/#347-8 Wk"9-: Xy!;-<-!45=->j/*?-@ ^^,A-B."67C-D ^?FF~VWE-FlJ'G-Hl45I-J$&9:K-L*m,M-N [+&O-P Z$Q-R ^ABS-T."67U-V Wj!W-X T7Y- `9,,-.(T&r